wayland: install X error handler for XWayland connection
The Wayland backend runs with a live XWayland Display* once XWayland fires its ready signal. Without an error handler, benign X errors (BadMatch on X_SetInputFocus, BadWindow during window teardown) reach Xlib's default handler and produce noisy output. Add wl_catch_xwayland_error() — same permissive policy as the X11 backend's x11_catch_error() — and install it via XSetErrorHandler in wl_register_error_handlers(). Include <X11/Xproto.h> for the X_SetInputFocus request code constant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2d9b9b76c5
commit
5f21e8069b
|
|
@ -126,6 +126,7 @@
|
|||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||
#include <wlr/xwayland.h> /* Phase 17: XWayland support */
|
||||
#include <X11/Xproto.h> /* X_SetInputFocus and other request codes */
|
||||
#include <wlr/backend/wayland.h> /* Phase 18: nested Wayland backend */
|
||||
#include <wlr/backend/multi.h> /* Phase 18: multi-backend */
|
||||
#include <wlr/types/wlr_scene.h> /* Phase 18: scene graph compositing */
|
||||
|
|
@ -4887,10 +4888,34 @@ static void wl_extensions_init(void) {}
|
|||
static void wl_cursors_init(void) {}
|
||||
static WNativeWindow wl_cursor_create_named(const char *name) { (void)name; return WNATIVE_NONE; }
|
||||
static void wl_shape_combine_mask(WNativeWindow win, WNativeWindow mask) { (void)win; (void)mask; }
|
||||
static int
|
||||
wl_catch_xwayland_error(Display *edpy, XErrorEvent *error)
|
||||
{
|
||||
(void)edpy;
|
||||
/* BadMatch on X_SetInputFocus is benign: the target window may not be
|
||||
* viewable yet (e.g. during XWayland startup or between map/unmap).
|
||||
* Silence it so it does not reach Xlib's default handler. */
|
||||
if (error->error_code == BadMatch &&
|
||||
error->request_code == X_SetInputFocus)
|
||||
return 0;
|
||||
/* BadWindow is also common during window teardown; ignore silently. */
|
||||
if (error->error_code == BadWindow)
|
||||
return 0;
|
||||
/* Everything else: print via wwarning and continue. */
|
||||
char buf[256];
|
||||
XGetErrorText(edpy, error->error_code, buf, sizeof(buf));
|
||||
wwarning("wl_backend: X error from XWayland: %s (request %d, resource 0x%lx)",
|
||||
buf, (int)error->request_code, (unsigned long)error->resourceid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
wl_register_error_handlers(void)
|
||||
{
|
||||
/* Pure Wayland: no X11 Display*, so no Xlib error handlers needed. */
|
||||
/* Install a permissive X error handler for the XWayland connection.
|
||||
* Without this, Xlib's default handler prints and the WM continues,
|
||||
* but benign errors (BadMatch on SetInputFocus etc.) cause visible noise. */
|
||||
XSetErrorHandler(wl_catch_xwayland_error);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
|
|
|||
Loading…
Reference in New Issue