From 357a92ce5530b216e92892ff7d0c02f494adc163 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 28 Jun 2024 09:16:48 +0200 Subject: [PATCH] [client,X11] log atom numbers passed to XGetAtomName --- client/X11/xf_cliprdr.c | 19 +++++++++++-------- client/X11/xf_input.c | 15 ++++++++++----- client/X11/xf_utils.c | 13 +++++++------ client/X11/xf_utils.h | 2 +- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 30a8d4511..90586602a 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -1126,7 +1126,8 @@ static void log_selection_event(xfContext* xfc, const XEvent* event) case SelectionClear: { const XSelectionClearEvent* xevent = &event->xselectionclear; - char* selection = Safe_XGetAtomName(xfc->display, xevent->selection); + char* selection = + Safe_XGetAtomName(_log_cached_ptr, xfc->display, xevent->selection); WLog_Print(_log_cached_ptr, level, "got event %s [selection %s]", x11_event_string(event->type), selection); XFree(selection); @@ -1135,9 +1136,10 @@ static void log_selection_event(xfContext* xfc, const XEvent* event) case SelectionNotify: { const XSelectionEvent* xevent = &event->xselection; - char* selection = Safe_XGetAtomName(xfc->display, xevent->selection); - char* target = Safe_XGetAtomName(xfc->display, xevent->target); - char* property = Safe_XGetAtomName(xfc->display, xevent->property); + char* selection = + Safe_XGetAtomName(_log_cached_ptr, xfc->display, xevent->selection); + char* target = Safe_XGetAtomName(_log_cached_ptr, xfc->display, xevent->target); + char* property = Safe_XGetAtomName(_log_cached_ptr, xfc->display, xevent->property); WLog_Print(_log_cached_ptr, level, "got event %s [selection %s, target %s, property %s]", x11_event_string(event->type), selection, target, property); @@ -1149,9 +1151,10 @@ static void log_selection_event(xfContext* xfc, const XEvent* event) case SelectionRequest: { const XSelectionRequestEvent* xevent = &event->xselectionrequest; - char* selection = Safe_XGetAtomName(xfc->display, xevent->selection); - char* target = Safe_XGetAtomName(xfc->display, xevent->target); - char* property = Safe_XGetAtomName(xfc->display, xevent->property); + char* selection = + Safe_XGetAtomName(_log_cached_ptr, xfc->display, xevent->selection); + char* target = Safe_XGetAtomName(_log_cached_ptr, xfc->display, xevent->target); + char* property = Safe_XGetAtomName(_log_cached_ptr, xfc->display, xevent->property); WLog_Print(_log_cached_ptr, level, "got event %s [selection %s, target %s, property %s]", x11_event_string(event->type), selection, target, property); @@ -1163,7 +1166,7 @@ static void log_selection_event(xfContext* xfc, const XEvent* event) case PropertyNotify: { const XPropertyEvent* xevent = &event->xproperty; - char* atom = Safe_XGetAtomName(xfc->display, xevent->atom); + char* atom = Safe_XGetAtomName(_log_cached_ptr, xfc->display, xevent->atom); WLog_Print(_log_cached_ptr, level, "got event %s [atom %s]", x11_event_string(event->type), atom); XFree(atom); diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index dfbe051f5..fd5514a85 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -36,6 +36,7 @@ #include "xf_event.h" #include "xf_input.h" +#include "xf_utils.h" #include #include @@ -133,12 +134,16 @@ static BOOL register_input_events(xfContext* xfc, Window window) } case XIValuatorClass: { - const XIValuatorClassInfo* t = (const XIValuatorClassInfo*)class; - char* name = t->label ? XGetAtomName(xfc->display, t->label) : NULL; + static wLog* log = NULL; + if (!log) + log = WLog_Get(TAG); - WLog_DBG(TAG, "%s device (id: %d) valuator %d label %s range %f - %f", - dev->name, dev->deviceid, t->number, name ? name : "None", t->min, - t->max); + const XIValuatorClassInfo* t = (const XIValuatorClassInfo*)class; + char* name = t->label ? Safe_XGetAtomName(log, xfc->display, t->label) : NULL; + + WLog_Print(log, WLOG_DEBUG, + "%s device (id: %d) valuator %d label %s range %f - %f", dev->name, + dev->deviceid, t->number, name ? name : "None", t->min, t->max); free(name); if (t->number == 2) diff --git a/client/X11/xf_utils.c b/client/X11/xf_utils.c index 4cce7c1bb..28d9f9966 100644 --- a/client/X11/xf_utils.c +++ b/client/X11/xf_utils.c @@ -32,8 +32,9 @@ static void write_log(wLog* log, DWORD level, const char* fname, const char* fkt va_end(ap); } -char* Safe_XGetAtomName(Display* display, Atom atom) +char* Safe_XGetAtomName(wLog* log, Display* display, Atom atom) { + WLog_Print(log, log_level, "XGetAtomName(0x%08" PRIx32 ")", atom); if (atom == None) return strdup("Atom_None"); return XGetAtomName(display, atom); @@ -54,8 +55,8 @@ int LogDynAndXChangeProperty_ex(wLog* log, const char* file, const char* fkt, si { if (WLog_IsLevelActive(log, log_level)) { - char* propstr = Safe_XGetAtomName(display, property); - char* typestr = Safe_XGetAtomName(display, type); + char* propstr = Safe_XGetAtomName(log, display, property); + char* typestr = Safe_XGetAtomName(log, display, type); write_log(log, log_level, file, fkt, line, "XChangeProperty(%p, %d, %s [%d], %s [%d], %d, %d, %p, %d)", display, w, propstr, property, typestr, type, format, mode, data, nelements); @@ -77,7 +78,7 @@ int LogDynAndXDeleteProperty_ex(wLog* log, const char* file, const char* fkt, si { if (WLog_IsLevelActive(log, log_level)) { - char* propstr = Safe_XGetAtomName(display, property); + char* propstr = Safe_XGetAtomName(log, display, property); write_log(log, log_level, file, fkt, line, "XDeleteProperty(%p, %d, %s [%d])", display, w, propstr, property); XFree(propstr); @@ -107,8 +108,8 @@ int LogDynAndXGetWindowProperty_ex(wLog* log, const char* file, const char* fkt, { if (WLog_IsLevelActive(log, log_level)) { - char* propstr = Safe_XGetAtomName(display, property); - char* req_type_str = Safe_XGetAtomName(display, req_type); + char* propstr = Safe_XGetAtomName(log, display, property); + char* req_type_str = Safe_XGetAtomName(log, display, req_type); write_log(log, log_level, file, fkt, line, "XGetWindowProperty(%p, %d, %s [%d], %ld, %ld, %d, %s [%d], %p, %p, %p, %p, %p)", display, w, propstr, property, long_offset, long_length, delete, req_type_str, diff --git a/client/X11/xf_utils.h b/client/X11/xf_utils.h index f94655467..f72d55aa8 100644 --- a/client/X11/xf_utils.h +++ b/client/X11/xf_utils.h @@ -23,7 +23,7 @@ #include -char* Safe_XGetAtomName(Display* display, Atom atom); +char* Safe_XGetAtomName(wLog* log, Display* display, Atom atom); #define LogTagAndXGetWindowProperty(tag, display, w, property, long_offset, long_length, delete, \ req_type, actual_type_return, actual_format_return, \