diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2019-11-18 01:11:26 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-01-05 23:36:02 +0100 |
commit | 20120205bb93b1195b59b68e452f90a6e394075c (patch) | |
tree | 5c4a1139709b63c2a689eb9c46c4c8a015ed9ecd /nx-X11/programs/Xserver | |
parent | 8500b4bc0d1bb00bf5ace9e173ce1eebc9e6e6b6 (diff) | |
download | nx-libs-20120205bb93b1195b59b68e452f90a6e394075c.tar.gz nx-libs-20120205bb93b1195b59b68e452f90a6e394075c.tar.bz2 nx-libs-20120205bb93b1195b59b68e452f90a6e394075c.zip |
Clipboard.c: Fix: re-claim selection on reconnect
On reconnect claim the selection ownership if one of nxagent's clients
is a selection owner. The code for this was already there but could
not work because the lastSelectionOwner array was always dropped at
the beginning of nxagentInitClipboard.
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 69cc7ecc5..a3d8fb5c1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -2127,19 +2127,26 @@ Bool nxagentInitClipboard(WindowPtr pWin) fprintf(stderr, "%s: Got called.\n", __func__); #endif - SAFE_free(lastSelectionOwner); + if (!nxagentReconnectTrap) + { + SAFE_free(lastSelectionOwner); - lastSelectionOwner = (SelectionOwner *) malloc(nxagentMaxSelections * sizeof(SelectionOwner)); + lastSelectionOwner = (SelectionOwner *) malloc(nxagentMaxSelections * sizeof(SelectionOwner)); - if (lastSelectionOwner == NULL) + if (lastSelectionOwner == NULL) + { + FatalError("nxagentInitClipboard: Failed to allocate memory for the clipboard selections.\n"); + } + nxagentInitSelectionOwner(nxagentPrimarySelection, XA_PRIMARY); + nxagentInitSelectionOwner(nxagentClipboardSelection, nxagentAtoms[10]); /* CLIPBOARD */ + } + else { - FatalError("nxagentInitClipboard: Failed to allocate memory for the clipboard selections.\n"); + /* the clipboard selection atom might have changed on the new X + server. Primary is constant. */ + lastSelectionOwner[nxagentClipboardSelection].selection = nxagentAtoms[10]; /* CLIPBOARD */ } - - nxagentInitSelectionOwner(nxagentPrimarySelection, XA_PRIMARY); - nxagentInitSelectionOwner(nxagentClipboardSelection, nxagentAtoms[10]); /* CLIPBOARD */ - #ifdef NXAGENT_TIMESTAMP { fprintf(stderr, "%s: Initializing start [%ld] milliseconds.\n", __func__, @@ -2229,22 +2236,23 @@ Bool nxagentInitClipboard(WindowPtr pWin) if (nxagentReconnectTrap) { - /* - * Only for PRIMARY and CLIPBOARD selections. - */ - - for (int i = 0; i < nxagentMaxSelections; i++) + if (nxagentOption(Clipboard) == ClipboardServer || + nxagentOption(Clipboard) == ClipboardBoth) { - /* - * if we have a selection inform the (new) real Xserver and - * claim the ownership. Note that we report our serverWindow as - * owner, not the real window! - */ - if (lastSelectionOwner[i].client && lastSelectionOwner[i].window) + for (int i = 0; i < nxagentMaxSelections; i++) { - XSetSelectionOwner(nxagentDisplay, lastSelectionOwner[i].selection, serverWindow, CurrentTime); + /* + * if we have a selection inform the (new) real Xserver and + * claim the ownership. Note that we report our serverWindow as + * owner, not the real window! + */ + if (lastSelectionOwner[i].client && lastSelectionOwner[i].window) + { + XSetSelectionOwner(nxagentDisplay, lastSelectionOwner[i].selection, serverWindow, CurrentTime); + } } } + /* FIXME: Shouldn't we reset lastServer* and lastClient* here? */ } else { |