Commit 2b59a199 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Clipboard.c: simplify nxagentSetSelectionOwner

We do not need to loop over all selections. We have a helper for that.
parent 15ef7087
...@@ -1622,42 +1622,35 @@ void nxagentSetSelectionOwner(Selection *pSelection) ...@@ -1622,42 +1622,35 @@ void nxagentSetSelectionOwner(Selection *pSelection)
} }
#endif #endif
/* int i = nxagentFindCurrentSelectionIndex(pSelection->selection);
* Only for PRIMARY and CLIPBOARD selections. if (i < NumCurrentSelections)
*/
for (int i = 0; i < nxagentMaxSelections; i++)
{ {
/* FIXME: using CurrentSelections with the index limited my MaxSelections looks wrong */ #ifdef DEBUG
if (pSelection->selection == CurrentSelections[i].selection) fprintf(stderr, "%s: lastSelectionOwner.client [%p] index [%d] -> [%p] index [%d]\n", __func__,
{ (void *)lastSelectionOwner[i].client, CLINDEX(lastSelectionOwner[i].client),
#ifdef DEBUG (void *)pSelection->client, CLINDEX(pSelection->client));
fprintf(stderr, "%s: lastSelectionOwner.client [%p] index [%d] -> [%p] index [%d]\n", __func__, fprintf(stderr, "%s: lastSelectionOwner.window [0x%x] -> [0x%x]\n", __func__,
(void *)lastSelectionOwner[i].client, CLINDEX(lastSelectionOwner[i].client), lastSelectionOwner[i].window, pSelection->window);
(void *)pSelection->client, CLINDEX(pSelection->client)); fprintf(stderr, "%s: lastSelectionOwner.windowPtr [%p] -> [%p] [0x%x] (serverWindow: [0x%x])\n", __func__,
fprintf(stderr, "%s: lastSelectionOwner.window [0x%x] -> [0x%x]\n", __func__, (void *)lastSelectionOwner[i].windowPtr, (void *)pSelection->pWin,
lastSelectionOwner[i].window, pSelection->window); nxagentWindow(pSelection->pWin), serverWindow);
fprintf(stderr, "%s: lastSelectionOwner.windowPtr [%p] -> [%p] [0x%x] (serverWindow: [0x%x])\n", __func__, fprintf(stderr, "%s: lastSelectionOwner.lastTimeChanged [%d]\n", __func__,
(void *)lastSelectionOwner[i].windowPtr, (void *)pSelection->pWin, lastSelectionOwner[i].lastTimeChanged);
nxagentWindow(pSelection->pWin), serverWindow); #endif
fprintf(stderr, "%s: lastSelectionOwner.lastTimeChanged [%d]\n", __func__,
lastSelectionOwner[i].lastTimeChanged);
#endif
/* /*
* inform the real X server that our serverWindow is the * inform the real X server that our serverWindow is the
* clipboard owner. * clipboard owner.
*/ */
XSetSelectionOwner(nxagentDisplay, lastSelectionOwner[i].selection, serverWindow, CurrentTime); XSetSelectionOwner(nxagentDisplay, lastSelectionOwner[i].selection, serverWindow, CurrentTime);
/* /*
* The real owner window (inside nxagent) is stored in * The real owner window (inside nxagent) is stored in
* lastSelectionOwner.window. lastSelectionOwner.windowPtr * lastSelectionOwner.window. lastSelectionOwner.windowPtr
* points to the struct that contains all information about the * points to the struct that contains all information about the
* owner window. * owner window.
*/ */
nxagentStoreSelectionOwner(i, pSelection); nxagentStoreSelectionOwner(i, pSelection);
}
} }
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
......
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