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.
This commit is contained in:
lkn 2026-06-23 13:18:22 +02:00
parent 074e9a7011
commit 89393e1782
3 changed files with 30 additions and 2 deletions

View File

@ -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) {

View File

@ -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 */

25
wm.log Normal file
View File

@ -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]