From 8baec5d70bd686f1e6398016de88705e9bdda415 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 6 Jun 2018 00:32:38 +0200 Subject: Clipboard: print requested target in debugging mode --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 38 +++++++++++++++++++++----- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 703a491b6..5c8264893 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -168,15 +168,39 @@ int GetWindowProperty(WindowPtr pWin, Atom property, long longOffset, long longL Bool nxagentValidServerTargets(Atom target) { - #ifdef DEBUG - fprintf(stderr, "nxagentValidServerTargets: Got called.\n"); - #endif - - if (target == XA_STRING) return True; - if (target == serverTEXT) return True; + if (target == XA_STRING) + { + #ifdef DEBUG + fprintf(stderr, "%s: valid target [XA_STRING].\n", __func__); + #endif + return True; + } + else if (target == serverTEXT) + { + #ifdef DEBUG + fprintf(stderr, "%s: valid target [TEXT].\n", __func__); + #endif + return True; + } /* by dimbor */ - if (target == serverUTF8_STRING) return True; + else if (target == serverUTF8_STRING) + { + #ifdef DEBUG + fprintf(stderr, "%s: valid target [UTF8_STRING].\n", __func__); + #endif + return True; + } + else if (target == serverTARGETS) + { + #ifdef DEBUG + fprintf(stderr, "%s: special target [TARGETS].\n", __func__); + #endif + return False; + } + #ifdef DEBUG + fprintf(stderr, "%s: invalid target [%ld].\n", __func__, target); + #endif return False; } -- cgit v1.2.3 From 6cdddadf9f9699d91c4ef647fa9302f557ade6e1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 7 Jun 2018 23:40:51 +0200 Subject: Clipboard.c: add function for debugging output --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 116 ++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 2 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 5c8264893..3c46ec34c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -157,6 +157,109 @@ void nxagentNotifyConvertFailure(ClientPtr client, Window requestor, Atom selection, Atom target, Time time); int nxagentSendNotify(xEvent *event); +void nxagentPrintClipboardStat(char *); + +void nxagentPrintClipboardStat(char *header) +{ + #ifdef DEBUG + char *s =NULL; + + fprintf(stderr, "/----- Clipboard internal status - %s -----\n", header); + + fprintf(stderr, " current time (Time) [%u]\n", GetTimeInMillis()); + fprintf(stderr, " agentClipboardStatus (int) [%d]\n", agentClipboardStatus); + fprintf(stderr, " clientAccum (int) [%d]\n", clientAccum); + fprintf(stderr, " nxagentMaxSelections (int) [%d]\n", nxagentMaxSelections); + fprintf(stderr, " NumCurrentSelections (int) [%d]\n", NumCurrentSelections); + fprintf(stderr, " serverWindow (Window) [0x%x]\n", serverWindow); + fprintf(stderr, " nxagentLastClipboardClient (int) [%d]\n", nxagentLastClipboardClient); + + fprintf(stderr, " ClipboardMode "); + switch(nxagentOption(Clipboard)) + { + case ClipboardBoth: fprintf(stderr, "[Both]"); break;; + case ClipboardClient: fprintf(stderr, "[Client]"); break;; + case ClipboardServer: fprintf(stderr, "[Server]"); break;; + case ClipboardNone: fprintf(stderr, "[None]"); break;; + default: fprintf(stderr, "[UNKNOWN] (FAIL!)"); break;; + } + fprintf(stderr,"\n"); + + fprintf(stderr, "lastServer\n"); + fprintf(stderr, " lastServerRequestor (Window) [0x%x]\n", lastServerRequestor); + if (s) XFree(s); s = XGetAtomName(nxagentDisplay, lastServerProperty); + fprintf(stderr, " lastServerProperty (Atom) [% 4d][%s]\n", lastServerProperty, s); + if (s) XFree(s); s = XGetAtomName(nxagentDisplay, lastServerTarget); + fprintf(stderr, " lastServerTarget (Atom) [% 4d][%s]\n", lastServerTarget, s); + fprintf(stderr, " lastServerTime (Time) [%u]\n", lastServerTime); + + fprintf(stderr, "lastClient\n"); + fprintf(stderr, " lastClientWindowPtr (WindowPtr) [%p]\n", (void *)lastClientWindowPtr); + fprintf(stderr, " lastClientClientPtr (ClientPtr) [%p]\n", (void *)lastClientClientPtr); + fprintf(stderr, " lastClientRequestor (Window) [0x%x]\n", lastClientRequestor); + fprintf(stderr, " lastClientProperty (Atom) [% 4d][%s]\n", lastClientProperty, NameForAtom(lastClientProperty)); + fprintf(stderr, " lastClientSelection (Atom) [% 4d][%s]\n", lastClientSelection, NameForAtom(lastClientSelection)); + fprintf(stderr, " lastClientTarget (Atom) [% 4d][%s]\n", lastClientTarget, NameForAtom(lastClientTarget)); + fprintf(stderr, " lastClientTime (Time) [%u]\n", lastServerTime); + fprintf(stderr, " lastClientReqTime (Time) [%u]\n", lastServerTime); + fprintf(stderr, " lastClientPropertySize (unsigned long) [%lu]\n", lastClientPropertySize); + fprintf(stderr, " lastClientStage (ClientSelectionStage) [%d]", lastClientStage); + switch(lastClientStage) + { + case SelectionStageNone: fprintf(stderr, "[None]"); break;; + case SelectionStageQuerySize: fprintf(stderr, "[QuerySize]"); break;; + case SelectionStageWaitSize: fprintf(stderr, "[WaitSize]"); break;; + case SelectionStageQueryData: fprintf(stderr, "[QueryData]"); break;; + case SelectionStageWaitData: fprintf(stderr, "[WaitData]"); break;; + default: fprintf(stderr, "[UNKNOWN] (FAIL!)"); break;; + } + fprintf(stderr,"\n"); + + fprintf(stderr, "PRIMARY\n"); + fprintf(stderr, " lastSelectionOwner[].client [%p]\n", (void *)lastSelectionOwner[nxagentPrimarySelection].client); + fprintf(stderr, " lastSelectionOwner[].window [0x%x]\n", lastSelectionOwner[nxagentPrimarySelection].window); + fprintf(stderr, " lastSelectionOwner[].windowPtr [%p]\n", (void *)lastSelectionOwner[nxagentPrimarySelection].windowPtr); + fprintf(stderr, " lastSelectionOwner[].lastTimeChanged [%u]\n", lastSelectionOwner[nxagentPrimarySelection].lastTimeChanged); + fprintf(stderr, " CurrentSelections[].client [%p]\n", (void *)CurrentSelections[nxagentPrimarySelection].client); + fprintf(stderr, " CurrentSelections[].window [0x%x]\n", CurrentSelections[nxagentPrimarySelection].window); + + fprintf(stderr, "CLIPBOARD\n"); + fprintf(stderr, " lastSelectionOwner[].client [%p]\n", (void *)lastSelectionOwner[nxagentClipboardSelection].client); + fprintf(stderr, " lastSelectionOwner[].window [0x%x]\n", lastSelectionOwner[nxagentClipboardSelection].window); + fprintf(stderr, " lastSelectionOwner[].windowPtr [%p]\n", (void *)lastSelectionOwner[nxagentClipboardSelection].windowPtr); + fprintf(stderr, " lastSelectionOwner[].lastTimeChanged [%u]\n", lastSelectionOwner[nxagentClipboardSelection].lastTimeChanged); + fprintf(stderr, " CurrentSelections[].client [%p]\n", (void *)CurrentSelections[nxagentClipboardSelection].client); + fprintf(stderr, " CurrentSelections[].window [0x%x]\n", CurrentSelections[nxagentClipboardSelection].window); + + fprintf(stderr, "Atoms (server side)\n"); + if (s) XFree(s); s = XGetAtomName(nxagentDisplay, serverTARGETS); + fprintf(stderr, " serverTARGETS [% 4d][%s]\n", serverTARGETS, validateString(s)); + if (s) XFree(s); s = XGetAtomName(nxagentDisplay, serverTEXT); + fprintf(stderr, " serverTEXT [% d][%s]\n", serverTEXT, s); + if (s) XFree(s); s = XGetAtomName(nxagentDisplay, serverUTF8_STRING); + fprintf(stderr, " serverUTF8_STRING [% 4d][%s]\n", serverUTF8_STRING, s); + if (s) XFree(s); s = XGetAtomName(nxagentDisplay, serverCutProperty); + fprintf(stderr, " serverCutProperty [% 4d][%s]\n", serverCutProperty, s); + + if (s) XFree(s); s = XGetAtomName(nxagentDisplay, nxagentClipboardAtom); + fprintf(stderr, " nxagentClipboardAtom [% 4d][%s]\n", nxagentClipboardAtom, s); + if (s) XFree(s); s = XGetAtomName(nxagentDisplay, nxagentTimestampAtom); + fprintf(stderr, " nxagentTimestampAtom [% 4d][%s]\n", nxagentTimestampAtom, s); + + fprintf(stderr, "Atoms (inside nxagent)\n"); + fprintf(stderr, " clientTARGETS [% 4d][%s]\n", clientTARGETS, NameForAtom(clientTARGETS)); + fprintf(stderr, " clientTEXT [% 4d][%s]\n", clientTEXT, NameForAtom(clientTEXT)); + fprintf(stderr, " clientCOMPOUND_TEXT [% 4d][%s]\n", clientCOMPOUND_TEXT, NameForAtom(clientCOMPOUND_TEXT)); + fprintf(stderr, " clientUTF8_STRING [% 4d][%s]\n", clientUTF8_STRING, NameForAtom(clientUTF8_STRING)); + fprintf(stderr, " clientCutProperty [% 4d][%s]\n", clientCutProperty, NameForAtom(clientCutProperty)); + fprintf(stderr, " nxagentLastRequestedSelection [% 4d][%s]\n", nxagentLastRequestedSelection, NameForAtom(nxagentLastRequestedSelection)); + + fprintf(stderr, "\\------------------------------------------------------------------------------\n"); + + if (s) XFree(s); s = NULL; +#endif +} + /* * This is from NXproperty.c. */ @@ -213,6 +316,8 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) (void *) pClient, (void *) pWindow); #endif + nxagentPrintClipboardStat("before nxagentClearClipboard"); + /* * Only for PRIMARY and CLIPBOARD selections. */ @@ -238,13 +343,14 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) lastServerRequestor = None; } } - + if (pWindow == lastClientWindowPtr) { lastClientWindowPtr = NULL; lastClientStage = SelectionStageNone; } + nxagentPrintClipboardStat("after nxagentClearClipboard"); } void nxagentClearSelection(XEvent *X) @@ -255,6 +361,8 @@ void nxagentClearSelection(XEvent *X) fprintf(stderr, "nxagentClearSelection: Got called.\n"); #endif + nxagentPrintClipboardStat("before nxagentClearSelection"); + if (agentClipboardStatus != 1 || nxagentOption(Clipboard) == ClipboardServer) { @@ -297,6 +405,7 @@ void nxagentClearSelection(XEvent *X) lastClientWindowPtr = NULL; lastClientStage = SelectionStageNone; + nxagentPrintClipboardStat("after nxagentClearSelection"); } void nxagentRequestSelection(XEvent *X) @@ -305,12 +414,14 @@ void nxagentRequestSelection(XEvent *X) int result; #endif int i = 0; - XSelectionEvent eventSelection; + XSelectionEvent eventSelection = {0}; #ifdef DEBUG fprintf(stderr, "nxagentRequestSelection: Got called.\n"); #endif + nxagentPrintClipboardStat("before nxagentRequestSelection"); + if (agentClipboardStatus != 1) { return; @@ -517,6 +628,7 @@ FIXME: Do we need this? } } } + nxagentPrintClipboardStat("after nxagentRequestSelection"); } void nxagentSendSelectionNotify(Atom property) -- cgit v1.2.3 From 35f6b32c6358b25bf2255839a3b94d326e21528f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 9 Jun 2018 15:02:32 +0200 Subject: NXproperty.c:add debug output --- nx-X11/programs/Xserver/hw/nxagent/NXproperty.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c b/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c index 6292b3508..9d8a46c4f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXproperty.c @@ -88,6 +88,11 @@ typedef struct nxagentWMStateRec; #endif +#define PANIC +#define WARNING +#undef TEST +#undef DEBUG + int ProcChangeProperty(ClientPtr client) { @@ -563,15 +568,25 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, unsigned long n, len, ind; if (!pWin) + { +#ifdef DEBUG + fprintf(stderr, "%s: invalid window\n", __func__); +#endif return BadWindow; - + } if (!ValidAtom(property)) { +#ifdef DEBUG + fprintf(stderr, "%s: invalid atom [%d]\n", __func__, property); +#endif return(BadAtom); } if ((type != AnyPropertyType) && !ValidAtom(type)) { +#ifdef DEBUG + fprintf(stderr, "%s: invalid type [%d]\n", __func__, type); +#endif return(BadAtom); } @@ -588,7 +603,12 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, if (!pProp) + { +#ifdef DEBUG + fprintf(stderr, "%s: property not found [%d]\n", __func__, property); +#endif return (BadAtom); + } /* If the request type and actual type don't match. Return the property information, but not the data. */ @@ -615,6 +635,9 @@ GetWindowProperty(pWin, property, longOffset, longLength, delete, if (n < ind) { +#ifdef DEBUG + fprintf(stderr, "%s: negative property len\n", __func__); +#endif return BadValue; } -- cgit v1.2.3 From fab6911bde09b5dc7dfe43269f97f5ddd5ecced5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 9 Oct 2018 22:51:55 +0200 Subject: Clipboard.c: introduce helper macros for easier debugging --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 107 ++++++++++++++----------- 1 file changed, 59 insertions(+), 48 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 3c46ec34c..0b78c2f05 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -139,6 +139,30 @@ static char szAgentCOMPOUND_TEXT[] = "COMPOUND_TEXT"; static char szAgentUTF8_STRING[] = "UTF8_STRING"; static char szAgentNX_CUT_BUFFER_CLIENT[] = "NX_CUT_BUFFER_CLIENT"; +/* + * some helpers for debugging output + */ + +#ifdef DEBUG +const char * GetClientSelectionStageString(int stage) +{ + switch(stage) + { + case SelectionStageNone: return("None"); break;; + case SelectionStageQuerySize: return("QuerySize"); break;; + case SelectionStageWaitSize: return("WaitSize"); break;; + case SelectionStageQueryData: return("QueryData"); break;; + case SelectionStageWaitData: return("WaitData"); break;; + default: return("UNKNOWN!"); break;; + } +} +#define SetClientSelectionStage(stage) do {fprintf(stderr, "%s: Changing selection stage from [%s] to [%s]\n", __func__, GetClientSelectionStageString(lastClientStage), GetClientSelectionStageString(SelectionStage##stage)); lastClientStage = SelectionStage##stage;} while (0) +#define PrintClientSelectionStage() do {fprintf(stderr, "%s: Current selection stage [%s]\n", __func__, GetClientSelectionStageString(lastClientStage));} while (0) +#else +#define SetClientSelectionStage(stage) do {lastClientStage = SelectionStage##stage;} while (0) +#define PrintClientSelectionStage() +#endif + /* * Save the values queried from X server. */ @@ -203,17 +227,7 @@ void nxagentPrintClipboardStat(char *header) fprintf(stderr, " lastClientTime (Time) [%u]\n", lastServerTime); fprintf(stderr, " lastClientReqTime (Time) [%u]\n", lastServerTime); fprintf(stderr, " lastClientPropertySize (unsigned long) [%lu]\n", lastClientPropertySize); - fprintf(stderr, " lastClientStage (ClientSelectionStage) [%d]", lastClientStage); - switch(lastClientStage) - { - case SelectionStageNone: fprintf(stderr, "[None]"); break;; - case SelectionStageQuerySize: fprintf(stderr, "[QuerySize]"); break;; - case SelectionStageWaitSize: fprintf(stderr, "[WaitSize]"); break;; - case SelectionStageQueryData: fprintf(stderr, "[QueryData]"); break;; - case SelectionStageWaitData: fprintf(stderr, "[WaitData]"); break;; - default: fprintf(stderr, "[UNKNOWN] (FAIL!)"); break;; - } - fprintf(stderr,"\n"); + fprintf(stderr, " lastClientStage (ClientSelectionStage) [%d][%s]\n", lastClientStage, GetClientSelectionStageString(lastClientStage)); fprintf(stderr, "PRIMARY\n"); fprintf(stderr, " lastSelectionOwner[].client [%p]\n", (void *)lastSelectionOwner[nxagentPrimarySelection].client); @@ -338,7 +352,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) lastSelectionOwner[i].lastTimeChanged = GetTimeInMillis(); lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); lastServerRequestor = None; } @@ -347,7 +361,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) if (pWindow == lastClientWindowPtr) { lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); } nxagentPrintClipboardStat("after nxagentClearClipboard"); @@ -404,7 +418,7 @@ void nxagentClearSelection(XEvent *X) } lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); nxagentPrintClipboardStat("after nxagentClearSelection"); } @@ -600,7 +614,7 @@ FIXME: Do we need this? else { /* - * Probably we must to send a Notify + * Probably we must send a Notify * to requestor with property None. */ @@ -670,7 +684,7 @@ void nxagentTransferSelection(int resource) nxagentSendSelectionNotify(None); lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); return; } @@ -679,6 +693,7 @@ void nxagentTransferSelection(int resource) { case SelectionStageQuerySize: { + PrintClientSelectionStage(); /* * Don't get data yet, just get size. We skip * this stage in current implementation and @@ -717,22 +732,19 @@ void nxagentTransferSelection(int resource) nxagentSendSelectionNotify(None); lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); return; } - #ifdef DEBUG - fprintf (stderr, "nxagentTransferSelection: Setting stage to [%d] for client [%d].\n", - SelectionStageWaitSize, lastClientClientPtr -> index); - #endif - - lastClientStage = SelectionStageWaitSize; + SetClientSelectionStage(WaitSize); break; } case SelectionStageQueryData: { + PrintClientSelectionStage(); + /* * Request the selection data now. */ @@ -773,25 +785,20 @@ void nxagentTransferSelection(int resource) nxagentSendSelectionNotify(None); lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); return; } - #ifdef DEBUG - fprintf (stderr, "nxagentTransferSelection: Setting stage to [%d] for client [%d].\n", - SelectionStageWaitData, lastClientClientPtr -> index); - #endif - - lastClientStage = SelectionStageWaitData; + SetClientSelectionStage(WaitData); break; } default: { #ifdef DEBUG - fprintf (stderr, "nxagentTransferSelection: WARNING! Inconsistent state [%d] for client [%d].\n", - lastClientStage, lastClientClientPtr -> index); + fprintf (stderr, "nxagentTransferSelection: WARNING! Inconsistent state [%s] for client [%d].\n", + GetClientSelectionStageString(lastClientStage), lastClientClientPtr -> index); #endif break; @@ -834,7 +841,7 @@ void nxagentCollectPropertyEvent(int resource) nxagentSendSelectionNotify(None); lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); if (pszReturnData != NULL) { @@ -858,7 +865,7 @@ void nxagentCollectPropertyEvent(int resource) } lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); if (pszReturnData != NULL) { @@ -872,6 +879,7 @@ void nxagentCollectPropertyEvent(int resource) { case SelectionStageWaitSize: { + PrintClientSelectionStage(); #ifdef DEBUG fprintf (stderr, "nxagentCollectPropertyEvent: Got size notify event for client [%d].\n", lastClientClientPtr -> index); @@ -887,7 +895,7 @@ void nxagentCollectPropertyEvent(int resource) nxagentSendSelectionNotify(None); lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); if (pszReturnData != NULL) { @@ -906,7 +914,7 @@ void nxagentCollectPropertyEvent(int resource) */ lastClientPropertySize = ulReturnBytesLeft; - lastClientStage = SelectionStageQueryData; + SetClientSelectionStage(QueryData); nxagentTransferSelection(resource); @@ -914,6 +922,7 @@ void nxagentCollectPropertyEvent(int resource) } case SelectionStageWaitData: { + PrintClientSelectionStage(); #ifdef DEBUG fprintf (stderr, "nxagentCollectPropertyEvent: Got data notify event for client [%d].\n", lastClientClientPtr -> index); @@ -929,7 +938,7 @@ void nxagentCollectPropertyEvent(int resource) nxagentSendSelectionNotify(None); lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); if (pszReturnData != NULL) { @@ -961,15 +970,15 @@ void nxagentCollectPropertyEvent(int resource) */ lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); break; } default: { #ifdef DEBUG - fprintf (stderr, "nxagentCollectPropertyEvent: WARNING! Inconsistent state [%d] for client [%d].\n", - lastClientStage, lastClientClientPtr -> index); + fprintf (stderr, "nxagentCollectPropertyEvent: WARNING! Inconsistent state [%s] for client [%d].\n", + GetClientSelectionStageString(lastClientStage), lastClientClientPtr -> index); #endif break; @@ -999,6 +1008,8 @@ void nxagentNotifySelection(XEvent *X) fprintf(stderr, "nxagentNotifySelection: SelectionNotify event.\n"); #endif + PrintClientSelectionStage(); + if (lastClientWindowPtr != NULL) { if ((lastClientStage == SelectionStageNone) && (X->xselection.property == serverCutProperty)) @@ -1019,7 +1030,7 @@ void nxagentNotifySelection(XEvent *X) * tions. */ - lastClientStage = SelectionStageQueryData; + SetClientSelectionStage(QueryData); lastClientPropertySize = 262144; nxagentTransferSelection(lastClientClientPtr -> index); @@ -1034,7 +1045,7 @@ void nxagentNotifySelection(XEvent *X) nxagentSendSelectionNotify(None); lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); } return; @@ -1195,7 +1206,7 @@ void nxagentResetSelectionOwner(void) } lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); lastServerRequestor = None; @@ -1245,7 +1256,7 @@ void nxagentSetSelectionOwner(Selection *pSelection) } lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); lastServerRequestor = None; @@ -1262,7 +1273,7 @@ FIXME lastSelectionOwnerWindowPtr = pSelection->pWin; lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); lastServerRequestor = None; } @@ -1346,7 +1357,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, lastClientSelection, lastClientTarget, lastClientTime); lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); } else { @@ -1473,7 +1484,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, (target == clientUTF8_STRING)) { lastClientWindowPtr = pWin; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); lastClientRequestor = requestor; lastClientClientPtr = client; lastClientTime = time; @@ -1767,7 +1778,7 @@ int nxagentInitClipboard(WindowPtr pWin) lastServerRequestor = None; lastClientWindowPtr = NULL; - lastClientStage = SelectionStageNone; + SetClientSelectionStage(None); lastClientReqTime = GetTimeInMillis(); clientCutProperty = MakeAtom(szAgentNX_CUT_BUFFER_CLIENT, -- cgit v1.2.3 From 85a28a68e90537c3b82e83bd8ff07a8e116ff00a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 9 Oct 2018 23:00:08 +0200 Subject: Clipboard.c: add macro for safe XFree calls with ptr clearance --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 53 ++++++++------------------ nx-X11/programs/Xserver/hw/nxagent/Utils.h | 2 + 2 files changed, 18 insertions(+), 37 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 0b78c2f05..a9287150c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -211,9 +211,9 @@ void nxagentPrintClipboardStat(char *header) fprintf(stderr, "lastServer\n"); fprintf(stderr, " lastServerRequestor (Window) [0x%x]\n", lastServerRequestor); - if (s) XFree(s); s = XGetAtomName(nxagentDisplay, lastServerProperty); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, lastServerProperty); fprintf(stderr, " lastServerProperty (Atom) [% 4d][%s]\n", lastServerProperty, s); - if (s) XFree(s); s = XGetAtomName(nxagentDisplay, lastServerTarget); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, lastServerTarget); fprintf(stderr, " lastServerTarget (Atom) [% 4d][%s]\n", lastServerTarget, s); fprintf(stderr, " lastServerTime (Time) [%u]\n", lastServerTime); @@ -246,18 +246,18 @@ void nxagentPrintClipboardStat(char *header) fprintf(stderr, " CurrentSelections[].window [0x%x]\n", CurrentSelections[nxagentClipboardSelection].window); fprintf(stderr, "Atoms (server side)\n"); - if (s) XFree(s); s = XGetAtomName(nxagentDisplay, serverTARGETS); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTARGETS); fprintf(stderr, " serverTARGETS [% 4d][%s]\n", serverTARGETS, validateString(s)); - if (s) XFree(s); s = XGetAtomName(nxagentDisplay, serverTEXT); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTEXT); fprintf(stderr, " serverTEXT [% d][%s]\n", serverTEXT, s); - if (s) XFree(s); s = XGetAtomName(nxagentDisplay, serverUTF8_STRING); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverUTF8_STRING); fprintf(stderr, " serverUTF8_STRING [% 4d][%s]\n", serverUTF8_STRING, s); - if (s) XFree(s); s = XGetAtomName(nxagentDisplay, serverCutProperty); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverCutProperty); fprintf(stderr, " serverCutProperty [% 4d][%s]\n", serverCutProperty, s); - if (s) XFree(s); s = XGetAtomName(nxagentDisplay, nxagentClipboardAtom); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, nxagentClipboardAtom); fprintf(stderr, " nxagentClipboardAtom [% 4d][%s]\n", nxagentClipboardAtom, s); - if (s) XFree(s); s = XGetAtomName(nxagentDisplay, nxagentTimestampAtom); + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, nxagentTimestampAtom); fprintf(stderr, " nxagentTimestampAtom [% 4d][%s]\n", nxagentTimestampAtom, s); fprintf(stderr, "Atoms (inside nxagent)\n"); @@ -270,7 +270,7 @@ void nxagentPrintClipboardStat(char *header) fprintf(stderr, "\\------------------------------------------------------------------------------\n"); - if (s) XFree(s); s = NULL; + SAFE_XFree(s); #endif } @@ -460,10 +460,7 @@ FIXME: Do we need this? fprintf(stderr, "SelectionRequest event aborting sele=[%s] ext target=[%s] Atom size is [%d]\n", validateString(NameForAtom(X->xselectionrequest.selection)), strTarget, sizeof(Atom)); - if (strTarget != NULL) - { - XFree(strTarget); - } + SAFE_XFree(strTarget); */ memset(&eventSelection, 0, sizeof(XSelectionEvent)); eventSelection.property = None; @@ -843,11 +840,7 @@ void nxagentCollectPropertyEvent(int resource) lastClientWindowPtr = NULL; SetClientSelectionStage(None); - if (pszReturnData != NULL) - { - XFree(pszReturnData); - } - + SAFE_XFree(pszReturnData); return; } @@ -867,11 +860,7 @@ void nxagentCollectPropertyEvent(int resource) lastClientWindowPtr = NULL; SetClientSelectionStage(None); - if (pszReturnData != NULL) - { - XFree(pszReturnData); - } - + SAFE_XFree(pszReturnData); return; } @@ -897,11 +886,7 @@ void nxagentCollectPropertyEvent(int resource) lastClientWindowPtr = NULL; SetClientSelectionStage(None); - if (pszReturnData != NULL) - { - XFree(pszReturnData); - } - + SAFE_XFree(pszReturnData); return; } @@ -940,11 +925,7 @@ void nxagentCollectPropertyEvent(int resource) lastClientWindowPtr = NULL; SetClientSelectionStage(None); - if (pszReturnData != NULL) - { - XFree(pszReturnData); - } - + SAFE_XFree(pszReturnData); return; } @@ -985,8 +966,7 @@ void nxagentCollectPropertyEvent(int resource) } } - XFree(pszReturnData); - pszReturnData = NULL; + SAFE_XFree(pszReturnData); } void nxagentNotifySelection(XEvent *X) @@ -1122,8 +1102,7 @@ void nxagentNotifySelection(XEvent *X) } /* - * XFree(pszReturnData); - * pszReturnData=NULL; + * SAFE_XFree(pszReturnData); */ } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Utils.h b/nx-X11/programs/Xserver/hw/nxagent/Utils.h index 63904e23b..c0ad03345 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Utils.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Utils.h @@ -44,4 +44,6 @@ static inline const char * validateString(const char *str) { return str ? str : "(null)"; } +#define SAFE_XFree(what) do {if (what) {XFree(what); what = NULL;}} while (0) + #endif /* __Utils_H__ */ -- cgit v1.2.3 From e90306ec430f9baba85b35196e76b5745e5ff736 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 10 Oct 2018 00:13:57 +0200 Subject: Clipboard.c: some scope optimizations --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index a9287150c..da1378815 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -424,9 +424,6 @@ void nxagentClearSelection(XEvent *X) void nxagentRequestSelection(XEvent *X) { - #ifdef DEBUG - int result; - #endif int i = 0; XSelectionEvent eventSelection = {0}; @@ -507,7 +504,7 @@ FIXME: Do we need this? eventSelection.time = X->xselectionrequest.time; #ifdef DEBUG - result = + int result = #endif XSendEvent(nxagentDisplay, eventSelection.requestor, @@ -625,7 +622,7 @@ FIXME: Do we need this? eventSelection.time = X->xselectionrequest.time; #ifdef DEBUG - result = + int result = #endif XSendEvent(nxagentDisplay, eventSelection.requestor, @@ -971,8 +968,6 @@ void nxagentCollectPropertyEvent(int resource) void nxagentNotifySelection(XEvent *X) { - int result; - XSelectionEvent eventSelection; #ifdef DEBUG @@ -1051,9 +1046,9 @@ void nxagentNotifySelection(XEvent *X) unsigned long ulReturnBytesLeft; unsigned char *pszReturnData = NULL; - result = GetWindowProperty(lastSelectionOwner[i].windowPtr, clientCutProperty, 0, 0, False, - AnyPropertyType, &atomReturnType, &resultFormat, - &ulReturnItems, &ulReturnBytesLeft, &pszReturnData); + int result = GetWindowProperty(lastSelectionOwner[i].windowPtr, clientCutProperty, 0, 0, False, + AnyPropertyType, &atomReturnType, &resultFormat, + &ulReturnItems, &ulReturnBytesLeft, &pszReturnData); if (result == BadAlloc || result == BadAtom || result == BadMatch || result == BadValue || @@ -1400,7 +1395,6 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, if (target == MakeAtom("TIMESTAMP", 9, 1)) { - xEvent x; int i = 0; while ((i < NumCurrentSelections) && @@ -1408,6 +1402,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, if (i < NumCurrentSelections) { + xEvent x; ChangeWindowProperty(pWin, property, target, -- cgit v1.2.3 From 888de83ac9d80495cfc3bc3b29277eedd1917feb Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 10 Oct 2018 00:21:13 +0200 Subject: Clipboard.c: print X errors --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 82 +++++++++++++++++++------- 1 file changed, 62 insertions(+), 20 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index da1378815..456da35a0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -163,6 +163,35 @@ const char * GetClientSelectionStageString(int stage) #define PrintClientSelectionStage() #endif +/* + * see also nx-X11/lib/src/ErrDes.c + */ +const char * GetXErrorString(int code) +{ + switch(code) + { + case Success: return("Success"); break;; + case BadRequest: return("BadRequest"); break;; + case BadValue: return("BadValue"); break;; + case BadWindow: return("BadWindow"); break;; + case BadPixmap: return("BadPixmap"); break;; + case BadAtom: return("BadAtom"); break;; + case BadCursor: return("BadCursor"); break;; + case BadFont: return("BadFont"); break;; + case BadMatch: return("BadMatch"); break;; + case BadDrawable: return("BadDrawable"); break;; + case BadAccess: return("BadAccess"); break;; + case BadAlloc: return("BadAlloc"); break;; + case BadColor: return("BadColor"); break;; + case BadGC: return("BadGC"); break;; + case BadIDChoice: return("BadIDChoice"); break;; + case BadName: return("BadName"); break;; + case BadLength: return("BadLength"); break;; + case BadImplementation: return("BadImplementation"); break;; + default: return("UNKNOWN!"); break;; + } +} + /* * Save the values queried from X server. */ @@ -513,13 +542,14 @@ FIXME: Do we need this? (XEvent *) &eventSelection); #ifdef DEBUG + fprintf(stderr, "%s: XSendEvent() returned [%s]\n", __func__, GetXErrorString(result)); if (result == BadValue || result == BadWindow) { - fprintf(stderr, "nxagentRequestSelection: WARNING! XSendEvent failed.\n"); + fprintf(stderr, "%s: WARNING! XSendEvent failed.\n", __func__); } else { - fprintf(stderr, "nxagentRequestSelection: XSendEvent sent to window [0x%lx].\n", + fprintf(stderr, "%s: XSendEvent sent to window [0x%lx].\n", __func__, eventSelection.requestor); } #endif @@ -631,7 +661,16 @@ FIXME: Do we need this? (XEvent *) &eventSelection); #ifdef DEBUG - fprintf(stderr, "nxagentRequestSelection: Executed XSendEvent with property None.\n"); + fprintf(stderr, "%s: XSendEvent() returned [%s]\n", __func__, GetXErrorString(result)); + if (result == BadValue || result == BadWindow) + { + fprintf(stderr, "%s: WARNING! XSendEvent failed.\n", __func__); + } + else + { + fprintf(stderr, "%s: XSendEvent with property None sent to window [0x%lx].\n", __func__, + eventSelection.requestor); + } #endif } } @@ -1050,24 +1089,15 @@ void nxagentNotifySelection(XEvent *X) AnyPropertyType, &atomReturnType, &resultFormat, &ulReturnItems, &ulReturnBytesLeft, &pszReturnData); + #ifdef DEBUG + fprintf(stderr, "%s: GetWindowProperty() returned [%s]\n", __func__, GetXErrorString(result)); + #endif if (result == BadAlloc || result == BadAtom || result == BadMatch || result == BadValue || result == BadWindow) { - fprintf (stderr, "Client GetProperty failed error ="); + fprintf (stderr, "Client GetProperty failed. Error = %s", GetXErrorString(result)); lastServerProperty = None; - switch (result) - { - case BadAtom: - fprintf (stderr, "BadAtom\n"); - break; - case BadValue: - fprintf (stderr, "BadValue\n"); - break; - case BadWindow: - fprintf (stderr, "BadWindow\n"); - break; - } } else { @@ -1075,12 +1105,15 @@ void nxagentNotifySelection(XEvent *X) ulReturnBytesLeft, False, AnyPropertyType, &atomReturnType, &resultFormat, &ulReturnItems, &ulReturnBytesLeft, &pszReturnData); + #ifdef DEBUG + fprintf(stderr, "%s: GetWindowProperty() returned [%s]\n", __func__, GetXErrorString(result)); + #endif if (result == BadAlloc || result == BadAtom || result == BadMatch || result == BadValue || result == BadWindow) { - fprintf (stderr, "SelectionNotify - XChangeProperty failed\n"); + fprintf (stderr, "SelectionNotify - XChangeProperty failed. Error = %s\n", GetXErrorString(result)); lastServerProperty = None; } @@ -1095,6 +1128,9 @@ void nxagentNotifySelection(XEvent *X) pszReturnData, ulReturnItems); } + #ifdef DEBUG + fprintf(stderr, "%s: XChangeProperty() returned [%s]\n", __func__, GetXErrorString(result)); + #endif /* * SAFE_XFree(pszReturnData); @@ -1124,7 +1160,7 @@ void nxagentNotifySelection(XEvent *X) */ #ifdef DEBUG - fprintf(stderr, "nxagentNotifySelection: Sending event to requestor.\n"); + fprintf(stderr, "nxagentNotifySelection: Sending event to requestor [%p].\n", eventSelection.requestor); #endif result = XSendEvent(nxagentDisplay, @@ -1133,6 +1169,9 @@ void nxagentNotifySelection(XEvent *X) 0L, (XEvent *) &eventSelection); + #ifdef DEBUG + fprintf(stderr, "%s: XSendEvent() returned [%s]\n", __func__, GetXErrorString(result)); + #endif if (result == BadValue || result == BadWindow) { fprintf (stderr, "SelectionRequest - XSendEvent failed\n"); @@ -1559,15 +1598,18 @@ int nxagentSendNotify(xEvent *event) x.time = CurrentTime; #ifdef DEBUG - fprintf(stderr, "nxagentSendNotify: Propagating clientCutProperty.\n"); + fprintf(stderr, "nxagentSendNotify: Propagating clientCutProperty to requestor [%p].\n", x.requestor); #endif result = XSendEvent (nxagentDisplay, x.requestor, False, 0L, (XEvent *) &x); + #ifdef DEBUG + fprintf(stderr, "%s: XSendEvent() returned [%s]\n", __func__, GetXErrorString(result)); + #endif if (result == BadValue || result == BadWindow) { - fprintf (stderr, "nxagentSendNotify: XSendEvent failed.\n"); + fprintf (stderr, "%s: XSendEvent failed.\n", __func__); } return 1; -- cgit v1.2.3 From 9a5f519a02d63700aaa742e50ddb5ba67ca7d2b4 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 10 Oct 2018 00:21:48 +0200 Subject: Clipboard.c: Code optimization (missing else) --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 456da35a0..7c6328183 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -504,8 +504,7 @@ FIXME: Do we need this? 1); eventSelection.property = X->xselectionrequest.property; } - - if (X->xselectionrequest.target == nxagentTimestampAtom) + else if (X->xselectionrequest.target == nxagentTimestampAtom) { while ((i < NumCurrentSelections) && lastSelectionOwner[i].selection != X->xselectionrequest.selection) i++; -- cgit v1.2.3 From 719488da9656c82aeb6ded94d7d22c2a31d485b6 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 10 Oct 2018 00:22:21 +0200 Subject: Clipboard.c: add FIXME --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 1 + 1 file changed, 1 insertion(+) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 7c6328183..3650210dc 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -562,6 +562,7 @@ FIXME: Do we need this? nxagentLastRequestedSelection = X->xselectionrequest.selection; + /* FIXME: shouldn't we reset i to 0 here first? */ while ((i < nxagentMaxSelections) && (lastSelectionOwner[i].selection != X->xselectionrequest.selection)) { -- cgit v1.2.3 From 018b561b7c2861dd777da164fd6fc3c00bd79c77 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 10 Oct 2018 00:22:38 +0200 Subject: Clipboard.c: whitespace fixes --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 3650210dc..a4a44f2c2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -882,7 +882,6 @@ void nxagentCollectPropertyEvent(int resource) if (resultFormat != 8 && resultFormat != 16 && resultFormat != 32) { - #ifdef DEBUG fprintf (stderr, "nxagentCollectPropertyEvent: WARNING! Invalid property " "value.\n"); @@ -1731,7 +1730,6 @@ int nxagentInitClipboard(WindowPtr pWin) { ErrorF("Unable to initialize XFixes extension.\n"); } - else { #ifdef TEST @@ -1832,4 +1830,3 @@ int nxagentInitClipboard(WindowPtr pWin) return 1; } - -- cgit v1.2.3 From 1af67b4df234cb1a702554289d4319f904aaef31 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 10 Oct 2018 00:26:54 +0200 Subject: Clipboard.c: GetWindowProperty() does not return BadMatch --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index a4a44f2c2..9cf541e9a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -1092,8 +1092,7 @@ void nxagentNotifySelection(XEvent *X) fprintf(stderr, "%s: GetWindowProperty() returned [%s]\n", __func__, GetXErrorString(result)); #endif if (result == BadAlloc || result == BadAtom || - result == BadMatch || result == BadValue || - result == BadWindow) + result == BadWindow || result == BadValue) { fprintf (stderr, "Client GetProperty failed. Error = %s", GetXErrorString(result)); lastServerProperty = None; @@ -1109,11 +1108,9 @@ void nxagentNotifySelection(XEvent *X) #endif if (result == BadAlloc || result == BadAtom || - result == BadMatch || result == BadValue || - result == BadWindow) + result == BadWindow || result == BadValue) { fprintf (stderr, "SelectionNotify - XChangeProperty failed. Error = %s\n", GetXErrorString(result)); - lastServerProperty = None; } else -- cgit v1.2.3 From 1c4c9f60978d5ef13e10e85ec2ce18898196177b Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 10 Oct 2018 01:15:17 +0200 Subject: Clipboard.c: more debugging info for nxagentGetClipboardWindow() --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 9cf541e9a..ae73f36e5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -1619,7 +1619,7 @@ WindowPtr nxagentGetClipboardWindow(Atom property, WindowPtr pWin) int i = 0; #ifdef DEBUG - fprintf(stderr, "nxagentGetClipboardWindow: Got called.\n"); + fprintf(stderr, "%s: Got called, property [%d][%s] window [%p].\n", __func__, property, NameForAtom(property), pWin); #endif while ((i < nxagentMaxSelections) && @@ -1632,7 +1632,7 @@ WindowPtr nxagentGetClipboardWindow(Atom property, WindowPtr pWin) (lastSelectionOwner[i].windowPtr != NULL)) { #ifdef DEBUG - fprintf(stderr, "nxagentGetClipboardWindow: Returning last clipboard owner window.\n"); + fprintf(stderr, "%s: Returning last clipboard owner window [%p].\n", __func__, lastSelectionOwner[i].windowPtr); #endif return lastSelectionOwner[i].windowPtr; @@ -1640,7 +1640,7 @@ WindowPtr nxagentGetClipboardWindow(Atom property, WindowPtr pWin) else { #ifdef DEBUG - fprintf(stderr, "nxagentGetClipboardWindow: Returning original target window.\n"); + fprintf(stderr, "%s: Returning original target window [%p].\n", __func__, pWin); #endif return pWin; -- cgit v1.2.3 From 5d26addd3df578b057e9820015018d019a85296f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 16 Oct 2018 00:19:58 +0200 Subject: Clipboard.c: new debug function to reduce duplicate code --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 66 +++++++++++++++++++++----- 1 file changed, 53 insertions(+), 13 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index ae73f36e5..a7a1cbdf3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -212,6 +212,57 @@ int nxagentSendNotify(xEvent *event); void nxagentPrintClipboardStat(char *); +#ifdef DEBUG +void nxagentPrintSelectionStat(int sel) +{ + SelectionOwner lOwner = lastSelectionOwner[sel]; + Selection curSel = CurrentSelections[sel]; + char *s =NULL; + +#ifdef CLIENTIDS + fprintf(stderr, " lastSelectionOwner[].client [%p] index [%d] PID [%d] Cmd [%s]\n", + lOwner.client, + lOwner.client ? lOwner.client->index : -1, + GetClientPid(lOwner.client), + GetClientCmdName(lOwner.client)); +#else + fprintf(stderr, " lastSelectionOwner[].client [%p] index [%d]\n", + lOwner.client, + lOwner.client ? lOwner.client->index : -1); +#endif + fprintf(stderr, " lastSelectionOwner[].window [0x%x]\n", lOwner.window); + fprintf(stderr, " lastSelectionOwner[].windowPtr [%p]\n", lOwner.windowPtr); + fprintf(stderr, " lastSelectionOwner[].lastTimeChanged [%u]\n", lOwner.lastTimeChanged); + + /* + print the selection name. + */ + if (lOwner.client) + { + fprintf(stderr, " lastSelectionOwner[].selection [% 4d][%s] (local)\n", lOwner.selection, NameForAtom(lOwner.selection)); + } + else + { + SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, lOwner.selection); + fprintf(stderr, " lastSelectionOwner[].selection [% 4d][%s] (remote)\n", lOwner.selection, validateString(s)); + SAFE_XFree(s); + } +#ifdef CLIENTIDS + fprintf(stderr, " CurrentSelections[].client [%p] index [%d] PID [%d] Cmd [%s]\n", + curSel.client, + curSel.client ? curSel.client->index : -1, + GetClientPid(curSel.client), + GetClientCmdName(curSel.client)); +#else + fprintf(stderr, " CurrentSelections[].client [%p] index [%d]\n", + curSel.client, + curSel.client ? curSel.client->index : -1); +#endif + fprintf(stderr, " CurrentSelections[].window [0x%x]\n", curSel.window); + return; +} +#endif + void nxagentPrintClipboardStat(char *header) { #ifdef DEBUG @@ -259,20 +310,9 @@ void nxagentPrintClipboardStat(char *header) fprintf(stderr, " lastClientStage (ClientSelectionStage) [%d][%s]\n", lastClientStage, GetClientSelectionStageString(lastClientStage)); fprintf(stderr, "PRIMARY\n"); - fprintf(stderr, " lastSelectionOwner[].client [%p]\n", (void *)lastSelectionOwner[nxagentPrimarySelection].client); - fprintf(stderr, " lastSelectionOwner[].window [0x%x]\n", lastSelectionOwner[nxagentPrimarySelection].window); - fprintf(stderr, " lastSelectionOwner[].windowPtr [%p]\n", (void *)lastSelectionOwner[nxagentPrimarySelection].windowPtr); - fprintf(stderr, " lastSelectionOwner[].lastTimeChanged [%u]\n", lastSelectionOwner[nxagentPrimarySelection].lastTimeChanged); - fprintf(stderr, " CurrentSelections[].client [%p]\n", (void *)CurrentSelections[nxagentPrimarySelection].client); - fprintf(stderr, " CurrentSelections[].window [0x%x]\n", CurrentSelections[nxagentPrimarySelection].window); - + nxagentPrintSelectionStat(nxagentPrimarySelection); fprintf(stderr, "CLIPBOARD\n"); - fprintf(stderr, " lastSelectionOwner[].client [%p]\n", (void *)lastSelectionOwner[nxagentClipboardSelection].client); - fprintf(stderr, " lastSelectionOwner[].window [0x%x]\n", lastSelectionOwner[nxagentClipboardSelection].window); - fprintf(stderr, " lastSelectionOwner[].windowPtr [%p]\n", (void *)lastSelectionOwner[nxagentClipboardSelection].windowPtr); - fprintf(stderr, " lastSelectionOwner[].lastTimeChanged [%u]\n", lastSelectionOwner[nxagentClipboardSelection].lastTimeChanged); - fprintf(stderr, " CurrentSelections[].client [%p]\n", (void *)CurrentSelections[nxagentClipboardSelection].client); - fprintf(stderr, " CurrentSelections[].window [0x%x]\n", CurrentSelections[nxagentClipboardSelection].window); + nxagentPrintSelectionStat(nxagentClipboardSelection); fprintf(stderr, "Atoms (server side)\n"); SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTARGETS); -- cgit v1.2.3 From f8bfdc87b3ba200f5cb9dba85682a445174209ba Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 16 Oct 2018 00:20:41 +0200 Subject: Clipboard.c: improve nxagentClearSelection() debug code --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index a7a1cbdf3..a02bd1cee 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -441,7 +441,7 @@ void nxagentClearSelection(XEvent *X) int i = 0; #ifdef DEBUG - fprintf(stderr, "nxagentClearSelection: Got called.\n"); + fprintf(stderr, "%s: SelectionClear event for selection [%d].\n", __func__, X->xselectionclear.selection); #endif nxagentPrintClipboardStat("before nxagentClearSelection"); @@ -452,10 +452,6 @@ void nxagentClearSelection(XEvent *X) return; } - #ifdef DEBUG - fprintf(stderr, "nxagentClearSelection: SelectionClear event.\n"); - #endif - while ((i < nxagentMaxSelections) && (lastSelectionOwner[i].selection != X->xselectionclear.selection)) { -- cgit v1.2.3 From 934d9eae6f92a69fc4fd2fe79c7b67689902c01c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 25 Jul 2018 22:13:30 +0200 Subject: Clipboard.c: Use constant instead of hardcoded value --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index a02bd1cee..285a7380b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -1696,7 +1696,7 @@ int nxagentInitClipboard(WindowPtr pWin) free(lastSelectionOwner); lastSelectionOwner = NULL; - lastSelectionOwner = (SelectionOwner *) malloc(2 * sizeof(SelectionOwner)); + lastSelectionOwner = (SelectionOwner *) malloc(nxagentMaxSelections * sizeof(SelectionOwner)); if (lastSelectionOwner == NULL) { -- cgit v1.2.3 From 2517d8c1f9c2d4460e0ddcccc66a7f0835d2d847 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 25 Jul 2018 22:25:22 +0200 Subject: Clipboard.c: more DEBUG output --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 285a7380b..942771a84 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -1588,14 +1588,21 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, int nxagentSendNotify(xEvent *event) { #ifdef DEBUG - fprintf(stderr, "nxagentSendNotify: Got called.\n"); + fprintf(stderr, "%s: Got called.\n", __func__); #endif if (agentClipboardStatus != 1) { + #ifdef DEBUG + fprintf(stderr, "%s: agentClipboardStatus != 1 - doing nothing.\n", __func__); + #endif return 0; } + #ifdef DEBUG + fprintf(stderr, "%s: property is [%d][%s].\n", __func__, event->u.selectionNotify.property, NameForAtom(event->u.selectionNotify.property)); + #endif + if (event->u.selectionNotify.property == clientCutProperty) { XSelectionEvent x; @@ -1630,7 +1637,7 @@ int nxagentSendNotify(xEvent *event) x.time = CurrentTime; #ifdef DEBUG - fprintf(stderr, "nxagentSendNotify: Propagating clientCutProperty to requestor [%p].\n", x.requestor); + fprintf(stderr, "%s: Propagating clientCutProperty to requestor [%p].\n", __func__, x.requestor); #endif result = XSendEvent (nxagentDisplay, x.requestor, False, @@ -1646,7 +1653,9 @@ int nxagentSendNotify(xEvent *event) return 1; } - + #ifdef DEBUG + fprintf(stderr, "nxagentSendNotify: sent nothing.\n"); + #endif return 0; } -- cgit v1.2.3 From 6ea7558d17fd848284b75bc56fcd0de566c7e5c8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Oct 2018 00:29:35 +0200 Subject: Clipboard.c: fix fprintf type warnings --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 942771a84..172658639 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -221,17 +221,17 @@ void nxagentPrintSelectionStat(int sel) #ifdef CLIENTIDS fprintf(stderr, " lastSelectionOwner[].client [%p] index [%d] PID [%d] Cmd [%s]\n", - lOwner.client, + (void *)lOwner.client, lOwner.client ? lOwner.client->index : -1, GetClientPid(lOwner.client), GetClientCmdName(lOwner.client)); #else fprintf(stderr, " lastSelectionOwner[].client [%p] index [%d]\n", - lOwner.client, + (void *)lOwner.client, lOwner.client ? lOwner.client->index : -1); #endif fprintf(stderr, " lastSelectionOwner[].window [0x%x]\n", lOwner.window); - fprintf(stderr, " lastSelectionOwner[].windowPtr [%p]\n", lOwner.windowPtr); + fprintf(stderr, " lastSelectionOwner[].windowPtr [%p]\n", (void *)lOwner.windowPtr); fprintf(stderr, " lastSelectionOwner[].lastTimeChanged [%u]\n", lOwner.lastTimeChanged); /* @@ -249,13 +249,13 @@ void nxagentPrintSelectionStat(int sel) } #ifdef CLIENTIDS fprintf(stderr, " CurrentSelections[].client [%p] index [%d] PID [%d] Cmd [%s]\n", - curSel.client, + (void *)curSel.client, curSel.client ? curSel.client->index : -1, GetClientPid(curSel.client), GetClientCmdName(curSel.client)); #else fprintf(stderr, " CurrentSelections[].client [%p] index [%d]\n", - curSel.client, + (void *)curSel.client, curSel.client ? curSel.client->index : -1); #endif fprintf(stderr, " CurrentSelections[].window [0x%x]\n", curSel.window); @@ -385,7 +385,7 @@ Bool nxagentValidServerTargets(Atom target) } #ifdef DEBUG - fprintf(stderr, "%s: invalid target [%ld].\n", __func__, target); + fprintf(stderr, "%s: invalid target [%u].\n", __func__, target); #endif return False; } @@ -441,7 +441,7 @@ void nxagentClearSelection(XEvent *X) int i = 0; #ifdef DEBUG - fprintf(stderr, "%s: SelectionClear event for selection [%d].\n", __func__, X->xselectionclear.selection); + fprintf(stderr, "%s: SelectionClear event for selection [%lu].\n", __func__, X->xselectionclear.selection); #endif nxagentPrintClipboardStat("before nxagentClearSelection"); @@ -1192,7 +1192,7 @@ void nxagentNotifySelection(XEvent *X) */ #ifdef DEBUG - fprintf(stderr, "nxagentNotifySelection: Sending event to requestor [%p].\n", eventSelection.requestor); + fprintf(stderr, "%s: Sending event to requestor [%p].\n", __func__, (void *)eventSelection.requestor); #endif result = XSendEvent(nxagentDisplay, @@ -1227,7 +1227,7 @@ void nxagentResetSelectionOwner(void) if (lastServerRequestor != None) { #ifdef TEST - fprintf (stderr, "nxagentResetSelectionOwner: WARNING! Requestor window [0x%lx] already found.\n", + fprintf (stderr, "nxagentResetSelectionOwner: WARNING! Requestor window [0x%x] already found.\n", lastServerRequestor); #endif @@ -1271,14 +1271,14 @@ void nxagentSetSelectionOwner(Selection *pSelection) } #ifdef DEBUG - fprintf(stderr, "nxagentSetSelectionOwner: Setting selection owner to window [0x%lx].\n", + fprintf(stderr, "nxagentSetSelectionOwner: Setting selection owner to window [0x%x].\n", serverWindow); #endif #ifdef TEST if (lastServerRequestor != None) { - fprintf (stderr, "nxagentSetSelectionOwner: WARNING! Requestor window [0x%lx] already found.\n", + fprintf (stderr, "nxagentSetSelectionOwner: WARNING! Requestor window [0x%x] already found.\n", lastServerRequestor); } #endif @@ -1419,7 +1419,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, #ifdef TEST fprintf(stderr, "nxagentConvertSelection: client [%d] ask for sel [%s] " - "on window [%lx] prop [%s] target [%s].\n", + "on window [%x] prop [%s] target [%s].\n", client -> index, validateString(NameForAtom(selection)), requestor, validateString(NameForAtom(property)), validateString(NameForAtom(target))); #endif @@ -1508,8 +1508,8 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, */ #ifdef DEBUG - fprintf(stderr, "nxagentConvertSelection: Consecutives request from client [%p] selection [%ld] " - "elapsed time [%lu] clientAccum [%d]\n", (void *) client, selection, + fprintf(stderr, "nxagentConvertSelection: Consecutives request from client [%p] selection [%u] " + "elapsed time [%u] clientAccum [%d]\n", (void *) client, selection, GetTimeInMillis() - lastClientReqTime, clientAccum); #endif @@ -1637,7 +1637,7 @@ int nxagentSendNotify(xEvent *event) x.time = CurrentTime; #ifdef DEBUG - fprintf(stderr, "%s: Propagating clientCutProperty to requestor [%p].\n", __func__, x.requestor); + fprintf(stderr, "%s: Propagating clientCutProperty to requestor [%p].\n", __func__, (void *)x.requestor); #endif result = XSendEvent (nxagentDisplay, x.requestor, False, @@ -1664,7 +1664,7 @@ WindowPtr nxagentGetClipboardWindow(Atom property, WindowPtr pWin) int i = 0; #ifdef DEBUG - fprintf(stderr, "%s: Got called, property [%d][%s] window [%p].\n", __func__, property, NameForAtom(property), pWin); + fprintf(stderr, "%s: Got called, property [%d][%s] window [%p].\n", __func__, property, NameForAtom(property), (void *)pWin); #endif while ((i < nxagentMaxSelections) && @@ -1677,7 +1677,7 @@ WindowPtr nxagentGetClipboardWindow(Atom property, WindowPtr pWin) (lastSelectionOwner[i].windowPtr != NULL)) { #ifdef DEBUG - fprintf(stderr, "%s: Returning last clipboard owner window [%p].\n", __func__, lastSelectionOwner[i].windowPtr); + fprintf(stderr, "%s: Returning last clipboard owner window [%p].\n", __func__, (void *)lastSelectionOwner[i].windowPtr); #endif return lastSelectionOwner[i].windowPtr; @@ -1685,7 +1685,7 @@ WindowPtr nxagentGetClipboardWindow(Atom property, WindowPtr pWin) else { #ifdef DEBUG - fprintf(stderr, "%s: Returning original target window [%p].\n", __func__, pWin); + fprintf(stderr, "%s: Returning original target window [%p].\n", __func__, (void *)pWin); #endif return pWin; @@ -1751,14 +1751,14 @@ int nxagentInitClipboard(WindowPtr pWin) if (serverCutProperty == None) { #ifdef PANIC - fprintf(stderr, "nxagentInitClipboard: PANIC! Could not create NX_CUT_BUFFER_SERVER atom\n"); + fprintf(stderr, "%s: PANIC! Could not create NX_CUT_BUFFER_SERVER atom\n", __func__); #endif return -1; } #ifdef TEST - fprintf(stderr, "nxagentInitClipboard: Setting owner of selection [%s][%d] on window 0x%lx\n", + fprintf(stderr, "%s: Setting owner of selection [%s][%d] on window 0x%x\n", __func__, "NX_CUT_BUFFER_SERVER", (int) serverCutProperty, iWindow); #endif -- cgit v1.2.3 From 60bce146ee344d477add3a559eb9f2de155e4c09 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Oct 2018 00:30:01 +0200 Subject: Clipboard.c: use __func__ everywhere --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 117 ++++++++++++------------- 1 file changed, 58 insertions(+), 59 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 172658639..13cfd81e6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -395,7 +395,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) int i; #ifdef DEBUG - fprintf(stderr, "nxagentClearClipboard: Called with client [%p] window [%p].\n", + fprintf(stderr, "%s: Called with client [%p] window [%p].\n", __func__, (void *) pClient, (void *) pWindow); #endif @@ -411,7 +411,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) (pWindow != NULL && lastSelectionOwner[i].windowPtr == pWindow)) { #ifdef TEST - fprintf(stderr, "nxagentClearClipboard: Resetting state with client [%p] window [%p].\n", + fprintf(stderr, "%s: Resetting state with client [%p] window [%p].\n", __func__, (void *) pClient, (void *) pWindow); #endif @@ -493,7 +493,7 @@ void nxagentRequestSelection(XEvent *X) XSelectionEvent eventSelection = {0}; #ifdef DEBUG - fprintf(stderr, "nxagentRequestSelection: Got called.\n"); + fprintf(stderr, "%s: Got called.\n", __func__); #endif nxagentPrintClipboardStat("before nxagentRequestSelection"); @@ -614,7 +614,7 @@ FIXME: Do we need this? serverWindow, lastClientTime); #ifdef DEBUG - fprintf(stderr, "nxagentRequestSelection: Sent XConvertSelection.\n"); + fprintf(stderr, "%s: Sent XConvertSelection.\n", __func__); #endif } else @@ -668,7 +668,7 @@ FIXME: Do we need this? NullGrab); #ifdef DEBUG - fprintf(stderr, "nxagentRequestSelection: Executed TryClientEvents with clientCutProperty.\n"); + fprintf(stderr, "%s: Executed TryClientEvents with clientCutProperty.\n", __func__); #endif } else @@ -719,7 +719,7 @@ void nxagentSendSelectionNotify(Atom property) xEvent x; #ifdef DEBUG - fprintf (stderr, "nxagentSendSelectionNotify: Sending event to client [%d].\n", + fprintf (stderr, "%s: Sending event to client [%d].\n", __func__, lastClientClientPtr -> index); #endif @@ -746,7 +746,7 @@ void nxagentTransferSelection(int resource) if (lastClientClientPtr -> index != resource) { #ifdef DEBUG - fprintf (stderr, "nxagentTransferSelection: WARNING! Inconsistent resource [%d] with current client [%d].\n", + fprintf (stderr, "%s: WARNING! Inconsistent resource [%d] with current client [%d].\n", __func__, resource, lastClientClientPtr -> index); #endif @@ -774,7 +774,7 @@ void nxagentTransferSelection(int resource) if (nxagentLastClipboardClient == -1) { #ifdef WARNING - fprintf(stderr, "nxagentTransferSelection: WARNING! Asynchronous GetProperty queue full.\n"); + fprintf(stderr, "%s: WARNING! Asynchronous GetProperty queue full.\n", __func__); #endif result = -1; @@ -794,7 +794,7 @@ void nxagentTransferSelection(int resource) if (result == -1) { #ifdef DEBUG - fprintf (stderr, "nxagentTransferSelection: Aborting selection notify procedure for client [%d].\n", + fprintf (stderr, "%s: Aborting selection notify procedure for client [%d].\n", __func__, lastClientClientPtr -> index); #endif @@ -819,7 +819,7 @@ void nxagentTransferSelection(int resource) */ #ifdef DEBUG - fprintf(stderr, "nxagentTransferSelection: Getting property content from remote server.\n"); + fprintf(stderr, "%s: Getting property content from remote server.\n", __func__); #endif nxagentLastClipboardClient = NXGetCollectPropertyResource(nxagentDisplay); @@ -827,7 +827,7 @@ void nxagentTransferSelection(int resource) if (nxagentLastClipboardClient == -1) { #ifdef WARNING - fprintf(stderr, "nxagentTransferSelection: WARNING! Asynchronous GetProperty queue full.\n"); + fprintf(stderr, "%s: WARNING! Asynchronous GetProperty queue full.\n", __func__); #endif result = -1; @@ -847,7 +847,7 @@ void nxagentTransferSelection(int resource) if (result == -1) { #ifdef DEBUG - fprintf (stderr, "nxagentTransferSelection: Aborting selection notify procedure for client [%d].\n", + fprintf (stderr, "%s: Aborting selection notify procedure for client [%d].\n", __func__, lastClientClientPtr -> index); #endif @@ -866,7 +866,7 @@ void nxagentTransferSelection(int resource) default: { #ifdef DEBUG - fprintf (stderr, "nxagentTransferSelection: WARNING! Inconsistent state [%s] for client [%d].\n", + fprintf (stderr, "%s: WARNING! Inconsistent state [%s] for client [%d].\n", __func__, GetClientSelectionStageString(lastClientStage), lastClientClientPtr -> index); #endif @@ -903,7 +903,7 @@ void nxagentCollectPropertyEvent(int resource) if (result == 0) { #ifdef DEBUG - fprintf (stderr, "nxagentCollectPropertyEvent: Failed to get reply data for client [%d].\n", + fprintf (stderr, "%s: Failed to get reply data for client [%d].\n", __func__, lastClientClientPtr -> index); #endif @@ -919,8 +919,7 @@ void nxagentCollectPropertyEvent(int resource) if (resultFormat != 8 && resultFormat != 16 && resultFormat != 32) { #ifdef DEBUG - fprintf (stderr, "nxagentCollectPropertyEvent: WARNING! Invalid property " - "value.\n"); + fprintf (stderr, "%s: WARNING! Invalid property value.\n", __func__); #endif if (lastClientClientPtr != NULL) @@ -941,14 +940,14 @@ void nxagentCollectPropertyEvent(int resource) { PrintClientSelectionStage(); #ifdef DEBUG - fprintf (stderr, "nxagentCollectPropertyEvent: Got size notify event for client [%d].\n", + fprintf (stderr, "%s: Got size notify event for client [%d].\n", __func__, lastClientClientPtr -> index); #endif if (ulReturnBytesLeft == 0) { #ifdef DEBUG - fprintf (stderr, "nxagentCollectPropertyEvent: Aborting selection notify procedure for client [%d].\n", + fprintf (stderr, "%s: Aborting selection notify procedure for client [%d].\n", __func__, lastClientClientPtr -> index); #endif @@ -962,7 +961,7 @@ void nxagentCollectPropertyEvent(int resource) } #ifdef DEBUG - fprintf(stderr, "nxagentCollectPropertyEvent: Got property size from remote server.\n"); + fprintf(stderr, "%s: Got property size from remote server.\n", __func__); #endif /* @@ -980,14 +979,14 @@ void nxagentCollectPropertyEvent(int resource) { PrintClientSelectionStage(); #ifdef DEBUG - fprintf (stderr, "nxagentCollectPropertyEvent: Got data notify event for client [%d].\n", + fprintf (stderr, "%s: Got data notify event for client [%d].\n", __func__, lastClientClientPtr -> index); #endif if (ulReturnBytesLeft != 0) { #ifdef DEBUG - fprintf (stderr, "nxagentCollectPropertyEvent: Aborting selection notify procedure for client [%d].\n", + fprintf (stderr, "%s: Aborting selection notify procedure for client [%d].\n", __func__, lastClientClientPtr -> index); #endif @@ -1001,7 +1000,7 @@ void nxagentCollectPropertyEvent(int resource) } #ifdef DEBUG - fprintf(stderr, "nxagentCollectPropertyEvent: Got property content from remote server.\n"); + fprintf(stderr, "%s: Got property content from remote server.\n", __func__); #endif ChangeWindowProperty(lastClientWindowPtr, @@ -1011,7 +1010,7 @@ void nxagentCollectPropertyEvent(int resource) ulReturnItems, pszReturnData, 1); #ifdef DEBUG - fprintf(stderr, "nxagentCollectPropertyEvent: Selection property [%s] changed to [%s]\n", + fprintf(stderr, "%s: Selection property [%s] changed to [%s]\n", __func__, validateString(NameForAtom(lastClientProperty)), pszReturnData); #endif @@ -1029,7 +1028,7 @@ void nxagentCollectPropertyEvent(int resource) default: { #ifdef DEBUG - fprintf (stderr, "nxagentCollectPropertyEvent: WARNING! Inconsistent state [%s] for client [%d].\n", + fprintf (stderr, "%s: WARNING! Inconsistent state [%s] for client [%d].\n", __func__, GetClientSelectionStageString(lastClientStage), lastClientClientPtr -> index); #endif @@ -1045,7 +1044,7 @@ void nxagentNotifySelection(XEvent *X) XSelectionEvent eventSelection; #ifdef DEBUG - fprintf(stderr, "nxagentNotifySelection: Got called.\n"); + fprintf(stderr, "%s: Got called.\n", __func__); #endif if (agentClipboardStatus != 1) @@ -1054,7 +1053,7 @@ void nxagentNotifySelection(XEvent *X) } #ifdef DEBUG - fprintf(stderr, "nxagentNotifySelection: SelectionNotify event.\n"); + fprintf(stderr, "%s: SelectionNotify event.\n", __func__); #endif PrintClientSelectionStage(); @@ -1064,7 +1063,7 @@ void nxagentNotifySelection(XEvent *X) if ((lastClientStage == SelectionStageNone) && (X->xselection.property == serverCutProperty)) { #ifdef DEBUG - fprintf(stderr, "nxagentNotifySelection: Starting selection transferral for client [%d].\n", + fprintf(stderr, "%s: Starting selection transferral for client [%d].\n", __func__, lastClientClientPtr -> index); #endif @@ -1087,7 +1086,7 @@ void nxagentNotifySelection(XEvent *X) else { #ifdef DEBUG - fprintf(stderr, "nxagentNotifySelection: WARNING! Resetting selection transferral for client [%d].\n", + fprintf(stderr, "%s: WARNING! Resetting selection transferral for client [%d].\n", __func__, lastClientClientPtr -> index); #endif @@ -1227,8 +1226,8 @@ void nxagentResetSelectionOwner(void) if (lastServerRequestor != None) { #ifdef TEST - fprintf (stderr, "nxagentResetSelectionOwner: WARNING! Requestor window [0x%x] already found.\n", - lastServerRequestor); + fprintf(stderr, "%s: WARNING! Requestor window [0x%x] already found.\n", __func__, + lastServerRequestor); #endif return; @@ -1242,7 +1241,7 @@ void nxagentResetSelectionOwner(void) { XSetSelectionOwner(nxagentDisplay, lastSelectionOwner[i].selection, serverWindow, CurrentTime); - fprintf (stderr, "nxagentResetSelectionOwner: Reset clipboard state.\n"); + fprintf(stderr, "%s: Reset clipboard state.\n", __func__); lastSelectionOwner[i].client = NULL; lastSelectionOwner[i].window = None; @@ -1262,7 +1261,7 @@ void nxagentSetSelectionOwner(Selection *pSelection) { int i; #ifdef DEBUG - fprintf(stderr, "nxagentSetSelectionOwner: Got called.\n"); + fprintf(stderr, "%s: Got called.\n", __func__); #endif if (agentClipboardStatus != 1) @@ -1271,14 +1270,14 @@ void nxagentSetSelectionOwner(Selection *pSelection) } #ifdef DEBUG - fprintf(stderr, "nxagentSetSelectionOwner: Setting selection owner to window [0x%x].\n", + fprintf(stderr, "%s: Setting selection owner to window [0x%x].\n", __func__, serverWindow); #endif #ifdef TEST if (lastServerRequestor != None) { - fprintf (stderr, "nxagentSetSelectionOwner: WARNING! Requestor window [0x%x] already found.\n", + fprintf (stderr, "%s: WARNING! Requestor window [0x%x] already found.\n", __func__, lastServerRequestor); } #endif @@ -1310,7 +1309,7 @@ FIXME if (XGetSelectionOwner(nxagentDisplay,pSelection->selection)==serverWindow) { - fprintf (stderr, "NXdispatch: SetSelectionOwner OK\n"); + fprintf (stderr, "%s: SetSelectionOwner OK\n", __func__); lastSelectionOwnerSelection = pSelection; lastSelectionOwnerClient = pSelection->client; @@ -1322,7 +1321,7 @@ FIXME lastServerRequestor = None; } - else fprintf (stderr, "nxagentSetSelectionOwner: SetSelectionOwner failed\n"); + else fprintf (stderr, "%s: SetSelectionOwner failed\n", __func__); */ } @@ -1338,7 +1337,7 @@ FIXME: Why this pointer can be not a valid if (clients[client -> index] != client) { #ifdef WARNING - fprintf(stderr, "nxagentNotifyConvertFailure: WARNING! Invalid client pointer."); + fprintf(stderr, "%s: WARNING! Invalid client pointer.", __func__); #endif return; @@ -1388,14 +1387,14 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, if (lastClientWindowPtr != NULL) { #ifdef TEST - fprintf(stderr, "nxagentConvertSelection: lastClientWindowPtr != NULL.\n"); + fprintf(stderr, "%s: lastClientWindowPtr != NULL.\n", __func__); #endif if ((GetTimeInMillis() - lastClientReqTime) > 5000) { #ifdef DEBUG - fprintf(stderr, "nxagentConvertSelection: timeout expired on last request, " - "notifying failure to client\n"); + fprintf(stderr, "%s: timeout expired on last request, " + "notifying failure to client\n", __func__); #endif nxagentNotifyConvertFailure(lastClientClientPtr, lastClientRequestor, @@ -1407,8 +1406,8 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, else { #ifdef DEBUG - fprintf(stderr, "nxagentConvertSelection: got request " - "before timeout expired on last request, notifying failure to client\n"); + fprintf(stderr, "%s: got request " + "before timeout expired on last request, notifying failure to client\n", __func__); #endif nxagentNotifyConvertFailure(client, requestor, selection, target, time); @@ -1418,8 +1417,8 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, } #ifdef TEST - fprintf(stderr, "nxagentConvertSelection: client [%d] ask for sel [%s] " - "on window [%x] prop [%s] target [%s].\n", + fprintf(stderr, "%s: client [%d] ask for sel [%s] " + "on window [%x] prop [%s] target [%s].\n", __func__, client -> index, validateString(NameForAtom(selection)), requestor, validateString(NameForAtom(property)), validateString(NameForAtom(target))); #endif @@ -1508,8 +1507,8 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, */ #ifdef DEBUG - fprintf(stderr, "nxagentConvertSelection: Consecutives request from client [%p] selection [%u] " - "elapsed time [%u] clientAccum [%d]\n", (void *) client, selection, + fprintf(stderr, "%s: Consecutives request from client [%p] selection [%u] " + "elapsed time [%u] clientAccum [%d]\n", __func__, (void *) client, selection, GetTimeInMillis() - lastClientReqTime, clientAccum); #endif @@ -1557,7 +1556,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, } #ifdef DEBUG - fprintf(stderr, "nxagentConvertSelection: Sent XConvertSelection with target=[%s], property [%s]\n", + fprintf(stderr, "%s: Sent XConvertSelection with target=[%s], property [%s]\n", __func__, validateString(NameForAtom(target)), validateString(NameForAtom(property))); #endif @@ -1568,8 +1567,8 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, xEvent x; #ifdef DEBUG - fprintf(stderr, "nxagentConvertSelection: Xserver generates a SelectionNotify event " - "to the requestor with property None.\n"); + fprintf(stderr, "%s: Xserver generates a SelectionNotify event " + "to the requestor with property None.\n", __func__); #endif memset(&x, 0, sizeof(xEvent)); @@ -1654,7 +1653,7 @@ int nxagentSendNotify(xEvent *event) return 1; } #ifdef DEBUG - fprintf(stderr, "nxagentSendNotify: sent nothing.\n"); + fprintf(stderr, "%s: sent nothing.\n", __func__); #endif return 0; } @@ -1699,7 +1698,7 @@ int nxagentInitClipboard(WindowPtr pWin) Window iWindow = nxagentWindow(pWin); #ifdef DEBUG - fprintf(stderr, "nxagentInitClipboard: Got called.\n"); + fprintf(stderr, "%s: Got called.\n", __func__); #endif free(lastSelectionOwner); @@ -1731,7 +1730,7 @@ int nxagentInitClipboard(WindowPtr pWin) { extern unsigned long startTime; - fprintf(stderr, "nxagentInitClipboard: Initializing start [%d] milliseconds.\n", + fprintf(stderr, "%s: Initializing start [%d] milliseconds.\n", __func__, GetTimeInMillis() - startTime); } #endif @@ -1775,7 +1774,7 @@ int nxagentInitClipboard(WindowPtr pWin) else { #ifdef TEST - fprintf(stderr, "nxagentInitClipboard: Registering for XFixesSelectionNotify events.\n"); + fprintf(stderr, "%s: Registering for XFixesSelectionNotify events.\n", __func__); #endif for (i = 0; i < nxagentMaxSelections; i++) @@ -1801,8 +1800,8 @@ int nxagentInitClipboard(WindowPtr pWin) if (nxagentSessionId[0]) { #ifdef TEST - fprintf(stderr, "nxagentInitClipboard: setting the ownership of %s to %lx" - " and registering for PropertyChangeMask events\n", + fprintf(stderr, "%s: setting the ownership of %s to %lx" + " and registering for PropertyChangeMask events\n", __func__, validateString(XGetAtomName(nxagentDisplay, nxagentAtoms[10])), iWindow); #endif @@ -1847,8 +1846,8 @@ int nxagentInitClipboard(WindowPtr pWin) if (clientCutProperty == None) { #ifdef PANIC - fprintf(stderr, "nxagentInitClipboard: PANIC! " - "Could not create NX_CUT_BUFFER_CLIENT atom.\n"); + fprintf(stderr, "%s: PANIC! " + "Could not create NX_CUT_BUFFER_CLIENT atom.\n", __func__); #endif return -1; @@ -1858,14 +1857,14 @@ int nxagentInitClipboard(WindowPtr pWin) agentClipboardStatus = 1; #ifdef DEBUG - fprintf(stderr, "nxagentInitClipboard: Clipboard initialization completed.\n"); + fprintf(stderr, "%s: Clipboard initialization completed.\n", __func__); #endif #ifdef NXAGENT_TIMESTAMP { extern unsigned long startTime; - fprintf(stderr, "nxagentInitClipboard: initializing ends [%d] milliseconds.\n", + fprintf(stderr, "%s: initializing ends [%d] milliseconds.\n", __func__, GetTimeInMillis() - startTime); } #endif -- cgit v1.2.3