summaryrefslogtreecommitdiff
path: root/src/clients/mod.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-30 15:48:34 +0100
committertcmal <me@aria.rip>2024-08-30 16:20:29 +0100
commitb5601a6eb3a8d0603bb837a847701d3d49f984c3 (patch)
tree3004b27ed9b710b7cd8d4569e852f072db7814e8 /src/clients/mod.rs
parent12c930d9118941997336deb9ef6c676aa35b1cd9 (diff)
Add bind for killing clients
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 {