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
+2
View File
@@ -73,6 +73,7 @@ func newXembedHost(conn *dbus.Conn, busName string, objPath dbus.ObjectPath) (*x
if dpy == nil {
return nil, errors.New("cannot open X display")
}
C.xembed_install_error_handlers()
screen := C.xembed_default_screen(dpy)
trayMgr := C.xembed_find_tray(dpy, screen)
@@ -383,6 +384,7 @@ func xembedTrayAvailable() bool {
if dpy == nil {
return false
}
C.xembed_install_error_handlers()
defer C.XCloseDisplay(dpy)
screen := C.xembed_default_screen(dpy)
return C.xembed_find_tray(dpy, screen) != 0