From d973959f7f34e02eeb01766b01aff680639a8c4c Mon Sep 17 00:00:00 2001 From: tcmal Date: Tue, 6 Aug 2024 14:39:55 +0100 Subject: Add support for mouse button binds --- src/clients/mod.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/clients') diff --git a/src/clients/mod.rs b/src/clients/mod.rs index 1abab20..a59240d 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -3,6 +3,7 @@ use std::cmp::{min, Ordering}; use crate::{ + buttons, config::BORDER_WIDTH, conn_info::Connection, debug, @@ -87,7 +88,7 @@ impl WM<'_> { /// Removing destroyed windows from the client list and rearrange. pub(crate) fn handle_destroy_notify(&mut self, e: &DestroyNotifyEvent) { - self.clients.unmanage(&self.conn, e.window()); + self.clients.unmanage_destroyed(&self.conn, e.window()); } /// Map a window, starting to manage it if needed. @@ -242,7 +243,7 @@ impl ClientState { | EventMask::STRUCTURE_NOTIFY, ); - // TODO: grabbuttons + buttons::grab(conn, c.window(), false); // Add to net_client_list conn.send_request(&ChangeProperty { @@ -258,8 +259,8 @@ impl ClientState { self.rearrange_monitor(conn, mon); } - /// Stop managing the given window - pub fn unmanage(&mut self, conn: &Connection<'_>, window: Window) { + /// Stop managing the given destroyed window + pub fn unmanage_destroyed(&mut self, conn: &Connection<'_>, window: Window) { let Some((mon, i)) = self.find_client_pos(window) else { return; }; @@ -275,6 +276,7 @@ impl ClientState { if let Some(new) = self.set_focused(mon, i) { new.set_border(conn, conn.colours.border_focused()); new.sync_hints(conn, true); + buttons::grab(conn, new.window(), true); if !new.never_focus() { conn.send_request(&SetInputFocus { revert_to: InputFocus::PointerRoot, @@ -307,6 +309,7 @@ impl ClientState { pub fn unfocus(&mut self, conn: &Connection<'_>) { if let Some(old) = self.focused_mut() { old.set_border(conn, conn.colours.border_normal()); + buttons::grab(conn, old.window(), false); } } -- cgit v1.2.3