From 89393e1782f7f5eade391aef1bf5d04813d19482 Mon Sep 17 00:00:00 2001 From: lkn Date: Tue, 23 Jun 2026 13:18:22 +0200 Subject: [PATCH] fix dockapp capture: use XSync, remove crash-prone timer Use XSync instead of XFlush for the initial capture to give the X server a round-trip to process the map. Remove the deferred timer re-capture which could crash if the icon was destroyed before firing. --- src/backend/wayland/wl_icon.c | 6 ++++-- src/icon.c | 1 + wm.log | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 wm.log diff --git a/src/backend/wayland/wl_icon.c b/src/backend/wayland/wl_icon.c index f5ee31c..904aa6a 100644 --- a/src/backend/wayland/wl_icon.c +++ b/src/backend/wayland/wl_icon.c @@ -414,9 +414,11 @@ wl_create_rimage_from_drawable(void *rcontext, WMDrawable drawable) if ((unsigned long)drawable < 0x10000000 && wl_state.x_display) { Window xwin = (Window)(unsigned long)drawable; WScreen *scr = wScreenWithNumber(0); - /* Ensure the window is mapped so we can capture its pixels */ + /* Ensure the window is mapped so we can capture its pixels. + * XSync forces a round-trip so the server processes the map + * and the app receives Expose before we capture. */ XMapWindow(wl_state.x_display, xwin); - XFlush(wl_state.x_display); + XSync(wl_state.x_display, False); XWindowAttributes attr; if (XGetWindowAttributes(wl_state.x_display, xwin, &attr) && attr.width > 0 && attr.height > 0) { diff --git a/src/icon.c b/src/icon.c index 5cb3fa6..4b7ed18 100644 --- a/src/icon.c +++ b/src/icon.c @@ -784,6 +784,7 @@ static void get_rimage_icon_from_icon_win(WIcon *icon) /* Set the new info */ icon->file_image = image; + } /* Set the dockapp in the WIcon */ diff --git a/wm.log b/wm.log new file mode 100644 index 0000000..e1d8f18 --- /dev/null +++ b/wm.log @@ -0,0 +1,25 @@ +[Thread debugging using libthread_db enabled] +Using host libthread_db library "/usr/lib64/libthread_db.so.1". +[New Thread 0x7fffe25ff6c0 (LWP 1941648)] +[New Thread 0x7fffe1dfe6c0 (LWP 1941649)] +[New Thread 0x7fffe11ff6c0 (LWP 1941650)] +[New Thread 0x7fffe09fe6c0 (LWP 1941651)] +[Thread 0x7fffe09fe6c0 (LWP 1941651) exited] +[Thread 0x7fffe11ff6c0 (LWP 1941650) exited] +[New Thread 0x7fffe11ff6c0 (LWP 1941652)] +[New Thread 0x7fffe09fe6c0 (LWP 1941653)] +[New Thread 0x7fffd3bff6c0 (LWP 1941654)] +[New Thread 0x7fffd33fe6c0 (LWP 1941655)] +[New Thread 0x7fffd29fd6c0 (LWP 1941656)] +[Detaching after vfork from child process 1941657] +[Detaching after fork from child process 1941658] +[Thread 0x7fffd33fe6c0 (LWP 1941655) exited] +[Thread 0x7fffd3bff6c0 (LWP 1941654) exited] +[Thread 0x7fffe09fe6c0 (LWP 1941653) exited] +[Thread 0x7fffe11ff6c0 (LWP 1941652) exited] +[Thread 0x7fffe1dfe6c0 (LWP 1941649) exited] +[Thread 0x7fffe25ff6c0 (LWP 1941648) exited] +[Thread 0x7ffff67c92c0 (LWP 1941645) exited] +[Thread 0x7fffd29fd6c0 (LWP 1941656) exited] +[New process 1941645] +[Inferior 1 (process 1941645) exited normally]