Commit 20120205 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

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.
parent 8500b4bc
......@@ -2127,6 +2127,8 @@ Bool nxagentInitClipboard(WindowPtr pWin)
fprintf(stderr, "%s: Got called.\n", __func__);
#endif
if (!nxagentReconnectTrap)
{
SAFE_free(lastSelectionOwner);
lastSelectionOwner = (SelectionOwner *) malloc(nxagentMaxSelections * sizeof(SelectionOwner));
......@@ -2135,10 +2137,15 @@ Bool nxagentInitClipboard(WindowPtr pWin)
{
FatalError("nxagentInitClipboard: Failed to allocate memory for the clipboard selections.\n");
}
nxagentInitSelectionOwner(nxagentPrimarySelection, XA_PRIMARY);
nxagentInitSelectionOwner(nxagentClipboardSelection, nxagentAtoms[10]); /* CLIPBOARD */
}
else
{
/* the clipboard selection atom might have changed on the new X
server. Primary is constant. */
lastSelectionOwner[nxagentClipboardSelection].selection = nxagentAtoms[10]; /* CLIPBOARD */
}
#ifdef NXAGENT_TIMESTAMP
{
......@@ -2229,10 +2236,9 @@ Bool nxagentInitClipboard(WindowPtr pWin)
if (nxagentReconnectTrap)
{
/*
* Only for PRIMARY and CLIPBOARD selections.
*/
if (nxagentOption(Clipboard) == ClipboardServer ||
nxagentOption(Clipboard) == ClipboardBoth)
{
for (int i = 0; i < nxagentMaxSelections; i++)
{
/*
......@@ -2246,6 +2252,8 @@ Bool nxagentInitClipboard(WindowPtr pWin)
}
}
}
/* FIXME: Shouldn't we reset lastServer* and lastClient* here? */
}
else
{
nxagentClearSelectionOwner(nxagentPrimarySelection);
......
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