summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2015-02-08 14:11:52 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2015-02-08 15:11:50 +0000
commitb9aa05a7f06d21218485bcdb08413aec2afdf618 (patch)
tree1070a3741495c548ec13ca86b3fd857dab942e3f
parent48f34ffbbb74f51394699f936edb5dbba6f112db (diff)
clipboard debug: Log clipboard owner HWND and window name when OpenClipboard() fails
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rw-r--r--hw/xwin/winclipboard/xevents.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c
index 32531f6c5..d196a7246 100644
--- a/hw/xwin/winclipboard/xevents.c
+++ b/hw/xwin/winclipboard/xevents.c
@@ -78,6 +78,18 @@ static const char *szSelectionNames[CLIP_NUM_SELECTIONS] =
static unsigned int lastOwnedSelectionIndex = CLIP_OWN_NONE;
+static const char *
+GetWindowName(HWND hWnd)
+{
+ static char *pBuf = NULL;
+ int len = GetWindowTextLength(hWnd);
+ len++;
+ pBuf = realloc(pBuf, len + 1);
+ GetWindowText(hWnd, pBuf, len);
+ pBuf[len] = 0;
+ return pBuf;
+}
+
static void
MonitorSelection(XFixesSelectionNotifyEvent * e, unsigned int i)
{
@@ -314,7 +326,7 @@ winClipboardFlushXEvents(HWND hwnd,
/* Access the clipboard */
if (!OpenClipboard(hwnd)) {
ErrorF("winClipboardFlushXEvents - SelectionRequest - "
- "OpenClipboard () failed: %08lx\n", GetLastError());
+ "OpenClipboard () failed: %08lx owner %p '%s'\n", GetLastError(), GetClipboardOwner(), GetWindowName(GetClipboardOwner()));
/* Abort */
fAbort = TRUE;
@@ -845,8 +857,8 @@ winClipboardFlushXEvents(HWND hwnd,
/* Access the Windows clipboard */
if (!OpenClipboard(hwnd)) {
- ErrorF("winClipboardFlushXEvents - OpenClipboard () failed: %08x\n",
- (int) GetLastError());
+ ErrorF("winClipboardFlushXEvents - OpenClipboard () failed: %08x Owner %p '%s'\n",
+ (int) GetLastError(), GetClipboardOwner(), GetWindowName(GetClipboardOwner()));
break;
}