1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
#ifndef lint
#ifdef SCCS
static char sccsid[] = "@(#)selection.c 1.11 93/06/28";
#endif
#endif
/*
* (c) Copyright 1990 Sun Microsystems, Inc. Sun design patents
* pending in the U.S. and foreign countries. See LEGAL NOTICE
* file for terms of the license.
*/
#ifdef __linux
/* Kludge to prevent multiple variables with same name */
#define __DEFINE_SEL_IMPL_VARS
#endif
#include <xview_private/sel_impl.h>
#ifdef __linux
#undef __DEFINE_SEL_IMPL_VARS
#endif
#include <xview/window.h>
Pkg_private char *xv_sel_atom_to_str(/* display, atom */);
Pkg_private Atom xv_sel_str_to_atom(/* display, string */);
/*ARGSUSED*/
Pkg_private int
sel_init(parent, sel_public, avlist)
Xv_Window parent;
Selection sel_public;
Attr_avlist avlist;
{
Display *dpy;
Sel_info *sel;
Xv_sel *sel_object = (Xv_sel *) sel_public;
XID xid = (XID) xv_get( parent, XV_XID );
/* Allocate and clear private data */
sel = xv_alloc(Sel_info);
/* Link private and public data */
sel_object->private_data = (Xv_opaque) sel;
sel->public_self = sel_public;
dpy = XV_DISPLAY_FROM_WINDOW( parent );
/* Initialize private data */
sel->dpy = dpy;
sel->rank = XA_PRIMARY;
sel->rank_name = xv_sel_atom_to_str( dpy, sel->rank, xid );
sel->timeout = defaults_get_integer("selection.timeout",
"Selection.Timeout", 3);
#ifdef WIN_SEL_EVENT_PROC
/* Register selection event handler */
xv_set(parent,
WIN_SEL_EVENT_PROC, sel_event_proc,
0);
#endif
return XV_OK;
}
/*ARGSUSED*/
Pkg_private Xv_opaque
sel_set_avlist(sel_public, avlist)
Selection sel_public;
Attr_avlist avlist;
{
Attr_avlist attrs;
int rank_set = FALSE;
int rank_name_set = FALSE;
Sel_info *sel = SEL_PRIVATE(sel_public);
XID xid=0;
for (attrs = avlist; *attrs; attrs = attr_next(attrs)) {
switch (attrs[0]) {
case SEL_RANK:
sel->rank = (Atom) attrs[1];
rank_set = TRUE;
break;
case SEL_RANK_NAME:
sel->rank_name = (char *) attrs[1];
rank_name_set = TRUE;
break;
case SEL_TIME:
sel->time = *(struct timeval *) attrs[1];
break;
case SEL_TIMEOUT_VALUE:
sel->timeout = (int) attrs[1];
break;
}
}
/*
xid = (XID) xv_get( sel_public, XV_XID );
*/
if (rank_set && !rank_name_set)
sel->rank_name = xv_sel_atom_to_str( sel->dpy, sel->rank, xid );
else if (rank_name_set && !rank_set)
sel->rank = xv_sel_str_to_atom( sel->dpy, sel->rank_name, xid );
return XV_OK;
}
/*ARGSUSED*/
Pkg_private Xv_opaque
sel_get_attr(sel_public, status, attr, valist)
Selection sel_public;
int *status;
Attr_attribute attr;
va_list valist;
{
Sel_info *sel = SEL_PRIVATE(sel_public);
switch (attr) {
case SEL_RANK:
return (Xv_opaque) sel->rank;
case SEL_RANK_NAME:
return (Xv_opaque) sel->rank_name;
case SEL_TIME:
return (Xv_opaque) &sel->time;
case SEL_TIMEOUT_VALUE:
return (Xv_opaque) sel->timeout;
default:
if ( xv_check_bad_attr( &xv_sel_pkg, attr ) == XV_ERROR )
*status = XV_ERROR;
return (Xv_opaque) 0;
}
}
Pkg_private int
sel_destroy(sel_public, status)
Selection sel_public;
Destroy_status status;
{
Sel_info *sel = SEL_PRIVATE(sel_public);
if (status == DESTROY_CHECKING || status == DESTROY_SAVE_YOURSELF
|| status == DESTROY_PROCESS_DEATH)
return XV_OK;
/* Free up malloc'ed storage */
free(sel);
return XV_OK;
}
|