diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2019-11-21 23:58:17 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-01-05 23:36:02 +0100 |
commit | 2b59a199332809722e5fceb891b6845f328054bc (patch) | |
tree | 77df46c35204d415f27982f2ff0a10cc397475ba /nx-X11 | |
parent | 15ef708747d26bef2a7ecb28130724a35b6637a5 (diff) | |
download | nx-libs-2b59a199332809722e5fceb891b6845f328054bc.tar.gz nx-libs-2b59a199332809722e5fceb891b6845f328054bc.tar.bz2 nx-libs-2b59a199332809722e5fceb891b6845f328054bc.zip |
Clipboard.c: simplify nxagentSetSelectionOwner
We do not need to loop over all selections. We have a helper for that.
Diffstat (limited to 'nx-X11')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 19ad34ee8..6b8123643 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -1622,42 +1622,35 @@ void nxagentSetSelectionOwner(Selection *pSelection) } #endif - /* - * Only for PRIMARY and CLIPBOARD selections. - */ - - for (int i = 0; i < nxagentMaxSelections; i++) + int i = nxagentFindCurrentSelectionIndex(pSelection->selection); + if (i < NumCurrentSelections) { - /* FIXME: using CurrentSelections with the index limited my MaxSelections looks wrong */ - if (pSelection->selection == CurrentSelections[i].selection) - { - #ifdef DEBUG - fprintf(stderr, "%s: lastSelectionOwner.client [%p] index [%d] -> [%p] index [%d]\n", __func__, - (void *)lastSelectionOwner[i].client, CLINDEX(lastSelectionOwner[i].client), - (void *)pSelection->client, CLINDEX(pSelection->client)); - fprintf(stderr, "%s: lastSelectionOwner.window [0x%x] -> [0x%x]\n", __func__, - lastSelectionOwner[i].window, pSelection->window); - fprintf(stderr, "%s: lastSelectionOwner.windowPtr [%p] -> [%p] [0x%x] (serverWindow: [0x%x])\n", __func__, - (void *)lastSelectionOwner[i].windowPtr, (void *)pSelection->pWin, - nxagentWindow(pSelection->pWin), serverWindow); - fprintf(stderr, "%s: lastSelectionOwner.lastTimeChanged [%d]\n", __func__, - lastSelectionOwner[i].lastTimeChanged); - #endif + #ifdef DEBUG + fprintf(stderr, "%s: lastSelectionOwner.client [%p] index [%d] -> [%p] index [%d]\n", __func__, + (void *)lastSelectionOwner[i].client, CLINDEX(lastSelectionOwner[i].client), + (void *)pSelection->client, CLINDEX(pSelection->client)); + fprintf(stderr, "%s: lastSelectionOwner.window [0x%x] -> [0x%x]\n", __func__, + lastSelectionOwner[i].window, pSelection->window); + fprintf(stderr, "%s: lastSelectionOwner.windowPtr [%p] -> [%p] [0x%x] (serverWindow: [0x%x])\n", __func__, + (void *)lastSelectionOwner[i].windowPtr, (void *)pSelection->pWin, + nxagentWindow(pSelection->pWin), serverWindow); + fprintf(stderr, "%s: lastSelectionOwner.lastTimeChanged [%d]\n", __func__, + lastSelectionOwner[i].lastTimeChanged); + #endif - /* - * inform the real X server that our serverWindow is the - * clipboard owner. - */ - XSetSelectionOwner(nxagentDisplay, lastSelectionOwner[i].selection, serverWindow, CurrentTime); + /* + * inform the real X server that our serverWindow is the + * clipboard owner. + */ + XSetSelectionOwner(nxagentDisplay, lastSelectionOwner[i].selection, serverWindow, CurrentTime); - /* - * The real owner window (inside nxagent) is stored in - * lastSelectionOwner.window. lastSelectionOwner.windowPtr - * points to the struct that contains all information about the - * owner window. - */ - nxagentStoreSelectionOwner(i, pSelection); - } + /* + * The real owner window (inside nxagent) is stored in + * lastSelectionOwner.window. lastSelectionOwner.windowPtr + * points to the struct that contains all information about the + * owner window. + */ + nxagentStoreSelectionOwner(i, pSelection); } lastClientWindowPtr = NULL; |