mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-26 16:49:08 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user