From 1b1a7d35ecd4f6a5e433c841680e1eed5d223a20 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 22 May 2025 19:47:41 +0200 Subject: [PATCH] [client,x11] log XFlush --- client/X11/xf_client.c | 4 ++-- client/X11/xf_cliprdr.c | 10 +++++----- client/X11/xf_rail.c | 2 +- client/X11/xf_utils.c | 19 +++++++++++++++++++ client/X11/xf_utils.h | 5 +++++ client/X11/xf_window.c | 6 +++--- 6 files changed, 35 insertions(+), 11 deletions(-) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 22d8c7fe5..dc3e436aa 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -471,7 +471,7 @@ static BOOL xf_end_paint(rdpContext* context) return FALSE; } - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); xf_unlock_x11(xfc); } @@ -716,7 +716,7 @@ BOOL xf_create_window(xfContext* xfc) XFillRectangle(xfc->display, xfc->primary, xfc->gc, 0, 0, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth), freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight)); - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); return TRUE; } diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 3fb7f6d1c..401e43db7 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -1645,7 +1645,7 @@ static BOOL xf_cliprdr_process_selection_request(xfClipboard* clipboard, conv.sev = respond; LogDynAndXSendEvent(xfc->log, xfc->display, xevent->requestor, 0, 0, conv.ev); - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); free(respond); } @@ -1954,7 +1954,7 @@ static void xf_cliprdr_prepare_to_set_selection_owner(xfContext* xfc, xfClipboar LogTagAndXChangeProperty(TAG, xfc->display, xfc->drawable, clipboard->timestamp_property_atom, XA_ATOM, 32, PropModeReplace, (const BYTE*)&value, 1); - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); } static void xf_cliprdr_set_selection_owner(xfContext* xfc, xfClipboard* clipboard, Time timestamp) @@ -1968,7 +1968,7 @@ static void xf_cliprdr_set_selection_owner(xfContext* xfc, xfClipboard* clipboar clipboard->selection_ownership_timestamp = timestamp; XSetSelectionOwner(xfc->display, clipboard->clipboard_atom, xfc->drawable, timestamp); - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); } /** @@ -2143,7 +2143,7 @@ xf_cliprdr_server_format_data_request(CliprdrClientContext* context, format->localFormat, format->formatName); LogTagAndXConvertSelection(TAG, xfc->display, clipboard->clipboard_atom, format->atom, clipboard->property_atom, xfc->drawable, CurrentTime); - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); /* After this point, we expect a SelectionNotify event from the clipboard owner. */ return CHANNEL_RC_OK; } @@ -2370,7 +2370,7 @@ xf_cliprdr_server_format_data_response(CliprdrClientContext* context, conv.sev = clipboard->respond; LogDynAndXSendEvent(xfc->log, xfc->display, clipboard->respond->requestor, 0, 0, conv.ev); - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); } free(clipboard->respond); clipboard->respond = NULL; diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c index 448d41702..be841e1f6 100644 --- a/client/X11/xf_rail.c +++ b/client/X11/xf_rail.c @@ -759,7 +759,7 @@ static void xf_rail_set_window_icon(xfContext* xfc, xfAppWindow* railWindow, xfR LogTagAndXChangeProperty(TAG, xfc->display, railWindow->handle, xfc->NET_WM_ICON, XA_CARDINAL, 32, replace ? PropModeReplace : PropModeAppend, (unsigned char*)icon->data, icon->length); - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); } static BOOL xf_rail_window_icon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, diff --git a/client/X11/xf_utils.c b/client/X11/xf_utils.c index c69596f96..2fc0cf325 100644 --- a/client/X11/xf_utils.c +++ b/client/X11/xf_utils.c @@ -396,3 +396,22 @@ int LogDynAndXSendEvent_ex(wLog* log, const char* file, const char* fkt, size_t } return rc; } + +int LogDynAndXFlush_ex(wLog* log, const char* file, const char* fkt, size_t line, Display* display) +{ + if (WLog_IsLevelActive(log, log_level)) + { + write_log(log, log_level, file, fkt, line, "XFlush(%p)", display); + } + + const int rc = XFlush(display); + if (rc < 0) + { + char buffer[128] = { 0 }; + + const DWORD lvl = WLOG_WARN; + WLog_Print(log, lvl, "XFlush returned %s", + error_to_string(display, rc, buffer, sizeof(buffer))); + } + return rc; +} diff --git a/client/X11/xf_utils.h b/client/X11/xf_utils.h index a71dc6429..a22274dad 100644 --- a/client/X11/xf_utils.h +++ b/client/X11/xf_utils.h @@ -127,4 +127,9 @@ extern Status LogDynAndXSendEvent_ex(wLog* log, const char* file, const char* fk Display* display, Window w, Bool propagate, long event_mask, XEvent* event_send); +#define LogDynAndXFlush(log, display) \ + LogDynAndXFlush_ex(log, __FILE__, __func__, __LINE__, (display)) +extern Status LogDynAndXFlush_ex(wLog* log, const char* file, const char* fkt, size_t line, + Display* display); + BOOL IsGnome(void); diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 7240c8eff..567f88982 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -1273,7 +1273,7 @@ void xf_ShowWindow(xfContext* xfc, xfAppWindow* appWindow, BYTE state) /* Save the current rail state of this window */ appWindow->rail_state = state; - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); } void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow, RECTANGLE_16* rects, int nrects) @@ -1365,7 +1365,7 @@ void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, i LogDynAndXCopyArea(xfc->log, xfc->display, appWindow->pixmap, appWindow->handle, appWindow->gc, x, y, WINPR_ASSERTING_INT_CAST(uint32_t, width), WINPR_ASSERTING_INT_CAST(uint32_t, height), x, y); - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); xf_unlock_x11(xfc); } @@ -1524,7 +1524,7 @@ UINT xf_AppUpdateWindowFromSurface(xfContext* xfc, gdiGfxSurface* surface) rc = CHANNEL_RC_OK; fail: - XFlush(xfc->display); + LogDynAndXFlush(xfc->log, xfc->display); xf_unlock_x11(xfc); return rc; }