diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2019-08-05 16:56:57 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2019-09-29 17:44:08 +0200 |
commit | 1af01db33bd4e16ad344aaae86ca590e5688b822 (patch) | |
tree | d4c465fff6eeb015a2537bfe52e0fe087874f29a | |
parent | 5e2487108e8f663752c94023568c5354c0df721b (diff) | |
download | nx-libs-1af01db33bd4e16ad344aaae86ca590e5688b822.tar.gz nx-libs-1af01db33bd4e16ad344aaae86ca590e5688b822.tar.bz2 nx-libs-1af01db33bd4e16ad344aaae86ca590e5688b822.zip |
Clipboard.c: factor out nxagentReplyRequestSelection
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 7f3dec05e..1ee60ec76 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -595,10 +595,37 @@ void nxagentClearSelection(XEvent *X) 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 fprintf(stderr, "%s: Got called.\n", __func__); #endif @@ -631,9 +658,6 @@ FIXME: Do we need this? SAFE_XFree(strTarget); */ - memset(&eventSelection, 0, sizeof(XSelectionEvent)); - eventSelection.property = None; - if (X->xselectionrequest.target == serverTARGETS) { Atom targets[] = {XA_STRING}; @@ -647,7 +671,7 @@ FIXME: Do we need this? PropModeReplace, (unsigned char*)&targets, numTargets); - eventSelection.property = X->xselectionrequest.property; + nxagentReplyRequestSelection(X, True); } else if (X->xselectionrequest.target == serverTIMESTAMP) { @@ -662,17 +686,14 @@ FIXME: Do we need this? PropModeReplace, (unsigned char *) &lastSelectionOwner[i].lastTimeChanged, 1); - eventSelection.property = X->xselectionrequest.property; + nxagentReplyRequestSelection(X, True); } } - - eventSelection.requestor = X->xselectionrequest.requestor; - eventSelection.selection = X->xselectionrequest.selection; - eventSelection.target = X->xselectionrequest.target; - eventSelection.time = X->xselectionrequest.time; - - SendSelectionNotifyEventToServer(&eventSelection); - + else + { + /* deny the request */ + nxagentReplyRequestSelection(X, False); + } return; } @@ -750,18 +771,8 @@ FIXME: Do we need this? } else { - /* - * Probably we must send a Notify - * 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); + /* deny the request */ + nxagentReplyRequestSelection(X, False); } } } |