From 3bee94c14161f34d8fc0c5a5e4ae63791e24d323 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 29 Oct 2025 13:20:57 +0100 Subject: [PATCH] [client,x11] log mouse event types and call stack --- client/X11/xf_event.c | 35 +++++++++++++++++++++++++++++------ client/X11/xf_event.h | 25 ++++++++++++++++++++----- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 1239487a9..1d726248d 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -55,6 +55,8 @@ (y) = 0; \ } while (0) +static const DWORD mouseLogLevel = WLOG_TRACE; + const char* x11_event_string(int event) { switch (event) @@ -425,10 +427,16 @@ static BOOL xf_event_VisibilityNotify(xfContext* xfc, const XVisibilityEvent* ev return TRUE; } -BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, Window window, BOOL app) +BOOL xf_generic_MotionNotify_(xfContext* xfc, int x, int y, Window window, BOOL app, + const char* file, const char* fkt, size_t line) { Window childWindow = None; + if (WLog_IsLevelActive(xfc->log, mouseLogLevel)) + WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt, + "%s: x=%d, y=%d, window=0x%08lx, app=%d", __func__, x, y, window, + app); + WINPR_ASSERT(xfc); WINPR_ASSERT(xfc->common.context.settings); @@ -455,11 +463,16 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, Window window, BOOL a return TRUE; } -BOOL xf_generic_RawMotionNotify(xfContext* xfc, int x, int y, WINPR_ATTR_UNUSED Window window, - BOOL app) +BOOL xf_generic_RawMotionNotify_(xfContext* xfc, int x, int y, WINPR_ATTR_UNUSED Window window, + BOOL app, const char* file, const char* fkt, size_t line) { WINPR_ASSERT(xfc); + if (WLog_IsLevelActive(xfc->log, mouseLogLevel)) + WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt, + "%s: x=%d, y=%d, window=0x%08lx, app=%d", __func__, x, y, window, + app); + if (app) { WLog_ERR(TAG, "Relative mouse input is not supported with remoate app mode!"); @@ -483,12 +496,17 @@ static BOOL xf_event_MotionNotify(xfContext* xfc, const XMotionEvent* event, BOO return xf_generic_MotionNotify(xfc, event->x, event->y, event->window, app); } -BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button, Window window, BOOL app, - BOOL down) +BOOL xf_generic_ButtonEvent_(xfContext* xfc, int x, int y, int button, Window window, BOOL app, + BOOL down, const char* file, const char* fkt, size_t line) { UINT16 flags = 0; Window childWindow = None; + if (WLog_IsLevelActive(xfc->log, mouseLogLevel)) + WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt, + "%s: x=%d, y=%d, button=%d, window=0x%08lx, app=%d, down=%d", + __func__, x, y, button, window, app, down); + WINPR_ASSERT(xfc); if (button < 0) return FALSE; @@ -1343,10 +1361,15 @@ BOOL xf_event_process(freerdp* instance, const XEvent* event) return status; } -BOOL xf_generic_RawButtonEvent(xfContext* xfc, int button, BOOL app, BOOL down) +BOOL xf_generic_RawButtonEvent_(xfContext* xfc, int button, BOOL app, BOOL down, const char* file, + const char* fkt, size_t line) { UINT16 flags = 0; + if (WLog_IsLevelActive(xfc->log, mouseLogLevel)) + WLog_PrintTextMessage(xfc->log, mouseLogLevel, line, file, fkt, + "%s: button=%d, app=%d, down=%d", __func__, button, app, down); + if (app || (button < 0)) return FALSE; diff --git a/client/X11/xf_event.h b/client/X11/xf_event.h index dc4a58753..778f73973 100644 --- a/client/X11/xf_event.h +++ b/client/X11/xf_event.h @@ -37,10 +37,25 @@ void xf_event_SendClientEvent(xfContext* xfc, xfWindow* window, Atom atom, unsig void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y); void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y); -BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, Window window, BOOL app); -BOOL xf_generic_RawMotionNotify(xfContext* xfc, int x, int y, Window window, BOOL app); -BOOL xf_generic_ButtonEvent(xfContext* xfc, int x, int y, int button, Window window, BOOL app, - BOOL down); -BOOL xf_generic_RawButtonEvent(xfContext* xfc, int button, BOOL app, BOOL down); +#define xf_generic_MotionNotify(xfc, x, y, window, app) \ + xf_generic_MotionNotify_((xfc), (x), (y), (window), (app), __FILE__, __func__, __LINE__) +BOOL xf_generic_MotionNotify_(xfContext* xfc, int x, int y, Window window, BOOL app, + const char* file, const char* fkt, size_t line); + +#define xf_generic_RawMotionNotify(xfc, x, y, window, app) \ + xf_generic_RawMotionNotify_((xfc), (x), (y), (window), (app), __FILE__, __func__, __LINE__) +BOOL xf_generic_RawMotionNotify_(xfContext* xfc, int x, int y, Window window, BOOL app, + const char* file, const char* fkt, size_t line); + +#define xf_generic_ButtonEvent(xfc, x, y, button, window, app, down) \ + xf_generic_ButtonEvent_((xfc), (x), (y), (button), (window), (app), (down), __FILE__, \ + __func__, __LINE__) +BOOL xf_generic_ButtonEvent_(xfContext* xfc, int x, int y, int button, Window window, BOOL app, + BOOL down, const char* file, const char* fkt, size_t line); + +#define xf_generic_RawButtonEvent(xfc, button, app, down) \ + xf_generic_RawButtonEvent_((xfc), (button), (app), (down), __FILE__, __func__, __LINE__) +BOOL xf_generic_RawButtonEvent_(xfContext* xfc, int button, BOOL app, BOOL down, const char* file, + const char* fkt, size_t line); #endif /* FREERDP_CLIENT_X11_EVENT_H */