diff --git a/src/backend/x11/mod.rs b/src/backend/x11/mod.rs index 5eadebf..c71d305 100644 --- a/src/backend/x11/mod.rs +++ b/src/backend/x11/mod.rs @@ -118,7 +118,10 @@ use x11rb::{ protocol::{ self as x11, dri3::ConnectionExt as _, - xproto::{ColormapAlloc, ConnectionExt, PixmapWrapper, VisualClass}, + xproto::{ + ColormapAlloc, ConnectionExt, CreateWindowAux, PixmapWrapper, VisualClass, WindowClass, + WindowWrapper, + }, ErrorKind, }, rust_connection::{ReplyError, RustConnection}, @@ -216,9 +219,28 @@ impl X11Backend { let atoms = Atoms::new(&*connection)?.reply()?; + // We need to give the X11Source a window we have created, we cannot send the close event to the root + // window (0). To handle this, we will create a window we never map or provide to users to the backend + // can be sent a message for shutdown. + + let close_window = WindowWrapper::create_window( + &*connection, + x11rb::COPY_DEPTH_FROM_PARENT, + screen.root, + 0, + 0, + 1, + 1, + 0, + WindowClass::INPUT_OUTPUT, + x11rb::COPY_FROM_PARENT, + &CreateWindowAux::new(), + )? + .into_window(); + let source = X11Source::new( connection.clone(), - 0, // send the close request to something to ensure we can wake the reader thread for events. + close_window, atoms._SMITHAY_X11_BACKEND_CLOSE, logger.clone(), );