Merge pull request #436 from i509VCB/x11-poll-unblocker

This commit is contained in:
Victoria Brekenfeld 2021-12-17 19:32:49 +01:00 committed by GitHub
commit 4faacfdc7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 2 deletions

View File

@ -118,7 +118,10 @@ use x11rb::{
protocol::{ protocol::{
self as x11, self as x11,
dri3::ConnectionExt as _, dri3::ConnectionExt as _,
xproto::{ColormapAlloc, ConnectionExt, PixmapWrapper, VisualClass}, xproto::{
ColormapAlloc, ConnectionExt, CreateWindowAux, PixmapWrapper, VisualClass, WindowClass,
WindowWrapper,
},
ErrorKind, ErrorKind,
}, },
rust_connection::{ReplyError, RustConnection}, rust_connection::{ReplyError, RustConnection},
@ -216,9 +219,28 @@ impl X11Backend {
let atoms = Atoms::new(&*connection)?.reply()?; 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( let source = X11Source::new(
connection.clone(), 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, atoms._SMITHAY_X11_BACKEND_CLOSE,
logger.clone(), logger.clone(),
); );