From d210c584c7505276e04018f206de5c0109f6ff63 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 16 Dec 2019 23:11:13 +0100 Subject: Clipboard.c: rename variables/atoms to better reflect their meaning Unfortunately we cannot rename NX_CUT_BUFFER_SERVER, too, without breaking compatibility because this one is used to signal nomachine's nxclient after the splash screen is gone (see Splash.c, Window.c and ArticaProject/nx-libs#838) --- nx-X11/programs/Xserver/hw/nxagent/Atoms.c | 5 +- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 68 +++++++++++++------------- nx-X11/programs/Xserver/hw/nxagent/Clipboard.h | 2 +- nx-X11/programs/Xserver/hw/nxagent/Splash.c | 4 +- nx-X11/programs/Xserver/hw/nxagent/Window.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Windows.h | 2 +- 6 files changed, 43 insertions(+), 40 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index d9775b720..4e9b7fb1f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -81,6 +81,9 @@ static char *nxagentAtomNames[NXAGENT_NUMBER_OF_ATOMS + 1] = "WM_NX_READY", /* 3 */ "MCOPGLOBALS", /* 4 */ "NX_CUT_BUFFER_SERVER", /* 5 */ + /* Unfortunately we cannot rename this to NX_SELTRANS_TO_AGENT + because nomachine's nxclient is depending on this + selection */ "TARGETS", /* 6 */ "TEXT", /* 7 */ "NX_AGENT_SIGNATURE", /* 8 */ @@ -90,7 +93,7 @@ static char *nxagentAtomNames[NXAGENT_NUMBER_OF_ATOMS + 1] = "UTF8_STRING", /* 12 */ "_NET_WM_STATE", /* 13 */ "_NET_WM_STATE_FULLSCREEN", /* 14 */ - "NX_CUT_BUFFER_CLIENT", /* 15 */ + "NX_SELTRANS_FROM_AGENT", /* 15 */ "COMPOUND_TEXT", /* 16 */ NULL, NULL diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index db5bfd65f..d488e92a9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -72,7 +72,7 @@ static int agentClipboardInitialized = False; static int clientAccum; #endif -XlibAtom serverCutProperty; +XlibAtom serverTransToAgentProperty; Atom clientCutProperty; static Window serverWindow; @@ -137,7 +137,7 @@ static XlibAtom serverTIMESTAMP; static XlibAtom serverTEXT; static XlibAtom serverCOMPOUND_TEXT; static XlibAtom serverUTF8_STRING; -static XlibAtom serverClientCutProperty; +static XlibAtom serverTransFromAgentProperty; static Atom clientTARGETS; static Atom clientTIMESTAMP; static Atom clientTEXT; @@ -365,10 +365,10 @@ void nxagentPrintClipboardStat(char *header) fprintf(stderr, " serverCOMPOUND_TEXT [% d][%s]\n", serverCOMPOUND_TEXT, s); SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverUTF8_STRING); fprintf(stderr, " serverUTF8_STRING [% 4d][%s]\n", serverUTF8_STRING, s); - SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverCutProperty); - fprintf(stderr, " serverCutProperty [% 4d][%s]\n", serverCutProperty, s); - SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverClientCutProperty); - fprintf(stderr, " serverClientCutProperty [% 4d][%s]\n", serverClientCutProperty, s); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTransToAgentProperty); + fprintf(stderr, " serverTransToAgentProperty [% 4d][%s]\n", serverTransFromAgentProperty, s); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTransFromAgentProperty); + fprintf(stderr, " serverTransFromAgentProperty [% 4d][%s]\n", serverTransToAgentProperty, s); SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTIMESTAMP); fprintf(stderr, " serverTIMESTAMP [% 4d][%s]\n", serverTIMESTAMP, s); @@ -896,11 +896,11 @@ void nxagentRequestSelection(XEvent *X) { /* * Request the real X server to transfer the selection content - * to the NX_CUT_BUFFER_CLIENT property of the serverWindow. + * to the NX_CUT_BUFFER_SERVER property of the serverWindow. * FIXME: document how we can end up here */ XConvertSelection(nxagentDisplay, CurrentSelections[i].selection, - X->xselectionrequest.target, serverCutProperty, + X->xselectionrequest.target, serverTransToAgentProperty, serverWindow, lastClientTime); #ifdef DEBUG @@ -1057,7 +1057,7 @@ void nxagentTransferSelection(int resource) result = NXCollectProperty(nxagentDisplay, nxagentLastClipboardClient, serverWindow, - serverCutProperty, + serverTransToAgentProperty, 0, 0, False, @@ -1111,7 +1111,7 @@ void nxagentTransferSelection(int resource) result = NXCollectProperty(nxagentDisplay, nxagentLastClipboardClient, serverWindow, - serverCutProperty, + serverTransToAgentProperty, 0, lastClientPropertySize, False, @@ -1323,11 +1323,11 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) * We reach here after a paste inside the nxagent, triggered by * the XConvertSelection call in nxagentConvertSelection(). This * means that data we need has been transferred to the - * serverCutProperty of the serverWindow (our window on the real X + * serverTransToAgentProperty of the serverWindow (our window on the real X * server). We now need to transfer it to the original requestor, * which is stored in the lastClient* variables. */ - if ((lastClientStage == SelectionStageNone) && (X->xselection.property == serverCutProperty)) + if ((lastClientStage == SelectionStageNone) && (X->xselection.property == serverTransToAgentProperty)) { #ifdef DEBUG fprintf(stderr, "%s: Starting selection transferral for client [%d].\n", __func__, @@ -1368,7 +1368,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) /* if the last owner was an internal one */ if (IS_INTERNAL_OWNER(i) && lastSelectionOwner[i].windowPtr != NULL && - X->xselection.property == serverClientCutProperty) + X->xselection.property == serverTransFromAgentProperty) { Atom atomReturnType; int resultFormat; @@ -1902,7 +1902,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, SetClientSelectionStage(None); /* * store the original requestor, we need that later after - * serverCutProperty contains the desired selection content + * serverTransToAgentProperty contains the desired selection content */ lastClientRequestor = requestor; lastClientClientPtr = client; @@ -1927,20 +1927,20 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, if (target == clientUTF8_STRING) { #ifdef DEBUG - fprintf(stderr, "%s: Sending XConvertSelection with target [%d][UTF8_STRING], property [%d][NX_CUT_BUFFER_SERVER]\n", __func__, - serverUTF8_STRING, serverCutProperty); + fprintf(stderr, "%s: Sending XConvertSelection with target [%d][%s], property [%d][%s]\n", __func__, + serverUTF8_STRING, szAgentUTF8_STRING, serverTransToAgentProperty, "NX_CUT_BUFFER_SERVER"); #endif - XConvertSelection(nxagentDisplay, selection, serverUTF8_STRING, serverCutProperty, + XConvertSelection(nxagentDisplay, selection, serverUTF8_STRING, serverTransToAgentProperty, serverWindow, CurrentTime); } else { #ifdef DEBUG - fprintf(stderr, "%s: Sending XConvertSelection with target [%d][%s], property [%d][NX_CUT_BUFFER_SERVER]\n", __func__, - XA_STRING, validateString(NameForAtom(XA_STRING)), serverCutProperty); + fprintf(stderr, "%s: Sending XConvertSelection with target [%d][%s], property [%d][%s]\n", __func__, + XA_STRING, validateString(NameForAtom(XA_STRING)), serverTransToAgentProperty, "NX_CUT_BUFFER_SERVER"); #endif - XConvertSelection(nxagentDisplay, selection, XA_STRING, serverCutProperty, + XConvertSelection(nxagentDisplay, selection, XA_STRING, serverTransToAgentProperty, serverWindow, CurrentTime); } @@ -2028,18 +2028,18 @@ int nxagentSendNotify(xEvent *event) * * .property must be a server-side Atom. As this property is only * set on our serverWindow and normally there are few other - * properties except serverCutProperty, the only thing we need to - * ensure is that the internal Atom clientCutProperty differs - * from the server-side serverCutProperty Atom. The actual name is - * not important. To be clean here we use a separate - * serverClientCutProperty. + * properties except serverTransToAgentProperty, the only thing + * we need to ensure is that the internal Atom clientCutProperty + * differs from the server-side serverTransToAgentProperty + * Atom. The actual name is not important. To be clean here we use + * a separate serverTransFromAgentProperty. */ XSelectionEvent eventSelection = { .requestor = serverWindow, .selection = event->u.selectionNotify.selection, .target = event->u.selectionNotify.target, - .property = serverClientCutProperty, + .property = serverTransFromAgentProperty, .time = CurrentTime, }; @@ -2172,24 +2172,24 @@ Bool nxagentInitClipboard(WindowPtr pWin) * Server side properties to hold pasted data. * see nxagentSendNotify for an explanation */ - serverClientCutProperty = nxagentAtoms[15]; /* NX_CUT_BUFFER_CLIENT */ - serverCutProperty = nxagentAtoms[5]; /* NX_CUT_BUFFER_SERVER */ + serverTransFromAgentProperty = nxagentAtoms[15]; /* NX_SELTRANS_FROM_AGENT */ + serverTransToAgentProperty = nxagentAtoms[5]; /* NX_CUT_BUFFER_SERVER */ - if (serverCutProperty == None) + if (serverTransToAgentProperty == None) { #ifdef PANIC - fprintf(stderr, "%s: PANIC! Could not create NX_CUT_BUFFER_SERVER atom\n", __func__); + fprintf(stderr, "%s: PANIC! Could not create %s atom\n", __func__, "NX_CUT_BUFFER_SERVER"); #endif return False; } #ifdef TEST - fprintf(stderr, "%s: Setting owner of selection [%s][%d] on window 0x%x\n", __func__, - "NX_CUT_BUFFER_SERVER", (int) serverCutProperty, serverWindow); + fprintf(stderr, "%s: Setting owner of selection [%d][%s] on window 0x%x\n", __func__, + (int) serverTransToAgentProperty, "NX_CUT_BUFFER_SERVER", serverWindow); #endif - XSetSelectionOwner(nxagentDisplay, serverCutProperty, serverWindow, CurrentTime); + XSetSelectionOwner(nxagentDisplay, serverTransToAgentProperty, serverWindow, CurrentTime); if (XQueryExtension(nxagentDisplay, "XFIXES", @@ -2285,7 +2285,7 @@ Bool nxagentInitClipboard(WindowPtr pWin) { #ifdef PANIC fprintf(stderr, "%s: PANIC! " - "Could not create NX_CUT_BUFFER_CLIENT atom.\n", __func__); + "Could not create %s atom.\n", __func__, szAgentNX_CUT_BUFFER_CLIENT); #endif return False; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h index 6df5a3134..a7d22ab97 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h @@ -41,7 +41,7 @@ typedef struct _XFixesAgentInfo extern XFixesAgentInfoRec nxagentXFixesInfo; /* - * Create the NX_CUT_BUFFER_CLIENT atom and + * Create the NX_SELTRANS_FROM_AGENT atom and * initialize the required property to exchange * data with the X server. */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index 058269a73..323155299 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -412,10 +412,10 @@ void nxagentRemoveSplashWindow(void) #ifdef TEST fprintf(stderr, "%s: setting the ownership of %s (%d) on window 0x%lx\n", __func__ - "NX_CUT_BUFFER_SERVER", (int)serverCutProperty, nxagentWindow(screenInfo.screens[0]->root)); + "NX_CUT_BUFFER_SERVER", (int)serverTransToAgentProperty, nxagentWindow(screenInfo.screens[0]->root)); #endif - XSetSelectionOwner(nxagentDisplay, serverCutProperty, + XSetSelectionOwner(nxagentDisplay, serverTransToAgentProperty, nxagentWindow(screenInfo.screens[0]->root), CurrentTime); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 0d36c7960..40af9c60e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -2602,7 +2602,7 @@ void nxagentMapDefaultWindows(void) * to notify of the agent start. */ - XSetSelectionOwner(nxagentDisplay, serverCutProperty, + XSetSelectionOwner(nxagentDisplay, serverTransToAgentProperty, nxagentDefaultWindows[i], CurrentTime); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Windows.h b/nx-X11/programs/Xserver/hw/nxagent/Windows.h index c742577f5..aa4629b47 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Windows.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Windows.h @@ -178,7 +178,7 @@ do\ WindowPtr nxagentWindowPtr(Window window); #ifdef XlibAtom -extern XlibAtom serverCutProperty; +extern XlibAtom serverTransToAgentProperty; #endif /* -- cgit v1.2.3