x11: internal window to send close backend event to
This commit is contained in:
parent
82f2e2def6
commit
22204f2845
|
@ -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(),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue