1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-07 06:14:13 +01:00

endless loop fix for W_GetSelection when selection is owned by the app itself

This commit is contained in:
kojima
1999-05-14 03:08:05 +00:00
parent bb0228dae5
commit a98624ab84

View File

@@ -262,7 +262,6 @@ WMCreateSelectionHandler(WMWidget *w, Atom selection, Time timestamp,
static void static void
timeoutHandler(void *data) timeoutHandler(void *data)
{ {
@@ -270,6 +269,55 @@ timeoutHandler(void *data)
} }
static Bool
getInternalSelection(WMScreen *scr, Atom selection, Atom target,
void **data, unsigned *length)
{
Window owner;
SelectionHandler *handler;
/*
* Check if the selection is owned by this application and if so,
* do the conversion directly.
*/
data = NULL;
owner = XGetSelectionOwner(scr->display, selection);
if (!owner)
return False;
handler = selHandlers;
while (handler) {
if (WMWidgetXID(handler->widget) == owner
/* && handler->selection == event->selection*/) {
break;
}
handler = handler->next;
}
if (!handler)
return False;
if (handler->convProc) {
Atom atom;
int format;
if (!(*handler->convProc)(handler->widget, handler->selection,
target, &atom, data, length, &format)) {
return True;
}
if (handler->doneProc) {
(*handler->doneProc)(handler->widget, handler->selection, target);
}
}
return True;
}
char* char*
W_GetTextSelection(WMScreen *scr, Atom selection) W_GetTextSelection(WMScreen *scr, Atom selection)
{ {
@@ -316,8 +364,16 @@ W_GetTextSelection(WMScreen *scr, Atom selection)
WMHandlerID timer; WMHandlerID timer;
int timeout = 0; int timeout = 0;
XEvent ev; XEvent ev;
unsigned length;
XDeleteProperty(scr->display, scr->groupLeader, scr->clipboardAtom); XDeleteProperty(scr->display, scr->groupLeader, scr->clipboardAtom);
if (getInternalSelection(scr, selection, XA_STRING, (void**)&data,
&length)) {
return data;
}
XConvertSelection(scr->display, selection, XA_STRING, XConvertSelection(scr->display, selection, XA_STRING,
scr->clipboardAtom, scr->groupLeader, scr->clipboardAtom, scr->groupLeader,
scr->lastEventTime); scr->lastEventTime);
@@ -333,7 +389,7 @@ W_GetTextSelection(WMScreen *scr, Atom selection)
wwarning("selection retrieval timed out"); wwarning("selection retrieval timed out");
return NULL; return NULL;
} }
/* nobody owns the selection or the current owner has /* nobody owns the selection or the current owner has
* nothing to do with what we need */ * nothing to do with what we need */
if (ev.xselection.property == None) { if (ev.xselection.property == None) {