Kill clients missing WM_DELETE_WINDOW protocol on close
Allows the compositor to close glxgears and other similar apps.
This commit is contained in:
parent
198ac851ee
commit
67efa2c559
3 changed files with 66 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use crate::server::{ObjectEvent, ObjectKey};
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::sync::{mpsc, Mutex, Once, OnceLock};
|
||||
use std::sync::{mpsc, Mutex, OnceLock};
|
||||
use wayland_client::protocol::{
|
||||
wl_buffer::WlBuffer, wl_callback::WlCallback, wl_compositor::WlCompositor,
|
||||
wl_keyboard::WlKeyboard, wl_output::WlOutput, wl_pointer::WlPointer, wl_region::WlRegion,
|
||||
|
|
|
|||
|
|
@ -830,19 +830,35 @@ impl super::XConnection for Arc<xcb::Connection> {
|
|||
}
|
||||
|
||||
fn close_window(&mut self, window: x::Window, atoms: Self::ExtraData) {
|
||||
let data = [atoms.wm_delete_window.resource_id(), 0, 0, 0, 0];
|
||||
let event = &x::ClientMessageEvent::new(
|
||||
let cookie = self.send_request(&x::GetProperty {
|
||||
window,
|
||||
atoms.wm_protocols,
|
||||
x::ClientMessageData::Data32(data),
|
||||
);
|
||||
delete: false,
|
||||
property: atoms.wm_protocols,
|
||||
r#type: x::ATOM_ATOM,
|
||||
long_offset: 0,
|
||||
long_length: 10,
|
||||
});
|
||||
let reply = unwrap_or_skip_bad_window!(self.wait_for_reply(cookie));
|
||||
|
||||
unwrap_or_skip_bad_window!(self.send_and_check_request(&x::SendEvent {
|
||||
destination: x::SendEventDest::Window(window),
|
||||
propagate: false,
|
||||
event_mask: x::EventMask::empty(),
|
||||
event,
|
||||
}));
|
||||
if reply.value::<x::Atom>().contains(&atoms.wm_delete_window) {
|
||||
let data = [atoms.wm_delete_window.resource_id(), 0, 0, 0, 0];
|
||||
let event = &x::ClientMessageEvent::new(
|
||||
window,
|
||||
atoms.wm_protocols,
|
||||
x::ClientMessageData::Data32(data),
|
||||
);
|
||||
|
||||
unwrap_or_skip_bad_window!(self.send_and_check_request(&x::SendEvent {
|
||||
destination: x::SendEventDest::Window(window),
|
||||
propagate: false,
|
||||
event_mask: x::EventMask::empty(),
|
||||
event,
|
||||
}));
|
||||
} else {
|
||||
unwrap_or_skip_bad_window!(self.send_and_check_request(&x::KillClient {
|
||||
resource: window.resource_id()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
fn raise_to_top(&mut self, window: x::Window) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue