diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2009-11-01 18:18:51 +0000 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2009-11-09 20:33:38 +0000 |
commit | 9657eae5d65eff289089afc46dfb629758ebbdf7 (patch) | |
tree | d314363a285cd0f27dd971ae323c46116c2c0a96 | |
parent | 062f49a8e0d1afb4dd32e9451a47ab2792639e7f (diff) |
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>
-rw-r--r-- | hw/xwin/winclipboardtextconv.c | 8 | ||||
-rw-r--r-- | hw/xwin/winclipboardwndproc.c | 8 | ||||
-rwxr-xr-x | hw/xwin/winclipboardwrappers.c | 49 | ||||
-rw-r--r-- | hw/xwin/winclipboardxevents.c | 67 |
4 files changed, 54 insertions, 78 deletions
diff --git a/hw/xwin/winclipboardtextconv.c b/hw/xwin/winclipboardtextconv.c index fd2e696c3..400f560fa 100644 --- a/hw/xwin/winclipboardtextconv.c +++ b/hw/xwin/winclipboardtextconv.c @@ -84,9 +84,7 @@ winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength) unsigned char *pszEnd = pszSrc + iLength; unsigned char *pszDest = NULL, *pszDestBegin = NULL; -#if 0 - ErrorF ("UNIXtoDOS () - Original data:\n%s\n", *ppszData); -#endif + winDebug("UNIXtoDOS () - Original data:'%s'\n", *ppszData); /* Count \n characters without leading \r */ while (pszSrc < pszEnd) @@ -153,7 +151,5 @@ winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength) free (*ppszData); *ppszData = pszDestBegin; -#if 0 - ErrorF ("UNIXtoDOS () - Final string:\n%s\n", pszDestBegin); -#endif + winDebug("UNIXtoDOS () - Final string:'%s'\n", pszDestBegin); } diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c index 292ca872b..9394b04db 100644 --- a/hw/xwin/winclipboardwndproc.c +++ b/hw/xwin/winclipboardwndproc.c @@ -104,13 +104,13 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay, if (tv.tv_sec < 0) 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 */ &fdsRead, /* Read mask */ NULL, /* No write mask */ NULL, /* No exception mask */ &tv); /* No timeout */ - if (iReturn <= 0) + if (iReturn < 0) { ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d. " "Bailing.\n", iReturn); @@ -440,9 +440,9 @@ winClipboardWindowProc (HWND hwnd, UINT message, * follow this message and reassert ownership of the X11 * selections, handling the issue for us. */ + winDebug ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - Ignored.\n"); return 0; - case WM_RENDERFORMAT: case WM_RENDERALLFORMATS: { @@ -536,6 +536,8 @@ winClipboardWindowProc (HWND hwnd, UINT message, if (g_fUnicodeSupport) SetClipboardData (CF_UNICODETEXT, 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 diff --git a/hw/xwin/winclipboardwrappers.c b/hw/xwin/winclipboardwrappers.c index c68d78aa3..658d050d2 100755 --- a/hw/xwin/winclipboardwrappers.c +++ b/hw/xwin/winclipboardwrappers.c @@ -324,9 +324,7 @@ winProcSetSelectionOwner (ClientPtr client) REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); -#if 0 - ErrorF ("winProcSetSelectionOwner - Hello.\n"); -#endif + winDebug("winProcSetSelectionOwner - Hello.\n"); /* Watch for server reset */ if (s_ulServerGeneration != serverGeneration) @@ -369,10 +367,8 @@ winProcSetSelectionOwner (ClientPtr client) { fOwnedToNotOwned = TRUE; -#if 0 - ErrorF ("winProcSetSelectionOwner - PRIMARY - Going from " + winDebug("winProcSetSelectionOwner - PRIMARY - Going from " "owned to not owned.\n"); -#endif /* Adjust last owned selection */ if (None != s_iOwners[CLIP_OWN_CLIPBOARD]) @@ -384,10 +380,8 @@ winProcSetSelectionOwner (ClientPtr client) /* Save new selection owner or None */ s_iOwners[CLIP_OWN_PRIMARY] = stuff->window; -#if 0 - ErrorF ("winProcSetSelectionOwner - PRIMARY - Now owned by: %d\n", + winDebug("winProcSetSelectionOwner - PRIMARY - Now owned by: %d\n", stuff->window); -#endif } else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection) { @@ -396,11 +390,9 @@ winProcSetSelectionOwner (ClientPtr client) && None != s_iOwners[CLIP_OWN_CLIPBOARD]) { fOwnedToNotOwned = TRUE; - -#if 0 - ErrorF ("winProcSetSelectionOwner - CLIPBOARD - Going from " - "owned to not owned.\n"); -#endif + + winDebug("winProcSetSelectionOwner - CLIPBOARD - Going from " + "owned to not owned.\n"); /* Adjust last owned selection */ if (None != s_iOwners[CLIP_OWN_PRIMARY]) @@ -412,10 +404,9 @@ winProcSetSelectionOwner (ClientPtr client) /* Save new selection owner or None */ s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window; -#if 0 - ErrorF ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: %d\n", - stuff->window); -#endif + winDebug("winProcSetSelectionOwner - CLIPBOARD - Now owned by: %d\n", + stuff->window); + } else goto winProcSetSelectionOwner_Done; @@ -444,13 +435,11 @@ winProcSetSelectionOwner (ClientPtr client) && g_hwndClipboard != NULL && g_hwndClipboard == GetClipboardOwner ()) { -#if 0 - ErrorF ("winProcSetSelectionOwner - We currently own the " - "clipboard and neither the PRIMARY nor the CLIPBOARD " - "selections are owned, releasing ownership of Win32 " - "clipboard.\n"); -#endif - + winDebug("winProcSetSelectionOwner - We currently own the " + "clipboard and neither the PRIMARY nor the CLIPBOARD " + "selections are owned, releasing ownership of Win32 " + "clipboard.\n"); + /* Release ownership of the Windows clipboard */ OpenClipboard (NULL); EmptyClipboard (); @@ -462,9 +451,7 @@ winProcSetSelectionOwner (ClientPtr client) /* Abort if no window at this point */ if (None == stuff->window) { -#if 0 - ErrorF ("winProcSetSelectionOwner - No window, returning.\n"); -#endif + winDebug("winProcSetSelectionOwner - No window, returning.\n"); goto winProcSetSelectionOwner_Done; } @@ -481,10 +468,8 @@ winProcSetSelectionOwner (ClientPtr client) /* Abort if clipboard manager is owning the selection */ if (pDrawable->id == g_iClipboardWindow) { -#if 0 - ErrorF ("winProcSetSelectionOwner - We changed ownership, " - "aborting.\n"); -#endif + winDebug("winProcSetSelectionOwner - We changed ownership, " + "aborting.\n"); goto winProcSetSelectionOwner_Done; } diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c index ec40814db..fee50f63d 100644 --- a/hw/xwin/winclipboardxevents.c +++ b/hw/xwin/winclipboardxevents.c @@ -105,20 +105,17 @@ winClipboardFlushXEvents (HWND hwnd, */ case SelectionRequest: -#if 0 { char *pszAtomName = NULL; - - ErrorF ("SelectionRequest - target %d\n", - event.xselectionrequest.target); - + winDebug("SelectionRequest - target %d\n", + event.xselectionrequest.target); + pszAtomName = XGetAtomName (pDisplay, event.xselectionrequest.target); - ErrorF ("SelectionRequest - Target atom name %s\n", pszAtomName); + winDebug("SelectionRequest - Target atom name %s\n", pszAtomName); XFree (pszAtomName); pszAtomName = NULL; } -#endif /* Abort if invalid target type */ if (event.xselectionrequest.target != XA_STRING @@ -466,21 +463,17 @@ winClipboardFlushXEvents (HWND hwnd, */ case SelectionNotify: -#if 0 - ErrorF ("winClipboardFlushXEvents - SelectionNotify\n"); + + winDebug ("winClipboardFlushXEvents - SelectionNotify\n"); { char *pszAtomName; - pszAtomName = XGetAtomName (pDisplay, event.xselection.selection); - ErrorF ("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n", - pszAtomName); - + winDebug("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n", + pszAtomName); XFree (pszAtomName); } -#endif - /* * Request conversion of UTF8 and CompoundText targets. @@ -489,18 +482,16 @@ winClipboardFlushXEvents (HWND hwnd, { if (event.xselection.target == XA_STRING) { -#if 0 - ErrorF ("winClipboardFlushXEvents - SelectionNotify - " - "XA_STRING\n"); -#endif + winDebug ("winClipboardFlushXEvents - SelectionNotify - " + "XA_STRING\n"); + return WIN_XEVENTS_CONVERT; } else if (event.xselection.target == atomUTF8String) { -#if 0 - ErrorF ("winClipboardFlushXEvents - SelectionNotify - " - "Requesting conversion of UTF8 target.\n"); -#endif + winDebug("winClipboardFlushXEvents - SelectionNotify - " + "Requesting conversion of UTF8 target.\n"); + iReturn = XConvertSelection (pDisplay, event.xselection.selection, XA_STRING, @@ -523,10 +514,9 @@ winClipboardFlushXEvents (HWND hwnd, #ifdef X_HAVE_UTF8_STRING else if (event.xselection.target == atomCompoundText) { -#if 0 - ErrorF ("winClipboardFlushXEvents - SelectionNotify - " - "Requesting conversion of CompoundText target.\n"); -#endif + winDebug("winClipboardFlushXEvents - SelectionNotify - " + "Requesting conversion of CompoundText target.\n"); + iReturn = XConvertSelection (pDisplay, event.xselection.selection, atomUTF8String, @@ -577,10 +567,8 @@ winClipboardFlushXEvents (HWND hwnd, break; } -#if 0 - ErrorF ("SelectionNotify - returned data %d left %d\n", - xtpText.nitems, ulReturnBytesLeft); -#endif + winDebug("SelectionNotify - returned data %d left %d\n", + xtpText.nitems, ulReturnBytesLeft); /* Request the selection data */ iReturn = XGetWindowProperty (pDisplay, @@ -603,19 +591,16 @@ winClipboardFlushXEvents (HWND hwnd, break; } -#if 0 { char *pszAtomName = NULL; - ErrorF ("SelectionNotify - returned data %d left %d\n", - xtpText.nitems, ulReturnBytesLeft); - + winDebug("SelectionNotify - returned data %d left %d\n", + xtpText.nitems, ulReturnBytesLeft); pszAtomName = XGetAtomName(pDisplay, xtpText.encoding); - ErrorF ("Notify atom name %s\n", pszAtomName); + winDebug("Notify atom name %s\n", pszAtomName); XFree (pszAtomName); pszAtomName = NULL; } -#endif if (fUseUnicode) { @@ -816,7 +801,15 @@ winClipboardFlushXEvents (HWND hwnd, SetClipboardData (CF_TEXT, NULL); return WIN_XEVENTS_NOTIFY; + case SelectionClear: + winDebug("SelectionClear - doing nothing\n"); + break; + + case PropertyNotify: + break; + default: + ErrorF ("winClipboardFlushXEvents - unexpected event type %d\n", event.type); break; } } |