fix(ui): install X11 error handler so tray races don't kill the UI

Xlib's default protocol-error handler calls exit() on any async X error,
so a tray race (tray manager window dying between find and dock, XMoveWindow
on a popup the WM already destroyed) would take the whole UI process down.

Install process-global logging no-op handlers via XSetErrorHandler/
XSetIOErrorHandler after every XOpenDisplay. Since the handler slot is
process-global and GDK init can clobber it, additionally wrap the popup
code's raw Xlib calls on GDK's Display in gdk_x11_display_error_trap_push/
pop_ignored, which is independent of the global handler.
This commit is contained in:
Zoltán Papp
2026-06-15 12:26:53 +02:00
parent 2089b79630
commit b0f08645c3
4 changed files with 58 additions and 0 deletions
+6
View File
@@ -8,6 +8,12 @@ static inline int xembed_default_screen(Display *dpy) {
return DefaultScreen(dpy);
}
// xembed_install_error_handlers replaces Xlib's default protocol- and
// I/O-error handlers (which call exit()) with logging handlers, so an async
// X error from a tray race doesn't kill the UI process. Process-global and
// idempotent; safe to call after every XOpenDisplay.
void xembed_install_error_handlers(void);
// xembed_find_tray returns the selection owner window for
// _NET_SYSTEM_TRAY_S{screen}, or 0 if no XEmbed tray manager exists.
Window xembed_find_tray(Display *dpy, int screen);