Cygwin/X: Clearly diagnose a timeout while waiting for SelectionNotify event

Clearly diagnose a timeout while waiting for SelectionNotify event
in the clipboard integration internal client.
(which seems to be behind some of the reported failures)

Turn useless #if 0/ErrorF()/#endif into useful winDebug()

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
Jon TURNEY 2009-11-01 18:18:51 +00:00
parent 062f49a8e0
commit 9657eae5d6
4 changed files with 54 additions and 78 deletions

View File

@ -84,9 +84,7 @@ winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength)
unsigned char *pszEnd = pszSrc + iLength; unsigned char *pszEnd = pszSrc + iLength;
unsigned char *pszDest = NULL, *pszDestBegin = NULL; unsigned char *pszDest = NULL, *pszDestBegin = NULL;
#if 0 winDebug("UNIXtoDOS () - Original data:'%s'\n", *ppszData);
ErrorF ("UNIXtoDOS () - Original data:\n%s\n", *ppszData);
#endif
/* Count \n characters without leading \r */ /* Count \n characters without leading \r */
while (pszSrc < pszEnd) while (pszSrc < pszEnd)
@ -153,7 +151,5 @@ winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength)
free (*ppszData); free (*ppszData);
*ppszData = pszDestBegin; *ppszData = pszDestBegin;
#if 0 winDebug("UNIXtoDOS () - Final string:'%s'\n", pszDestBegin);
ErrorF ("UNIXtoDOS () - Final string:\n%s\n", pszDestBegin);
#endif
} }

View File

@ -104,13 +104,13 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
if (tv.tv_sec < 0) if (tv.tv_sec < 0)
return WIN_XEVENTS_SUCCESS; return WIN_XEVENTS_SUCCESS;
/* Wait for a Windows event or an X event */ /* Wait for an X event */
iReturn = select (iConnNumber + 1,/* Highest fds number */ iReturn = select (iConnNumber + 1,/* Highest fds number */
&fdsRead, /* Read mask */ &fdsRead, /* Read mask */
NULL, /* No write mask */ NULL, /* No write mask */
NULL, /* No exception mask */ NULL, /* No exception mask */
&tv); /* No timeout */ &tv); /* No timeout */
if (iReturn <= 0) if (iReturn < 0)
{ {
ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d. " ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d. "
"Bailing.\n", iReturn); "Bailing.\n", iReturn);
@ -440,9 +440,9 @@ winClipboardWindowProc (HWND hwnd, UINT message,
* follow this message and reassert ownership of the X11 * follow this message and reassert ownership of the X11
* selections, handling the issue for us. * selections, handling the issue for us.
*/ */
winDebug ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - Ignored.\n");
return 0; return 0;
case WM_RENDERFORMAT: case WM_RENDERFORMAT:
case WM_RENDERALLFORMATS: case WM_RENDERALLFORMATS:
{ {
@ -536,6 +536,8 @@ winClipboardWindowProc (HWND hwnd, UINT message,
if (g_fUnicodeSupport) if (g_fUnicodeSupport)
SetClipboardData (CF_UNICODETEXT, NULL); SetClipboardData (CF_UNICODETEXT, NULL);
SetClipboardData (CF_TEXT, NULL); SetClipboardData (CF_TEXT, NULL);
ErrorF("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY\n");
} }
/* BPS - Post ourselves a user message whose handler will reset the /* BPS - Post ourselves a user message whose handler will reset the

View File

@ -324,9 +324,7 @@ winProcSetSelectionOwner (ClientPtr client)
REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
#if 0 winDebug("winProcSetSelectionOwner - Hello.\n");
ErrorF ("winProcSetSelectionOwner - Hello.\n");
#endif
/* Watch for server reset */ /* Watch for server reset */
if (s_ulServerGeneration != serverGeneration) if (s_ulServerGeneration != serverGeneration)
@ -369,10 +367,8 @@ winProcSetSelectionOwner (ClientPtr client)
{ {
fOwnedToNotOwned = TRUE; fOwnedToNotOwned = TRUE;
#if 0 winDebug("winProcSetSelectionOwner - PRIMARY - Going from "
ErrorF ("winProcSetSelectionOwner - PRIMARY - Going from "
"owned to not owned.\n"); "owned to not owned.\n");
#endif
/* Adjust last owned selection */ /* Adjust last owned selection */
if (None != s_iOwners[CLIP_OWN_CLIPBOARD]) if (None != s_iOwners[CLIP_OWN_CLIPBOARD])
@ -384,10 +380,8 @@ winProcSetSelectionOwner (ClientPtr client)
/* Save new selection owner or None */ /* Save new selection owner or None */
s_iOwners[CLIP_OWN_PRIMARY] = stuff->window; s_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
#if 0 winDebug("winProcSetSelectionOwner - PRIMARY - Now owned by: %d\n",
ErrorF ("winProcSetSelectionOwner - PRIMARY - Now owned by: %d\n",
stuff->window); stuff->window);
#endif
} }
else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection) else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection)
{ {
@ -396,11 +390,9 @@ winProcSetSelectionOwner (ClientPtr client)
&& None != s_iOwners[CLIP_OWN_CLIPBOARD]) && None != s_iOwners[CLIP_OWN_CLIPBOARD])
{ {
fOwnedToNotOwned = TRUE; fOwnedToNotOwned = TRUE;
#if 0 winDebug("winProcSetSelectionOwner - CLIPBOARD - Going from "
ErrorF ("winProcSetSelectionOwner - CLIPBOARD - Going from " "owned to not owned.\n");
"owned to not owned.\n");
#endif
/* Adjust last owned selection */ /* Adjust last owned selection */
if (None != s_iOwners[CLIP_OWN_PRIMARY]) if (None != s_iOwners[CLIP_OWN_PRIMARY])
@ -412,10 +404,9 @@ winProcSetSelectionOwner (ClientPtr client)
/* Save new selection owner or None */ /* Save new selection owner or None */
s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window; s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
#if 0 winDebug("winProcSetSelectionOwner - CLIPBOARD - Now owned by: %d\n",
ErrorF ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: %d\n", stuff->window);
stuff->window);
#endif
} }
else else
goto winProcSetSelectionOwner_Done; goto winProcSetSelectionOwner_Done;
@ -444,13 +435,11 @@ winProcSetSelectionOwner (ClientPtr client)
&& g_hwndClipboard != NULL && g_hwndClipboard != NULL
&& g_hwndClipboard == GetClipboardOwner ()) && g_hwndClipboard == GetClipboardOwner ())
{ {
#if 0 winDebug("winProcSetSelectionOwner - We currently own the "
ErrorF ("winProcSetSelectionOwner - We currently own the " "clipboard and neither the PRIMARY nor the CLIPBOARD "
"clipboard and neither the PRIMARY nor the CLIPBOARD " "selections are owned, releasing ownership of Win32 "
"selections are owned, releasing ownership of Win32 " "clipboard.\n");
"clipboard.\n");
#endif
/* Release ownership of the Windows clipboard */ /* Release ownership of the Windows clipboard */
OpenClipboard (NULL); OpenClipboard (NULL);
EmptyClipboard (); EmptyClipboard ();
@ -462,9 +451,7 @@ winProcSetSelectionOwner (ClientPtr client)
/* Abort if no window at this point */ /* Abort if no window at this point */
if (None == stuff->window) if (None == stuff->window)
{ {
#if 0 winDebug("winProcSetSelectionOwner - No window, returning.\n");
ErrorF ("winProcSetSelectionOwner - No window, returning.\n");
#endif
goto winProcSetSelectionOwner_Done; goto winProcSetSelectionOwner_Done;
} }
@ -481,10 +468,8 @@ winProcSetSelectionOwner (ClientPtr client)
/* Abort if clipboard manager is owning the selection */ /* Abort if clipboard manager is owning the selection */
if (pDrawable->id == g_iClipboardWindow) if (pDrawable->id == g_iClipboardWindow)
{ {
#if 0 winDebug("winProcSetSelectionOwner - We changed ownership, "
ErrorF ("winProcSetSelectionOwner - We changed ownership, " "aborting.\n");
"aborting.\n");
#endif
goto winProcSetSelectionOwner_Done; goto winProcSetSelectionOwner_Done;
} }

View File

@ -105,20 +105,17 @@ winClipboardFlushXEvents (HWND hwnd,
*/ */
case SelectionRequest: case SelectionRequest:
#if 0
{ {
char *pszAtomName = NULL; char *pszAtomName = NULL;
winDebug("SelectionRequest - target %d\n",
ErrorF ("SelectionRequest - target %d\n", event.xselectionrequest.target);
event.xselectionrequest.target);
pszAtomName = XGetAtomName (pDisplay, pszAtomName = XGetAtomName (pDisplay,
event.xselectionrequest.target); event.xselectionrequest.target);
ErrorF ("SelectionRequest - Target atom name %s\n", pszAtomName); winDebug("SelectionRequest - Target atom name %s\n", pszAtomName);
XFree (pszAtomName); XFree (pszAtomName);
pszAtomName = NULL; pszAtomName = NULL;
} }
#endif
/* Abort if invalid target type */ /* Abort if invalid target type */
if (event.xselectionrequest.target != XA_STRING if (event.xselectionrequest.target != XA_STRING
@ -466,21 +463,17 @@ winClipboardFlushXEvents (HWND hwnd,
*/ */
case SelectionNotify: case SelectionNotify:
#if 0
ErrorF ("winClipboardFlushXEvents - SelectionNotify\n"); winDebug ("winClipboardFlushXEvents - SelectionNotify\n");
{ {
char *pszAtomName; char *pszAtomName;
pszAtomName = XGetAtomName (pDisplay, pszAtomName = XGetAtomName (pDisplay,
event.xselection.selection); event.xselection.selection);
ErrorF ("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n", winDebug("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n",
pszAtomName); pszAtomName);
XFree (pszAtomName); XFree (pszAtomName);
} }
#endif
/* /*
* Request conversion of UTF8 and CompoundText targets. * Request conversion of UTF8 and CompoundText targets.
@ -489,18 +482,16 @@ winClipboardFlushXEvents (HWND hwnd,
{ {
if (event.xselection.target == XA_STRING) if (event.xselection.target == XA_STRING)
{ {
#if 0 winDebug ("winClipboardFlushXEvents - SelectionNotify - "
ErrorF ("winClipboardFlushXEvents - SelectionNotify - " "XA_STRING\n");
"XA_STRING\n");
#endif
return WIN_XEVENTS_CONVERT; return WIN_XEVENTS_CONVERT;
} }
else if (event.xselection.target == atomUTF8String) else if (event.xselection.target == atomUTF8String)
{ {
#if 0 winDebug("winClipboardFlushXEvents - SelectionNotify - "
ErrorF ("winClipboardFlushXEvents - SelectionNotify - " "Requesting conversion of UTF8 target.\n");
"Requesting conversion of UTF8 target.\n");
#endif
iReturn = XConvertSelection (pDisplay, iReturn = XConvertSelection (pDisplay,
event.xselection.selection, event.xselection.selection,
XA_STRING, XA_STRING,
@ -523,10 +514,9 @@ winClipboardFlushXEvents (HWND hwnd,
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
else if (event.xselection.target == atomCompoundText) else if (event.xselection.target == atomCompoundText)
{ {
#if 0 winDebug("winClipboardFlushXEvents - SelectionNotify - "
ErrorF ("winClipboardFlushXEvents - SelectionNotify - " "Requesting conversion of CompoundText target.\n");
"Requesting conversion of CompoundText target.\n");
#endif
iReturn = XConvertSelection (pDisplay, iReturn = XConvertSelection (pDisplay,
event.xselection.selection, event.xselection.selection,
atomUTF8String, atomUTF8String,
@ -577,10 +567,8 @@ winClipboardFlushXEvents (HWND hwnd,
break; break;
} }
#if 0 winDebug("SelectionNotify - returned data %d left %d\n",
ErrorF ("SelectionNotify - returned data %d left %d\n", xtpText.nitems, ulReturnBytesLeft);
xtpText.nitems, ulReturnBytesLeft);
#endif
/* Request the selection data */ /* Request the selection data */
iReturn = XGetWindowProperty (pDisplay, iReturn = XGetWindowProperty (pDisplay,
@ -603,19 +591,16 @@ winClipboardFlushXEvents (HWND hwnd,
break; break;
} }
#if 0
{ {
char *pszAtomName = NULL; char *pszAtomName = NULL;
ErrorF ("SelectionNotify - returned data %d left %d\n", winDebug("SelectionNotify - returned data %d left %d\n",
xtpText.nitems, ulReturnBytesLeft); xtpText.nitems, ulReturnBytesLeft);
pszAtomName = XGetAtomName(pDisplay, xtpText.encoding); pszAtomName = XGetAtomName(pDisplay, xtpText.encoding);
ErrorF ("Notify atom name %s\n", pszAtomName); winDebug("Notify atom name %s\n", pszAtomName);
XFree (pszAtomName); XFree (pszAtomName);
pszAtomName = NULL; pszAtomName = NULL;
} }
#endif
if (fUseUnicode) if (fUseUnicode)
{ {
@ -816,7 +801,15 @@ winClipboardFlushXEvents (HWND hwnd,
SetClipboardData (CF_TEXT, NULL); SetClipboardData (CF_TEXT, NULL);
return WIN_XEVENTS_NOTIFY; return WIN_XEVENTS_NOTIFY;
case SelectionClear:
winDebug("SelectionClear - doing nothing\n");
break;
case PropertyNotify:
break;
default: default:
ErrorF ("winClipboardFlushXEvents - unexpected event type %d\n", event.type);
break; break;
} }
} }