summaryrefslogtreecommitdiff
path: root/src/clients/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients/mod.rs')
-rw-r--r--src/clients/mod.rs28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs
index da341ba..4ebd634 100644
--- a/src/clients/mod.rs
+++ b/src/clients/mod.rs
@@ -11,12 +11,12 @@ use crate::{
};
use xcb::{
x::{
- self, ChangeProperty, ConfigWindow, ConfigWindowMask, ConfigureNotifyEvent,
+ self, ChangeProperty, CloseDown, ConfigWindow, ConfigWindowMask, ConfigureNotifyEvent,
ConfigureRequestEvent, ConfigureWindow, DeleteProperty, DestroyNotifyEvent, EventMask,
- GetWindowAttributes, InputFocus, MapRequestEvent, PropMode, SetInputFocus,
- UnmapNotifyEvent, Window,
+ GetWindowAttributes, InputFocus, KillClient, MapRequestEvent, PropMode, SetCloseDownMode,
+ SetInputFocus, UnmapNotifyEvent, Window,
},
- xinerama, BaseEvent, Extension,
+ xinerama, BaseEvent, Extension, Xid,
};
pub use client::*;
@@ -548,6 +548,26 @@ impl ClientState {
pub fn client_mon(&self, pos: ClientIdx) -> &MonitorInfo {
&self.mons[self.client_mon_idx(pos)]
}
+
+ pub fn kill_client(&self, conn: &Connection, pos: usize) {
+ let c = self.client(pos);
+ // Modern clients respond to the WM_DELETE event
+ if !conn.send_event(c.window(), conn.atoms.wm_delete) {
+ // Fallback to the old fashioned way
+
+ // Using checked requests so we can ignore errors here without waiting for them to go to
+ // the event loop
+ let cookie1 = conn.send_request_checked(&SetCloseDownMode {
+ mode: CloseDown::DestroyAll,
+ });
+ let cookie2 = conn.send_request_checked(&KillClient {
+ resource: c.window().resource_id(),
+ });
+
+ let _ = conn.check_request(cookie1);
+ let _ = conn.check_request(cookie2);
+ }
+ }
}
impl Default for ClientState {