From 11d9b74b61492503e6a39346b8d171d4cf18b811 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 17 Dec 2019 21:49:57 +0100 Subject: Events.c: improve debugging output Extend nxagentHandleClientMessageEvent: better debug messages, suppress warning "Invalid window in ClientMessage" for legal case. I came across this while testing some clipboard stuff. --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 32 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index b9d3a9238..859a01bf4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -2578,11 +2578,6 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) { *result = doNothing; - #ifdef TEST - fprintf(stderr, "%s: ClientMessage event window [%ld] with type [%ld] format [%d].\n", - __func__, X -> xclient.window, X -> xclient.message_type, X -> xclient.format); - #endif - /* * If window is 0, message_type is 0 and format is 32 then we assume * event is coming from proxy. @@ -2592,11 +2587,25 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) X -> xclient.message_type == 0 && X -> xclient.format == 32) { + #ifdef TEST + fprintf(stderr, "%s: got nxproxy event\n", __func__); + #endif nxagentHandleProxyEvent(X); return 1; } + #ifdef TEST + char * name = XGetAtomName(nxagentDisplay, X -> xclient.message_type); + fprintf(stderr, "nxagentHandleClientMessageEvent: ClientMessage event window [0x%lx] with " + "message_type [%ld][%s] format [%d] type [%d] source_indication [%ld][%s] timestamp [%ld] " + "curwin [0x%lx].\n", X -> xclient.window, X -> xclient.message_type, name, + X -> xclient.format, X -> xclient.type, X -> xclient.data.l[0], + X -> xclient.data.l[0] == 1 ? "'application'" : X -> xclient.data.l[0] == 1 ? "'pager'" : "'none (old spec)'", + X -> xclient.data.l[1], X -> xclient.data.l[2]); + SAFE_XFree(name); + #endif + if (nxagentOption(Rootless)) { Atom message_type = nxagentRemoteToLocalAtom(X -> xclient.message_type); @@ -2611,11 +2620,20 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) } WindowPtr pWin = nxagentWindowPtr(X -> xclient.window); - if (pWin == NULL) { + /* + * If some window on the real X server sends a + * _NET_ACTIVE_WINDOW ClientMessage to indicate the active + * window that window will be one not belonging to nxagent so + * this situation is perfectly legal. For all other situations + * we print a warning. + */ #ifdef WARNING - fprintf(stderr, "WARNING: Invalid window in ClientMessage.\n"); + if (message_type != MakeAtom("_NET_ACTIVE_WINDOW", strlen("_NET_ACTIVE_WINDOW"), False)) + { + fprintf(stderr, "WARNING: Invalid window in ClientMessage xclient.window [0x%lx].\n", X->xclient.window); + } #endif return 0; -- cgit v1.2.3