home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Shareware 1999 March
/
PCShareware-3-99.iso
/
IMPLE
/
DJGPP.RAR
/
DJGPP2
/
XLIB-SR0.ZIP
/
SRC
/
XLIBEMU
/
SELECTIO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-14
|
3KB
|
135 lines
/* $Id: selectio.c 1.2 1994/01/15 02:18:38 ulrich Exp $ */
/*
* selection.c
*
* X library functions for selections.
*/
#include "Xlibemu.h"
extern Time _WCurrentTime();
typedef struct {
Atom selection;
Window owner;
Time last_change;
} _WSelection;
typedef struct {
int next;
int size;
_WSelection *selections;
} _WSelectionList;
_WSelectionList _SelList = { 0 };
XSetSelectionOwner(dpy, selection, owner, time)
register Display *dpy;
Atom selection;
Window owner;
Time time;
{
int i;
_WSelection *sp;
XEvent xe;
for (i = _SelList.next; --i >= 0; ) {
if (_SelList.selections[i].selection == selection)
break;
}
if (i < 0) {
if (_SelList.next >= _SelList.size) {
_SelList.size += _SelList.size/2 + 1;
_SelList.selections = (_WSelection *)
Xrealloc (_SelList.selections,
_SelList.size * sizeof(_WSelection));
}
i = _SelList.next++;
_SelList.selections[i].selection = selection;
_SelList.selections[i].owner = None;
_SelList.selections[i].last_change = 0;
}
sp = &_SelList.selections[i];
if (time == CurrentTime)
time = _WCurrentTime();
if (time < sp->last_change || time > _WCurrentTime()) {
return 0;
}
sp->last_change = time;
if (sp->owner != None && sp->owner != owner) {
xe.xselectionclear.type = SelectionClear;
xe.xselectionclear.send_event = False;
xe.xselectionclear.display = dpy;
xe.xselectionclear.window = sp->owner;
xe.xselectionclear.selection = selection;
xe.xselectionclear.time = sp->last_change;
_XEnq (dpy, &xe);
}
sp->owner = owner;
return 1;
}
Window XGetSelectionOwner(dpy, selection)
register Display *dpy;
Atom selection;
{
int i;
for (i = _SelList.next; --i >= 0; ) {
if (_SelList.selections[i].selection == selection)
break;
}
if (i < 0) {
return None;
}
return _SelList.selections[i].owner;
}
XConvertSelection(dpy, selection, target, property, requestor, time)
register Display *dpy;
Atom selection, target;
Atom property;
Window requestor;
Time time;
{
int i;
XEvent xe;
for (i = _SelList.next; --i >= 0; ) {
if (_SelList.selections[i].selection == selection)
break;
}
if (i < 0) {
_WError (dpy, (XID) requestor, BadAtom, X_ConvertSelection);
return 0;
}
if (_SelList.selections[i].owner != None) {
xe.xselectionrequest.type = SelectionRequest;
xe.xselectionrequest.send_event = False;
xe.xselectionrequest.display = dpy;
xe.xselectionrequest.owner = _SelList.selections[i].owner;
xe.xselectionrequest.requestor = requestor;
xe.xselectionrequest.selection = _SelList.selections[i].selection;
xe.xselectionrequest.target = target;
xe.xselectionrequest.property = property;
xe.xselectionrequest.time = (time == CurrentTime) ? _WCurrentTime() : time;
_XEnq (dpy, &xe);
return 1;
}
else {
xe.xselection.type = SelectionNotify;
xe.xselection.send_event = False;
xe.xselection.display = dpy;
xe.xselection.requestor = requestor;
xe.xselection.selection = _SelList.selections[i].selection;
xe.xselection.target = target;
xe.xselection.property = None;
xe.xselection.time = (time == CurrentTime) ? _WCurrentTime() : time;
_XEnq (dpy, &xe);
return 1;
}
}