diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2020-02-14 22:21:39 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-05-31 12:52:35 +0200 |
commit | f3320571df484de540e9f85a4f8697f8b697fe2d (patch) | |
tree | 35237f9b11ef29cfd16961f04b01335eb351b934 /nx-X11/programs | |
parent | 46bd33402820a3be60e74f0f246081798b32f8e8 (diff) | |
download | nx-libs-f3320571df484de540e9f85a4f8697f8b697fe2d.tar.gz nx-libs-f3320571df484de540e9f85a4f8697f8b697fe2d.tar.bz2 nx-libs-f3320571df484de540e9f85a4f8697f8b697fe2d.zip |
Clipboard.c: make setClientSelectionStage a function
and reset the lastClient variables when stage is set to None.
Diffstat (limited to 'nx-X11/programs')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 492b74295..1e444a614 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -178,10 +178,8 @@ static const char * getClientSelectionStageString(int stage) } #ifdef DEBUG -#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 @@ -231,6 +229,7 @@ XFixesAgentInfoRec nxagentXFixesInfo = { -1, -1, -1, 0 }; extern Display *nxagentDisplay; static Bool validServerTargets(XlibAtom target); +static void setClientSelectionStage(int stage); static void endTransfer(Bool success); #define SELECTION_SUCCESS True #define SELECTION_FAULT False @@ -407,6 +406,31 @@ void nxagentDumpClipboardStat(void) } /* + * Helper to handle data transfer + */ +static void setClientSelectionStage(int stage) +{ + #ifdef DEBUG + fprintf(stderr, "%s: Changing selection stage from [%s] to [%s]\n", __func__, + getClientSelectionStageString(lastClientStage), getClientSelectionStageString(stage)); + #endif + + lastClientStage = stage; + if (stage == SelectionStageNone) + { + lastClientWindowPtr = NULL; + lastClientClientPtr = NULL; + lastClientRequestor = 0; + lastClientProperty = 0; + lastClientSelection = 0; + lastClientTarget = 0; + lastClientTime = 0; + lastClientReqTime = 0; + lastClientPropertySize = 0; + } +} + +/* * This is from NXproperty.c. */ @@ -600,8 +624,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) clearSelectionOwner(i); - lastClientWindowPtr = NULL; - setClientSelectionStage(None); + setClientSelectionStage(SelectionStageNone); lastServerRequestor = None; } @@ -609,8 +632,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) if (pWindow && pWindow == lastClientWindowPtr) { - lastClientWindowPtr = NULL; - setClientSelectionStage(None); + setClientSelectionStage(SelectionStageNone); } } @@ -697,8 +719,7 @@ void nxagentHandleSelectionClearFromXServer(XEvent *X) clearSelectionOwner(i); } - lastClientWindowPtr = NULL; - setClientSelectionStage(None); + setClientSelectionStage(SelectionStageNone); } /* @@ -1017,8 +1038,7 @@ static void endTransfer(Bool success) /* * Enable further requests from clients. */ - lastClientWindowPtr = NULL; - setClientSelectionStage(None); + setClientSelectionStage(SelectionStageNone); } static void transferSelection(int resource) @@ -1082,7 +1102,7 @@ static void transferSelection(int resource) return; } - setClientSelectionStage(WaitSize); + setClientSelectionStage(SelectionStageWaitSize); NXFlushDisplay(nxagentDisplay, NXFlushLink); @@ -1136,7 +1156,7 @@ static void transferSelection(int resource) return; } - setClientSelectionStage(WaitData); + setClientSelectionStage(SelectionStageWaitData); /* we've seen situations where you had to move the mouse or press a key to let the transfer complete. Flushing here fixed it */ @@ -1233,7 +1253,7 @@ void nxagentCollectPropertyEvent(int resource) * Request the selection data now. */ lastClientPropertySize = ulReturnBytesLeft; - setClientSelectionStage(QueryData); + setClientSelectionStage(SelectionStageQueryData); transferSelection(resource); } @@ -1352,7 +1372,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) * tions. */ - setClientSelectionStage(QueryData); + setClientSelectionStage(SelectionStageQueryData); lastClientPropertySize = 262144; transferSelection(lastClientClientPtr -> index); @@ -1523,8 +1543,7 @@ static void resetSelectionOwner(void) clearSelectionOwner(i); } - lastClientWindowPtr = NULL; - setClientSelectionStage(None); + setClientSelectionStage(SelectionStageNone); /* Hmm, this is already None when reaching this */ lastServerRequestor = None; @@ -1670,8 +1689,7 @@ static void setSelectionOwner(Selection *pSelection) storeSelectionOwner(i, pSelection); } - lastClientWindowPtr = NULL; - setClientSelectionStage(None); + setClientSelectionStage(SelectionStageNone); lastServerRequestor = None; @@ -1687,8 +1705,7 @@ FIXME lastSelectionOwnerWindow = pSelection->window; lastSelectionOwnerWindowPtr = pSelection->pWin; - lastClientWindowPtr = NULL; - setClientSelectionStage(None); + setClientSelectionStage(SelectionStageNone); lastServerRequestor = None; } @@ -1773,8 +1790,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, notifyConvertFailure(lastClientClientPtr, lastClientRequestor, lastClientSelection, lastClientTarget, lastClientTime); - lastClientWindowPtr = NULL; - setClientSelectionStage(None); + setClientSelectionStage(SelectionStageNone); } else { @@ -1912,13 +1928,14 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, target == clientCOMPOUND_TEXT || target == clientUTF8_STRING) { - lastClientWindowPtr = pWin; - setClientSelectionStage(None); + setClientSelectionStage(SelectionStageNone); + /* * store the original requestor, we need that later after * serverTransToAgentProperty contains the desired selection content */ lastClientRequestor = requestor; + lastClientWindowPtr = pWin; lastClientClientPtr = client; lastClientTime = time; lastClientProperty = property; @@ -2283,8 +2300,7 @@ Bool nxagentInitClipboard(WindowPtr pWin) lastServerRequestor = None; - lastClientWindowPtr = NULL; - setClientSelectionStage(None); + setClientSelectionStage(SelectionStageNone); lastClientReqTime = GetTimeInMillis(); clientTARGETS = MakeAtom(szAgentTARGETS, strlen(szAgentTARGETS), True); |