From 56b50966a3bf73f0be80be80d4d27f31c3a685f2 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 25 Jul 2024 07:36:09 +0200 Subject: [PATCH] [client,x11] log all XInternAtom calls --- client/X11/xf_client.c | 86 ++++++++++++++++++++++++----------------- client/X11/xf_cliprdr.c | 39 +++++++++++-------- client/X11/xf_event.c | 6 ++- client/X11/xf_tsmf.c | 6 ++- client/X11/xf_utils.c | 11 ++++++ client/X11/xf_utils.h | 1 + client/X11/xfreerdp.h | 1 + 7 files changed, 94 insertions(+), 56 deletions(-) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 1f944d037..85d3560eb 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -1777,7 +1777,7 @@ static int xfreerdp_client_start(rdpContext* context) static Atom get_supported_atom(xfContext* xfc, const char* atomName) { - const Atom atom = XInternAtom(xfc->display, atomName, False); + const Atom atom = Logging_XInternAtom(xfc->log, xfc->display, atomName, False); for (unsigned long i = 0; i < xfc->supportedAtomCount; i++) { @@ -1871,8 +1871,9 @@ BOOL xf_setup_x11(xfContext* xfc) xfc->big_endian = (ImageByteOrder(xfc->display) == MSBFirst); xfc->invert = TRUE; xfc->complex_regions = TRUE; - xfc->_NET_SUPPORTED = XInternAtom(xfc->display, "_NET_SUPPORTED", True); - xfc->_NET_SUPPORTING_WM_CHECK = XInternAtom(xfc->display, "_NET_SUPPORTING_WM_CHECK", True); + xfc->_NET_SUPPORTED = Logging_XInternAtom(xfc->log, xfc->display, "_NET_SUPPORTED", True); + xfc->_NET_SUPPORTING_WM_CHECK = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_SUPPORTING_WM_CHECK", True); if ((xfc->_NET_SUPPORTED != None) && (xfc->_NET_SUPPORTING_WM_CHECK != None)) { @@ -1898,56 +1899,68 @@ BOOL xf_setup_x11(xfContext* xfc) } xfc->_XWAYLAND_MAY_GRAB_KEYBOARD = - XInternAtom(xfc->display, "_XWAYLAND_MAY_GRAB_KEYBOARD", False); - xfc->_NET_WM_ICON = XInternAtom(xfc->display, "_NET_WM_ICON", False); - xfc->_MOTIF_WM_HINTS = XInternAtom(xfc->display, "_MOTIF_WM_HINTS", False); - xfc->_NET_CURRENT_DESKTOP = XInternAtom(xfc->display, "_NET_CURRENT_DESKTOP", False); - xfc->_NET_WORKAREA = XInternAtom(xfc->display, "_NET_WORKAREA", False); + Logging_XInternAtom(xfc->log, xfc->display, "_XWAYLAND_MAY_GRAB_KEYBOARD", False); + xfc->_NET_WM_ICON = Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_ICON", False); + xfc->_MOTIF_WM_HINTS = Logging_XInternAtom(xfc->log, xfc->display, "_MOTIF_WM_HINTS", False); + xfc->_NET_CURRENT_DESKTOP = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_CURRENT_DESKTOP", False); + xfc->_NET_WORKAREA = Logging_XInternAtom(xfc->log, xfc->display, "_NET_WORKAREA", False); xfc->_NET_WM_STATE = get_supported_atom(xfc, "_NET_WM_STATE"); xfc->_NET_WM_STATE_FULLSCREEN = get_supported_atom(xfc, "_NET_WM_STATE_FULLSCREEN"); xfc->_NET_WM_STATE_MAXIMIZED_HORZ = - XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); xfc->_NET_WM_STATE_MAXIMIZED_VERT = - XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", False); xfc->_NET_WM_FULLSCREEN_MONITORS = get_supported_atom(xfc, "_NET_WM_FULLSCREEN_MONITORS"); - xfc->_NET_WM_NAME = XInternAtom(xfc->display, "_NET_WM_NAME", False); - xfc->_NET_WM_PID = XInternAtom(xfc->display, "_NET_WM_PID", False); - xfc->_NET_WM_WINDOW_TYPE = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE", False); + xfc->_NET_WM_NAME = Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_NAME", False); + xfc->_NET_WM_PID = Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_PID", False); + xfc->_NET_WM_WINDOW_TYPE = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_WINDOW_TYPE", False); xfc->_NET_WM_WINDOW_TYPE_NORMAL = - XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_NORMAL", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_WINDOW_TYPE_NORMAL", False); xfc->_NET_WM_WINDOW_TYPE_DIALOG = - XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_DIALOG", False); - xfc->_NET_WM_WINDOW_TYPE_POPUP = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_POPUP", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_WINDOW_TYPE_DIALOG", False); + xfc->_NET_WM_WINDOW_TYPE_POPUP = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_WINDOW_TYPE_POPUP", False); xfc->_NET_WM_WINDOW_TYPE_POPUP_MENU = - XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_POPUP_MENU", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_WINDOW_TYPE_POPUP_MENU", False); xfc->_NET_WM_WINDOW_TYPE_UTILITY = - XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_UTILITY", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_WINDOW_TYPE_UTILITY", False); xfc->_NET_WM_WINDOW_TYPE_DROPDOWN_MENU = - XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", False); xfc->_NET_WM_STATE_SKIP_TASKBAR = - XInternAtom(xfc->display, "_NET_WM_STATE_SKIP_TASKBAR", False); - xfc->_NET_WM_STATE_SKIP_PAGER = XInternAtom(xfc->display, "_NET_WM_STATE_SKIP_PAGER", False); - xfc->_NET_WM_MOVERESIZE = XInternAtom(xfc->display, "_NET_WM_MOVERESIZE", False); - xfc->_NET_MOVERESIZE_WINDOW = XInternAtom(xfc->display, "_NET_MOVERESIZE_WINDOW", False); - xfc->UTF8_STRING = XInternAtom(xfc->display, "UTF8_STRING", FALSE); - xfc->WM_PROTOCOLS = XInternAtom(xfc->display, "WM_PROTOCOLS", False); - xfc->WM_DELETE_WINDOW = XInternAtom(xfc->display, "WM_DELETE_WINDOW", False); - xfc->WM_STATE = XInternAtom(xfc->display, "WM_STATE", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_SKIP_TASKBAR", False); + xfc->_NET_WM_STATE_SKIP_PAGER = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_SKIP_PAGER", False); + xfc->_NET_WM_MOVERESIZE = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_MOVERESIZE", False); + xfc->_NET_MOVERESIZE_WINDOW = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_MOVERESIZE_WINDOW", False); + xfc->UTF8_STRING = Logging_XInternAtom(xfc->log, xfc->display, "UTF8_STRING", FALSE); + xfc->WM_PROTOCOLS = Logging_XInternAtom(xfc->log, xfc->display, "WM_PROTOCOLS", False); + xfc->WM_DELETE_WINDOW = Logging_XInternAtom(xfc->log, xfc->display, "WM_DELETE_WINDOW", False); + xfc->WM_STATE = Logging_XInternAtom(xfc->log, xfc->display, "WM_STATE", False); xfc->x11event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfc->xfds, WINPR_FD_READ); - xfc->NET_WM_ALLOWED_ACTIONS = XInternAtom(xfc->display, "_NET_WM_ALLOWED_ACTIONS", False); + xfc->NET_WM_ALLOWED_ACTIONS = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_ALLOWED_ACTIONS", False); - xfc->NET_WM_ACTION_CLOSE = XInternAtom(xfc->display, "_NET_WM_ACTION_CLOSE", False); - xfc->NET_WM_ACTION_MINIMIZE = XInternAtom(xfc->display, "_NET_WM_ACTION_MINIMIZE", False); - xfc->NET_WM_ACTION_MOVE = XInternAtom(xfc->display, "_NET_WM_ACTION_MOVE", False); - xfc->NET_WM_ACTION_RESIZE = XInternAtom(xfc->display, "_NET_WM_ACTION_RESIZE", False); + xfc->NET_WM_ACTION_CLOSE = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_ACTION_CLOSE", False); + xfc->NET_WM_ACTION_MINIMIZE = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_ACTION_MINIMIZE", False); + xfc->NET_WM_ACTION_MOVE = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_ACTION_MOVE", False); + xfc->NET_WM_ACTION_RESIZE = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_ACTION_RESIZE", False); xfc->NET_WM_ACTION_MAXIMIZE_HORZ = - XInternAtom(xfc->display, "_NET_WM_ACTION_MAXIMIZE_HORZ", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_ACTION_MAXIMIZE_HORZ", False); xfc->NET_WM_ACTION_MAXIMIZE_VERT = - XInternAtom(xfc->display, "_NET_WM_ACTION_MAXIMIZE_VERT", False); - xfc->NET_WM_ACTION_FULLSCREEN = XInternAtom(xfc->display, "_NET_WM_ACTION_FULLSCREEN", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_ACTION_MAXIMIZE_VERT", False); + xfc->NET_WM_ACTION_FULLSCREEN = + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_ACTION_FULLSCREEN", False); xfc->NET_WM_ACTION_CHANGE_DESKTOP = - XInternAtom(xfc->display, "_NET_WM_ACTION_CHANGE_DESKTOP", False); + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_ACTION_CHANGE_DESKTOP", False); if (!xfc->x11event) { @@ -1987,6 +2000,7 @@ static BOOL xfreerdp_client_new(freerdp* instance, rdpContext* context) PubSub_SubscribeZoomingChange(context->pubSub, xf_ZoomingChangeEventHandler); PubSub_SubscribePanningChange(context->pubSub, xf_PanningChangeEventHandler); #endif + xfc->log = WLog_Get(TAG); return TRUE; } diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 931abcbd9..8723c381d 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -2331,7 +2331,7 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) if (!selectionAtom) selectionAtom = "CLIPBOARD"; - clipboard->clipboard_atom = XInternAtom(xfc->display, selectionAtom, FALSE); + clipboard->clipboard_atom = Logging_XInternAtom(xfc->log, xfc->display, selectionAtom, FALSE); if (clipboard->clipboard_atom == None) { @@ -2340,10 +2340,13 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) } clipboard->timestamp_property_atom = - XInternAtom(xfc->display, "_FREERDP_TIMESTAMP_PROPERTY", FALSE); - clipboard->property_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR", FALSE); - clipboard->raw_transfer_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR_RAW", FALSE); - clipboard->raw_format_list_atom = XInternAtom(xfc->display, "_FREERDP_CLIPRDR_FORMATS", FALSE); + Logging_XInternAtom(xfc->log, xfc->display, "_FREERDP_TIMESTAMP_PROPERTY", FALSE); + clipboard->property_atom = + Logging_XInternAtom(xfc->log, xfc->display, "_FREERDP_CLIPRDR", FALSE); + clipboard->raw_transfer_atom = + Logging_XInternAtom(xfc->log, xfc->display, "_FREERDP_CLIPRDR_RAW", FALSE); + clipboard->raw_format_list_atom = + Logging_XInternAtom(xfc->log, xfc->display, "_FREERDP_CLIPRDR_FORMATS", FALSE); xf_cliprdr_set_raw_transfer_enabled(clipboard, TRUE); XSelectInput(xfc->display, clipboard->root_window, PropertyChangeMask); #ifdef WITH_XFIXES @@ -2377,11 +2380,11 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) "Warning: Using clipboard redirection without XFIXES extension is strongly discouraged!"); #endif clientFormat = &clipboard->clientFormats[n++]; - clientFormat->atom = XInternAtom(xfc->display, "_FREERDP_RAW", False); + clientFormat->atom = Logging_XInternAtom(xfc->log, xfc->display, "_FREERDP_RAW", False); clientFormat->localFormat = clientFormat->formatToRequest = CF_RAW; clientFormat = &clipboard->clientFormats[n++]; - clientFormat->atom = XInternAtom(xfc->display, "UTF8_STRING", False); + clientFormat->atom = Logging_XInternAtom(xfc->log, xfc->display, "UTF8_STRING", False); clientFormat->formatToRequest = CF_UNICODETEXT; clientFormat->localFormat = ClipboardGetFormatId(xfc->clipboard->system, mime_text_plain); @@ -2391,7 +2394,7 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) clientFormat->localFormat = ClipboardGetFormatId(xfc->clipboard->system, mime_text_plain); clientFormat = &clipboard->clientFormats[n++]; - clientFormat->atom = XInternAtom(xfc->display, mime_tiff, False); + clientFormat->atom = Logging_XInternAtom(xfc->log, xfc->display, mime_tiff, False); clientFormat->formatToRequest = clientFormat->localFormat = CF_TIFF; for (size_t x = 0; x < ARRAYSIZE(mime_bitmap); x++) @@ -2407,7 +2410,7 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) WLog_DBG(TAG, "register local bitmap format %s [0x%08" PRIx32 "]", mime_bmp, format); clientFormat = &clipboard->clientFormats[n++]; clientFormat->localFormat = format; - clientFormat->atom = XInternAtom(xfc->display, mime_bmp, False); + clientFormat->atom = Logging_XInternAtom(xfc->log, xfc->display, mime_bmp, False); clientFormat->formatToRequest = CF_DIB; } @@ -2424,12 +2427,12 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) WLog_DBG(TAG, "register local bitmap format %s [0x%08" PRIx32 "]", mime_bmp, format); clientFormat = &clipboard->clientFormats[n++]; clientFormat->localFormat = format; - clientFormat->atom = XInternAtom(xfc->display, mime_bmp, False); + clientFormat->atom = Logging_XInternAtom(xfc->log, xfc->display, mime_bmp, False); clientFormat->formatToRequest = CF_DIB; } clientFormat = &clipboard->clientFormats[n++]; - clientFormat->atom = XInternAtom(xfc->display, mime_html, False); + clientFormat->atom = Logging_XInternAtom(xfc->log, xfc->display, mime_html, False); clientFormat->formatToRequest = ClipboardGetFormatId(xfc->clipboard->system, type_HtmlFormat); clientFormat->localFormat = ClipboardGetFormatId(xfc->clipboard->system, mime_html); clientFormat->formatName = _strdup(type_HtmlFormat); @@ -2450,7 +2453,7 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) if (uid) { cliprdr_file_context_set_locally_available(clipboard->file, TRUE); - clientFormat->atom = XInternAtom(xfc->display, mime_uri_list, False); + clientFormat->atom = Logging_XInternAtom(xfc->log, xfc->display, mime_uri_list, False); clientFormat->localFormat = uid; clientFormat->formatToRequest = fgid; clientFormat->formatName = _strdup(type_FileGroupDescriptorW); @@ -2465,7 +2468,8 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) if (gid != 0) { cliprdr_file_context_set_locally_available(clipboard->file, TRUE); - clientFormat->atom = XInternAtom(xfc->display, mime_gnome_copied_files, False); + clientFormat->atom = + Logging_XInternAtom(xfc->log, xfc->display, mime_gnome_copied_files, False); clientFormat->localFormat = gid; clientFormat->formatToRequest = fgid; clientFormat->formatName = _strdup(type_FileGroupDescriptorW); @@ -2480,7 +2484,8 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) if (mid != 0) { cliprdr_file_context_set_locally_available(clipboard->file, TRUE); - clientFormat->atom = XInternAtom(xfc->display, mime_mate_copied_files, False); + clientFormat->atom = + Logging_XInternAtom(xfc->log, xfc->display, mime_mate_copied_files, False); clientFormat->localFormat = mid; clientFormat->formatToRequest = fgid; clientFormat->formatName = _strdup(type_FileGroupDescriptorW); @@ -2490,10 +2495,10 @@ xfClipboard* xf_clipboard_new(xfContext* xfc, BOOL relieveFilenameRestriction) } clipboard->numClientFormats = n; - clipboard->targets[0] = XInternAtom(xfc->display, "TIMESTAMP", FALSE); - clipboard->targets[1] = XInternAtom(xfc->display, "TARGETS", FALSE); + clipboard->targets[0] = Logging_XInternAtom(xfc->log, xfc->display, "TIMESTAMP", FALSE); + clipboard->targets[1] = Logging_XInternAtom(xfc->log, xfc->display, "TARGETS", FALSE); clipboard->numTargets = 2; - clipboard->incr_atom = XInternAtom(xfc->display, "INCR", FALSE); + clipboard->incr_atom = Logging_XInternAtom(xfc->log, xfc->display, "INCR", FALSE); if (relieveFilenameRestriction) { diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 993988d54..8b03ba616 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -959,14 +959,16 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event, for (unsigned long i = 0; i < nitems; i++) { if ((Atom)((UINT16**)prop)[i] == - XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", False)) + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", + False)) { if (appWindow) appWindow->maxVert = TRUE; } if ((Atom)((UINT16**)prop)[i] == - XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False)) + Logging_XInternAtom(xfc->log, xfc->display, "_NET_WM_STATE_MAXIMIZED_HORZ", + False)) { if (appWindow) appWindow->maxHorz = TRUE; diff --git a/client/X11/xf_tsmf.c b/client/X11/xf_tsmf.c index 1c5e5b36d..b54fd0188 100644 --- a/client/X11/xf_tsmf.c +++ b/client/X11/xf_tsmf.c @@ -33,6 +33,7 @@ #include #include "xf_tsmf.h" +#include "xf_utils.h" #ifdef WITH_XV @@ -382,7 +383,10 @@ static int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf) { if (strcmp(attr[i].name, "XV_COLORKEY") == 0) { - xv->xv_colorkey_atom = XInternAtom(xfc->display, "XV_COLORKEY", FALSE); + static wLog* log = NULL; + if (!log) + log = WLog_Get(TAG); + xv->xv_colorkey_atom = Logging_XInternAtom(log, xfc->display, "XV_COLORKEY", FALSE); XvSetPortAttribute(xfc->display, xv->xv_port, xv->xv_colorkey_atom, attr[i].min_value + 1); break; diff --git a/client/X11/xf_utils.c b/client/X11/xf_utils.c index 7240abbb9..180a30991 100644 --- a/client/X11/xf_utils.c +++ b/client/X11/xf_utils.c @@ -42,6 +42,17 @@ char* Safe_XGetAtomName(wLog* log, Display* display, Atom atom) return XGetAtomName(display, atom); } +Atom Logging_XInternAtom(wLog* log, Display* display, _Xconst char* atom_name, Bool only_if_exists) +{ + Atom atom = XInternAtom(display, atom_name, only_if_exists); + if (WLog_IsLevelActive(log, log_level)) + { + WLog_Print(log, log_level, "XInternAtom(0x%08" PRIx32 ", %s, %s) -> 0x%08" PRIx32, display, + atom_name, only_if_exists, atom); + } + return atom; +} + int LogTagAndXChangeProperty_ex(const char* tag, const char* file, const char* fkt, size_t line, Display* display, Window w, Atom property, Atom type, int format, int mode, const unsigned char* data, int nelements) diff --git a/client/X11/xf_utils.h b/client/X11/xf_utils.h index 95d849ebd..4eb16188c 100644 --- a/client/X11/xf_utils.h +++ b/client/X11/xf_utils.h @@ -25,6 +25,7 @@ #include char* Safe_XGetAtomName(wLog* log, Display* display, Atom atom); +Atom Logging_XInternAtom(wLog* log, Display* display, _Xconst char* atom_name, Bool only_if_exists); #define LogTagAndXGetWindowProperty(tag, display, w, property, long_offset, long_length, delete, \ req_type, actual_type_return, actual_format_return, \ diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 8763a1a49..eb733ec7b 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -306,6 +306,7 @@ struct xf_context BOOL xi_rawevent; BOOL xi_event; HANDLE pipethread; + wLog* log; }; BOOL xf_create_window(xfContext* xfc);