Commit 1feb4985 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Clipboard.c: make agentClipboardStatus a Boolean

and add debugging information around its checks.
parent fba36716
...@@ -67,7 +67,7 @@ extern Selection *CurrentSelections; ...@@ -67,7 +67,7 @@ extern Selection *CurrentSelections;
int nxagentLastClipboardClient = -1; int nxagentLastClipboardClient = -1;
static int agentClipboardStatus; static int agentClipboardInitialized = False;
#ifdef DEBUG #ifdef DEBUG
static int clientAccum; static int clientAccum;
#endif #endif
...@@ -285,14 +285,14 @@ void nxagentPrintClipboardStat(char *header) ...@@ -285,14 +285,14 @@ void nxagentPrintClipboardStat(char *header)
fprintf(stderr, "/----- Clipboard internal status - %s -----\n", header); fprintf(stderr, "/----- Clipboard internal status - %s -----\n", header);
fprintf(stderr, " current time (Time) [%u]\n", GetTimeInMillis()); fprintf(stderr, " current time (Time) [%u]\n", GetTimeInMillis());
fprintf(stderr, " agentClipboardStatus (int) [%d]\n", agentClipboardStatus); fprintf(stderr, " agentClipboardInitialized (Bool) [%s]\n", agentClipboardInitialized ? "True" : "False");
fprintf(stderr, " clientAccum (int) [%d]\n", clientAccum); fprintf(stderr, " clientAccum (int) [%d]\n", clientAccum);
fprintf(stderr, " nxagentMaxSelections (int) [%d]\n", nxagentMaxSelections); fprintf(stderr, " nxagentMaxSelections (int) [%d]\n", nxagentMaxSelections);
fprintf(stderr, " NumCurrentSelections (int) [%d]\n", NumCurrentSelections); fprintf(stderr, " NumCurrentSelections (int) [%d]\n", NumCurrentSelections);
fprintf(stderr, " serverWindow (Window) [0x%x]\n", serverWindow); fprintf(stderr, " serverWindow (Window) [0x%x]\n", serverWindow);
fprintf(stderr, " nxagentLastClipboardClient (int) [%d]\n", nxagentLastClipboardClient); fprintf(stderr, " nxagentLastClipboardClient (int) [%d]\n", nxagentLastClipboardClient);
fprintf(stderr, " ClipboardMode "); fprintf(stderr, " Clipboard mode ");
switch(nxagentOption(Clipboard)) switch(nxagentOption(Clipboard))
{ {
case ClipboardBoth: fprintf(stderr, "[Both]"); break;; case ClipboardBoth: fprintf(stderr, "[Both]"); break;;
...@@ -597,9 +597,19 @@ void nxagentClearSelection(XEvent *X) ...@@ -597,9 +597,19 @@ void nxagentClearSelection(XEvent *X)
nxagentPrintClipboardStat("before nxagentClearSelection"); nxagentPrintClipboardStat("before nxagentClearSelection");
if (agentClipboardStatus != 1 || if (!agentClipboardInitialized)
nxagentOption(Clipboard) == ClipboardServer)
{ {
#ifdef DEBUG
fprintf(stderr, "%s: clipboard not initialized - doing nothing.\n", __func__);
#endif
return;
}
if (nxagentOption(Clipboard) == ClipboardServer)
{
#ifdef DEBUG
fprintf(stderr, "%s: clipboard mode 'server' - doing nothing.\n", __func__);
#endif
return; return;
} }
...@@ -696,8 +706,11 @@ void nxagentRequestSelection(XEvent *X) ...@@ -696,8 +706,11 @@ void nxagentRequestSelection(XEvent *X)
nxagentPrintClipboardStat("before nxagentRequestSelection"); nxagentPrintClipboardStat("before nxagentRequestSelection");
if (agentClipboardStatus != 1) if (!agentClipboardInitialized)
{ {
#ifdef DEBUG
fprintf(stderr, "%s: clipboard not initialized - doing nothing.\n", __func__);
#endif
return; return;
} }
...@@ -1215,8 +1228,11 @@ void nxagentCollectPropertyEvent(int resource) ...@@ -1215,8 +1228,11 @@ void nxagentCollectPropertyEvent(int resource)
*/ */
void nxagentHandleSelectionNotifyFromXServer(XEvent *X) void nxagentHandleSelectionNotifyFromXServer(XEvent *X)
{ {
if (agentClipboardStatus != 1) if (!agentClipboardInitialized)
{ {
#ifdef DEBUG
fprintf(stderr, "%s: clipboard not initialized - doing nothing.\n", __func__);
#endif
return; return;
} }
...@@ -1521,8 +1537,11 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, ...@@ -1521,8 +1537,11 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data,
*/ */
void nxagentSetSelectionOwner(Selection *pSelection) void nxagentSetSelectionOwner(Selection *pSelection)
{ {
if (agentClipboardStatus != 1) if (!agentClipboardInitialized)
{ {
#ifdef DEBUG
fprintf(stderr, "%s: clipboard not initialized - doing nothing.\n", __func__);
#endif
return; return;
} }
...@@ -1637,9 +1656,19 @@ void nxagentNotifyConvertFailure(ClientPtr client, Window requestor, ...@@ -1637,9 +1656,19 @@ void nxagentNotifyConvertFailure(ClientPtr client, Window requestor,
int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
Window requestor, Atom property, Atom target, Time time) Window requestor, Atom property, Atom target, Time time)
{ {
if (agentClipboardStatus != 1 || if (!agentClipboardInitialized)
nxagentOption(Clipboard) == ClipboardServer)
{ {
#ifdef DEBUG
fprintf(stderr, "%s: clipboard not initialized - doing nothing.\n", __func__);
#endif
return 0;
}
if (nxagentOption(Clipboard) == ClipboardServer)
{
#ifdef DEBUG
fprintf(stderr, "%s: clipboard mode 'server' - doing nothing.\n", __func__);
#endif
return 0; return 0;
} }
...@@ -1894,10 +1923,10 @@ int nxagentSendNotify(xEvent *event) ...@@ -1894,10 +1923,10 @@ int nxagentSendNotify(xEvent *event)
fprintf(stderr, "%s: Got called.\n", __func__); fprintf(stderr, "%s: Got called.\n", __func__);
#endif #endif
if (agentClipboardStatus != 1) if (!agentClipboardInitialized)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s: agentClipboardStatus != 1 - doing nothing.\n", __func__); fprintf(stderr, "%s: clipboard not initialized - doing nothing.\n", __func__);
#endif #endif
return 0; return 0;
} }
...@@ -2049,7 +2078,7 @@ int nxagentInitClipboard(WindowPtr pWin) ...@@ -2049,7 +2078,7 @@ int nxagentInitClipboard(WindowPtr pWin)
} }
#endif #endif
agentClipboardStatus = 0; agentClipboardInitialized = False;
serverWindow = iWindow; serverWindow = iWindow;
/* /*
...@@ -2170,7 +2199,7 @@ int nxagentInitClipboard(WindowPtr pWin) ...@@ -2170,7 +2199,7 @@ int nxagentInitClipboard(WindowPtr pWin)
} }
} }
agentClipboardStatus = 1; agentClipboardInitialized = True;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s: Clipboard initialization completed.\n", __func__); fprintf(stderr, "%s: Clipboard initialization completed.\n", __func__);
......
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