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

Clipboard.c: make setClientSelectionStage a function

and reset the lastClient variables when stage is set to None.
parent 46bd3340
...@@ -178,10 +178,8 @@ static const char * getClientSelectionStageString(int stage) ...@@ -178,10 +178,8 @@ static const char * getClientSelectionStageString(int stage)
} }
#ifdef DEBUG #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) #define printClientSelectionStage() do {fprintf(stderr, "%s: Current selection stage [%s]\n", __func__, getClientSelectionStageString(lastClientStage));} while (0)
#else #else
#define setClientSelectionStage(stage) do {lastClientStage = SelectionStage##stage;} while (0)
#define printClientSelectionStage() #define printClientSelectionStage()
#endif #endif
...@@ -231,6 +229,7 @@ XFixesAgentInfoRec nxagentXFixesInfo = { -1, -1, -1, 0 }; ...@@ -231,6 +229,7 @@ XFixesAgentInfoRec nxagentXFixesInfo = { -1, -1, -1, 0 };
extern Display *nxagentDisplay; extern Display *nxagentDisplay;
static Bool validServerTargets(XlibAtom target); static Bool validServerTargets(XlibAtom target);
static void setClientSelectionStage(int stage);
static void endTransfer(Bool success); static void endTransfer(Bool success);
#define SELECTION_SUCCESS True #define SELECTION_SUCCESS True
#define SELECTION_FAULT False #define SELECTION_FAULT False
...@@ -407,6 +406,31 @@ void nxagentDumpClipboardStat(void) ...@@ -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. * This is from NXproperty.c.
*/ */
...@@ -600,8 +624,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) ...@@ -600,8 +624,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
clearSelectionOwner(i); clearSelectionOwner(i);
lastClientWindowPtr = NULL; setClientSelectionStage(SelectionStageNone);
setClientSelectionStage(None);
lastServerRequestor = None; lastServerRequestor = None;
} }
...@@ -609,8 +632,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) ...@@ -609,8 +632,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
if (pWindow && pWindow == lastClientWindowPtr) if (pWindow && pWindow == lastClientWindowPtr)
{ {
lastClientWindowPtr = NULL; setClientSelectionStage(SelectionStageNone);
setClientSelectionStage(None);
} }
} }
...@@ -697,8 +719,7 @@ void nxagentHandleSelectionClearFromXServer(XEvent *X) ...@@ -697,8 +719,7 @@ void nxagentHandleSelectionClearFromXServer(XEvent *X)
clearSelectionOwner(i); clearSelectionOwner(i);
} }
lastClientWindowPtr = NULL; setClientSelectionStage(SelectionStageNone);
setClientSelectionStage(None);
} }
/* /*
...@@ -1017,8 +1038,7 @@ static void endTransfer(Bool success) ...@@ -1017,8 +1038,7 @@ static void endTransfer(Bool success)
/* /*
* Enable further requests from clients. * Enable further requests from clients.
*/ */
lastClientWindowPtr = NULL; setClientSelectionStage(SelectionStageNone);
setClientSelectionStage(None);
} }
static void transferSelection(int resource) static void transferSelection(int resource)
...@@ -1082,7 +1102,7 @@ static void transferSelection(int resource) ...@@ -1082,7 +1102,7 @@ static void transferSelection(int resource)
return; return;
} }
setClientSelectionStage(WaitSize); setClientSelectionStage(SelectionStageWaitSize);
NXFlushDisplay(nxagentDisplay, NXFlushLink); NXFlushDisplay(nxagentDisplay, NXFlushLink);
...@@ -1136,7 +1156,7 @@ static void transferSelection(int resource) ...@@ -1136,7 +1156,7 @@ static void transferSelection(int resource)
return; return;
} }
setClientSelectionStage(WaitData); setClientSelectionStage(SelectionStageWaitData);
/* we've seen situations where you had to move the mouse or press a /* we've seen situations where you had to move the mouse or press a
key to let the transfer complete. Flushing here fixed it */ key to let the transfer complete. Flushing here fixed it */
...@@ -1233,7 +1253,7 @@ void nxagentCollectPropertyEvent(int resource) ...@@ -1233,7 +1253,7 @@ void nxagentCollectPropertyEvent(int resource)
* Request the selection data now. * Request the selection data now.
*/ */
lastClientPropertySize = ulReturnBytesLeft; lastClientPropertySize = ulReturnBytesLeft;
setClientSelectionStage(QueryData); setClientSelectionStage(SelectionStageQueryData);
transferSelection(resource); transferSelection(resource);
} }
...@@ -1352,7 +1372,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) ...@@ -1352,7 +1372,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X)
* tions. * tions.
*/ */
setClientSelectionStage(QueryData); setClientSelectionStage(SelectionStageQueryData);
lastClientPropertySize = 262144; lastClientPropertySize = 262144;
transferSelection(lastClientClientPtr -> index); transferSelection(lastClientClientPtr -> index);
...@@ -1523,8 +1543,7 @@ static void resetSelectionOwner(void) ...@@ -1523,8 +1543,7 @@ static void resetSelectionOwner(void)
clearSelectionOwner(i); clearSelectionOwner(i);
} }
lastClientWindowPtr = NULL; setClientSelectionStage(SelectionStageNone);
setClientSelectionStage(None);
/* Hmm, this is already None when reaching this */ /* Hmm, this is already None when reaching this */
lastServerRequestor = None; lastServerRequestor = None;
...@@ -1670,8 +1689,7 @@ static void setSelectionOwner(Selection *pSelection) ...@@ -1670,8 +1689,7 @@ static void setSelectionOwner(Selection *pSelection)
storeSelectionOwner(i, pSelection); storeSelectionOwner(i, pSelection);
} }
lastClientWindowPtr = NULL; setClientSelectionStage(SelectionStageNone);
setClientSelectionStage(None);
lastServerRequestor = None; lastServerRequestor = None;
...@@ -1687,8 +1705,7 @@ FIXME ...@@ -1687,8 +1705,7 @@ FIXME
lastSelectionOwnerWindow = pSelection->window; lastSelectionOwnerWindow = pSelection->window;
lastSelectionOwnerWindowPtr = pSelection->pWin; lastSelectionOwnerWindowPtr = pSelection->pWin;
lastClientWindowPtr = NULL; setClientSelectionStage(SelectionStageNone);
setClientSelectionStage(None);
lastServerRequestor = None; lastServerRequestor = None;
} }
...@@ -1773,8 +1790,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1773,8 +1790,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
notifyConvertFailure(lastClientClientPtr, lastClientRequestor, notifyConvertFailure(lastClientClientPtr, lastClientRequestor,
lastClientSelection, lastClientTarget, lastClientTime); lastClientSelection, lastClientTarget, lastClientTime);
lastClientWindowPtr = NULL; setClientSelectionStage(SelectionStageNone);
setClientSelectionStage(None);
} }
else else
{ {
...@@ -1912,13 +1928,14 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1912,13 +1928,14 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
target == clientCOMPOUND_TEXT || target == clientCOMPOUND_TEXT ||
target == clientUTF8_STRING) target == clientUTF8_STRING)
{ {
lastClientWindowPtr = pWin; setClientSelectionStage(SelectionStageNone);
setClientSelectionStage(None);
/* /*
* store the original requestor, we need that later after * store the original requestor, we need that later after
* serverTransToAgentProperty contains the desired selection content * serverTransToAgentProperty contains the desired selection content
*/ */
lastClientRequestor = requestor; lastClientRequestor = requestor;
lastClientWindowPtr = pWin;
lastClientClientPtr = client; lastClientClientPtr = client;
lastClientTime = time; lastClientTime = time;
lastClientProperty = property; lastClientProperty = property;
...@@ -2283,8 +2300,7 @@ Bool nxagentInitClipboard(WindowPtr pWin) ...@@ -2283,8 +2300,7 @@ Bool nxagentInitClipboard(WindowPtr pWin)
lastServerRequestor = None; lastServerRequestor = None;
lastClientWindowPtr = NULL; setClientSelectionStage(SelectionStageNone);
setClientSelectionStage(None);
lastClientReqTime = GetTimeInMillis(); lastClientReqTime = GetTimeInMillis();
clientTARGETS = MakeAtom(szAgentTARGETS, strlen(szAgentTARGETS), True); clientTARGETS = MakeAtom(szAgentTARGETS, strlen(szAgentTARGETS), True);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment