Commit 1af01db3 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Clipboard.c: factor out nxagentReplyRequestSelection

parent 5e248710
...@@ -595,10 +595,37 @@ void nxagentClearSelection(XEvent *X) ...@@ -595,10 +595,37 @@ void nxagentClearSelection(XEvent *X)
nxagentPrintClipboardStat("after nxagentClearSelection"); nxagentPrintClipboardStat("after nxagentClearSelection");
} }
void nxagentRequestSelection(XEvent *X) /*
* Send a SelectionNotify event as reply to the RequestSelection
* event X. If success is True take the property from the event, else
* take None (which reports "failed/denied" to the requestor.
*/
void nxagentReplyRequestSelection(XEvent *X, Bool success)
{ {
XSelectionEvent eventSelection = {0}; XSelectionEvent eventSelection = {
.requestor = X->xselectionrequest.requestor,
.selection = X->xselectionrequest.selection,
.target = X->xselectionrequest.target,
.time = X->xselectionrequest.time,
.property = X->xselectionrequest.property
};
if (!success)
{
#ifdef DEBUG
fprintf(stderr, "%s: denying request\n", __func__);
#endif
eventSelection.property = None;
}
SendSelectionNotifyEventToServer(&eventSelection);
NXFlushDisplay(nxagentDisplay, NXFlushLink);
}
void nxagentRequestSelection(XEvent *X)
{
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s: Got called.\n", __func__); fprintf(stderr, "%s: Got called.\n", __func__);
#endif #endif
...@@ -631,9 +658,6 @@ FIXME: Do we need this? ...@@ -631,9 +658,6 @@ FIXME: Do we need this?
SAFE_XFree(strTarget); SAFE_XFree(strTarget);
*/ */
memset(&eventSelection, 0, sizeof(XSelectionEvent));
eventSelection.property = None;
if (X->xselectionrequest.target == serverTARGETS) if (X->xselectionrequest.target == serverTARGETS)
{ {
Atom targets[] = {XA_STRING}; Atom targets[] = {XA_STRING};
...@@ -647,7 +671,7 @@ FIXME: Do we need this? ...@@ -647,7 +671,7 @@ FIXME: Do we need this?
PropModeReplace, PropModeReplace,
(unsigned char*)&targets, (unsigned char*)&targets,
numTargets); numTargets);
eventSelection.property = X->xselectionrequest.property; nxagentReplyRequestSelection(X, True);
} }
else if (X->xselectionrequest.target == serverTIMESTAMP) else if (X->xselectionrequest.target == serverTIMESTAMP)
{ {
...@@ -662,17 +686,14 @@ FIXME: Do we need this? ...@@ -662,17 +686,14 @@ FIXME: Do we need this?
PropModeReplace, PropModeReplace,
(unsigned char *) &lastSelectionOwner[i].lastTimeChanged, (unsigned char *) &lastSelectionOwner[i].lastTimeChanged,
1); 1);
eventSelection.property = X->xselectionrequest.property; nxagentReplyRequestSelection(X, True);
} }
} }
else
eventSelection.requestor = X->xselectionrequest.requestor; {
eventSelection.selection = X->xselectionrequest.selection; /* deny the request */
eventSelection.target = X->xselectionrequest.target; nxagentReplyRequestSelection(X, False);
eventSelection.time = X->xselectionrequest.time; }
SendSelectionNotifyEventToServer(&eventSelection);
return; return;
} }
...@@ -750,18 +771,8 @@ FIXME: Do we need this? ...@@ -750,18 +771,8 @@ FIXME: Do we need this?
} }
else else
{ {
/* /* deny the request */
* Probably we must send a Notify nxagentReplyRequestSelection(X, False);
* to requestor with property None.
*/
eventSelection.requestor = X->xselectionrequest.requestor;
eventSelection.selection = X->xselectionrequest.selection;
eventSelection.target = X->xselectionrequest.target;
eventSelection.property = None;
eventSelection.time = X->xselectionrequest.time;
SendSelectionNotifyEventToServer(&eventSelection);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment