diff options
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
-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 { |