diff options
author | tcmal <me@aria.rip> | 2024-08-25 21:10:02 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-28 21:34:33 +0100 |
commit | a339653a03b5e270cb897145fce7367861369145 (patch) | |
tree | fd8df8fcae36efe84d5fcd6f9e927ef755aa6e50 /src/clients | |
parent | 59e2829634b6a96a36c6358253860db4350024b4 (diff) |
Deal with not receiving enternotify events
Diffstat (limited to 'src/clients')
-rw-r--r-- | src/clients/client.rs | 10 | ||||
-rw-r--r-- | src/clients/mod.rs | 40 |
2 files changed, 13 insertions, 37 deletions
diff --git a/src/clients/client.rs b/src/clients/client.rs index 03afc16..bcf8b60 100644 --- a/src/clients/client.rs +++ b/src/clients/client.rs @@ -255,15 +255,11 @@ impl Client { } /// Set the event mask for this window - pub fn set_event_mask( - &self, - conn: &Connection<'_>, - event_mask: EventMask, - ) -> VoidCookieChecked { - conn.send_request_checked(&ChangeWindowAttributes { + pub fn set_event_mask(&self, conn: &Connection<'_>, event_mask: EventMask) { + conn.send_request(&ChangeWindowAttributes { window: self.window(), value_list: &[Cw::EventMask(event_mask)], - }) + }); } /// Sync the non-geometry related hints with EWMH hints diff --git a/src/clients/mod.rs b/src/clients/mod.rs index c42a385..bd44f1d 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -1,10 +1,9 @@ //! Tracking and managing windows. -use std::cmp::{min, Ordering}; +use std::cmp::Ordering; use crate::{ buttons, - config::BORDER_WIDTH, conn_info::Connection, debug, error::{Error, Result}, @@ -156,47 +155,27 @@ impl ClientState { } } - let Ok(geom) = conn.wait_for_reply(conn.send_request(&GetGeometry { - drawable: Drawable::Window(window), - })) else { - return; // window stopped existing, so we can't manage it - }; - + let new_idx = self.clients.len(); self.clients.push(Client::new(window, tag)); - let mon_geom @ MonitorGeometry { - width: mon_width, - height: mon_height, - .. - } = self.focused_mon().screen_info; + let mon_geom = self.focused_mon().screen_info; - let c = &mut self.clients[0]; - #[allow(clippy::cast_sign_loss)] - c.set_geom( - conn, - geom.x(), - geom.y(), - min(geom.width(), mon_width.saturating_sub(geom.x() as u16)), - min(geom.height(), mon_height.saturating_sub(geom.y() as u16)), - BORDER_WIDTH, - ); + let c = &mut self.clients[new_idx]; c.set_border(conn, conn.colours.border_normal()); - if floating { c.set_floating(conn); } c.sync_hints(conn, true); c.apply_geometry_hints(conn, &mon_geom); - - c.ensure_mapped(conn); - c.set_event_mask( conn, EventMask::ENTER_WINDOW | EventMask::FOCUS_CHANGE | EventMask::PROPERTY_CHANGE - | EventMask::STRUCTURE_NOTIFY, + | EventMask::STRUCTURE_NOTIFY + | EventMask::BUTTON_PRESS + | EventMask::KEY_PRESS, ); // Add to net_client_list @@ -207,10 +186,11 @@ impl ClientState { r#type: x::ATOM_WINDOW, data: &[window], }); - c.set_withdrawn(conn, false); - self.refocus(conn, self.clients.len() - 1); self.rearrange(conn); + if self.focused_mon().focused_tag.matches(tag) { + self.refocus(conn, self.clients.len() - 1); + } } /// Stop managing the given destroyed window |