From 68125b06e852c96d60c1ee704f1700de8aa6c629 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 22 Nov 2019 21:15:54 +0100 Subject: Clipboard.c: Use Find*Index helpers at more locations --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 31 +++++++++++++------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 0709954b9..715895cf0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -770,15 +770,17 @@ void nxagentRequestSelection(XEvent *X) } /* the selection in this request is none we own. */ - if ((X->xselectionrequest.selection != lastSelectionOwner[nxagentPrimarySelection].selection) && - (X->xselectionrequest.selection != lastSelectionOwner[nxagentClipboardSelection].selection)) { - #ifdef DEBUG - fprintf(stderr, "%s: not owning selection [%ld] - denying request.\n", __func__, X->xselectionrequest.selection); - #endif + int i = nxagentFindLastSelectionOwnerIndex(X->xselectionrequest.selection); + if (i == nxagentMaxSelections) + { + #ifdef DEBUG + fprintf(stderr, "%s: not owning selection [%ld] - denying request.\n", __func__, X->xselectionrequest.selection); + #endif - nxagentReplyRequestSelection(X, False); - return; + nxagentReplyRequestSelection(X, False); + return; + } } /* this is a special request like TARGETS or TIMESTAMP */ @@ -1724,16 +1726,13 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, return 0; } - for (int i = 0; i < nxagentMaxSelections; i++) + int i = nxagentFindCurrentSelectionIndex(selection); + if (i < NumCurrentSelections && IS_INTERNAL_OWNER(i)) { - if (selection == CurrentSelections[i].selection && - IS_INTERNAL_OWNER(i)) - { - /* - * There is a client owner on the agent side, let normal dix stuff happen. - */ - return 0; - } + /* + * There is a client owner on the agent side, let normal dix stuff happen. + */ + return 0; } /* -- cgit v1.2.3