From 59ee58ee79d948223e74c2a8a745565da95c64aa Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 13 Oct 2020 00:14:49 +0200 Subject: Clipboard.c: drop clientCLIPBOARD read the value from the intSelAtoms array instead --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'nx-X11/programs/Xserver') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index a92573f9d..3d33cb931 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -152,7 +152,6 @@ static Atom clientTIMESTAMP; static Atom clientTEXT; static Atom clientCOMPOUND_TEXT; static Atom clientUTF8_STRING; -static Atom clientCLIPBOARD; static char szAgentTARGETS[] = "TARGETS"; static char szAgentTEXT[] = "TEXT"; @@ -1792,8 +1791,8 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, if (pCurSel->pWin != NULL && nxagentOption(Clipboard) != ClipboardNone && /* FIXME: shouldn't we also check for != ClipboardClient? */ - (pCurSel->selection == XA_PRIMARY || - pCurSel->selection == clientCLIPBOARD)) + (pCurSel->selection == intSelAtoms[nxagentPrimarySelection] || + pCurSel->selection == intSelAtoms[nxagentClipboardSelection])) { #ifdef DEBUG fprintf(stderr, "%s: calling setSelectionOwnerOnXServer\n", __func__); @@ -2181,20 +2180,22 @@ XlibAtom translateLocalToRemoteSelection(Atom local) * XInternAtom(nxagentDisplay, "CLIPBOARD", 1), which is stored in * remSelAtoms[nxagentClipboardSelection]. For * PRIMARY there's nothing to map because that is identical on all - * X servers (defined in Xatom.h). + * X servers (defined in Xatom.h). We do it anyway so we do not + * require a special treatment. */ - XlibAtom remote; + XlibAtom remote = -1; - if (local == XA_PRIMARY) - { - remote = XA_PRIMARY; - } - else if (local == clientCLIPBOARD) + for (int index = 0; index < nxagentMaxSelections; index++) { - remote = remSelAtoms[nxagentClipboardSelection]; + if (local == intSelAtoms[index]) + { + remote = remSelAtoms[index]; + break; + } } - else + + if (remote == -1) { remote = nxagentLocalToRemoteAtom(local); } @@ -2396,7 +2397,6 @@ Bool nxagentInitClipboard(WindowPtr pWin) { /* cannot move that down to others - we need it for * initSelectionOwnerData ! */ - clientCLIPBOARD = MakeAtom(szAgentCLIPBOARD, strlen(szAgentCLIPBOARD), True); clientTARGETS = MakeAtom(szAgentTARGETS, strlen(szAgentTARGETS), True); clientTEXT = MakeAtom(szAgentTEXT, strlen(szAgentTEXT), True); clientCOMPOUND_TEXT = MakeAtom(szAgentCOMPOUND_TEXT, strlen(szAgentCOMPOUND_TEXT), True); @@ -2434,7 +2434,7 @@ Bool nxagentInitClipboard(WindowPtr pWin) FatalError("nxagentInitClipboard: Failed to allocate memory for the internal selection Atoms array.\n"); } intSelAtoms[nxagentPrimarySelection] = XA_PRIMARY; - intSelAtoms[nxagentClipboardSelection] = clientCLIPBOARD; + intSelAtoms[nxagentClipboardSelection] = MakeAtom(szAgentCLIPBOARD, strlen(szAgentCLIPBOARD), True); SAFE_free(remSelAtoms); remSelAtoms = (XlibAtom *) calloc(nxagentMaxSelections, sizeof(XlibAtom)); -- cgit v1.2.3