From 9e9312bbeb3ad86482afe2ac25c39529e182cd41 Mon Sep 17 00:00:00 2001 From: Michal Odnous Date: Wed, 13 Mar 2024 20:48:46 +0000 Subject: [PATCH] React to XCB (X11) errors in the event loop.) --- plugin/gui/gui.v | 5 +++++ plugin/gui/xcb.v | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/plugin/gui/gui.v b/plugin/gui/gui.v index 1529307..4ae49a3 100644 --- a/plugin/gui/gui.v +++ b/plugin/gui/gui.v @@ -92,6 +92,11 @@ pub fn (g &GUI) on_posix_fd() { } t := event.response_type & ~0x80 match t { + // Error + 0 { + error_ev := &C.xcb_request_error_t(event) + eprintln('Received X11 error: ${error_ev.error_code}') + } u8(C.XCB_EXPOSE) { expose_ev := &C.xcb_expose_event_t(event) if expose_ev.window == g.window { diff --git a/plugin/gui/xcb.v b/plugin/gui/xcb.v index 24b3e5e..fece731 100644 --- a/plugin/gui/xcb.v +++ b/plugin/gui/xcb.v @@ -50,6 +50,15 @@ struct C.xcb_expose_event_t { window C.xcb_window_t } +@[typedef] +struct C.xcb_request_error_t { + error_code u8 + sequence u16 + bad_value u32 + minor_opcode u16 + major_opcode u16 +} + fn C.xcb_connect(&char, &int) &C.xcb_connection_t fn C.xcb_disconnect(&C.xcb_connection_t) fn C.xcb_flush(&C.xcb_connection_t)