Skip to content

Commit

Permalink
React to XCB (X11) errors in the event loop.)
Browse files Browse the repository at this point in the history
  • Loading branch information
odiroot committed Mar 13, 2024
1 parent e4b43b1 commit 9e9312b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugin/gui/gui.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions plugin/gui/xcb.v
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9e9312b

Please sign in to comment.