summaryrefslogtreecommitdiff
path: root/src/clients/client.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-06 14:23:03 +0100
committertcmal <me@aria.rip>2024-08-06 14:39:52 +0100
commit5359062bf58a5ff57dfa48492db57f9340ecfbee (patch)
tree7a2d719cd091d681ca0de88585f1c64ddd305717 /src/clients/client.rs
parent9865539d1a490ed403e8daff8c670d9a45673468 (diff)
Deal with configurerequest properly
Diffstat (limited to 'src/clients/client.rs')
-rw-r--r--src/clients/client.rs63
1 files changed, 57 insertions, 6 deletions
diff --git a/src/clients/client.rs b/src/clients/client.rs
index 43d4c54..6ab664b 100644
--- a/src/clients/client.rs
+++ b/src/clients/client.rs
@@ -1,8 +1,8 @@
use xcb::{
x::{
- self, ChangeProperty, ChangeWindowAttributes, ConfigWindow, ConfigureNotifyEvent,
- ConfigureWindow, Cw, EventMask, MapWindow, PropMode, SendEvent, SendEventDest, StackMode,
- Window,
+ self, ChangeProperty, ChangeWindowAttributes, ConfigWindow, ConfigWindowMask,
+ ConfigureNotifyEvent, ConfigureWindow, Cw, EventMask, MapWindow, PropMode, SendEvent,
+ SendEventDest, StackMode, Window,
},
VoidCookieChecked, Xid,
};
@@ -113,6 +113,37 @@ impl Client {
});
}
+ /// Set the client's geometry as requested by the given event.
+ /// Properties not specified in `e` are not changed.
+ pub fn set_geom_from(&mut self, conn: &Connection, e: &x::ConfigureRequestEvent) {
+ let Self {
+ mut x,
+ mut y,
+ mut width,
+ mut height,
+ mut border_width,
+ ..
+ } = self;
+
+ if e.value_mask().contains(ConfigWindowMask::X) {
+ x = e.x();
+ }
+ if e.value_mask().contains(ConfigWindowMask::Y) {
+ y = e.y();
+ }
+ if e.value_mask().contains(ConfigWindowMask::HEIGHT) {
+ height = e.height();
+ }
+ if e.value_mask().contains(ConfigWindowMask::WIDTH) {
+ width = e.width();
+ }
+ if e.value_mask().contains(ConfigWindowMask::BORDER_WIDTH) {
+ border_width = e.border_width();
+ }
+
+ self.set_geom(conn, x, y, height, width, border_width);
+ }
+
/// Set the border colour of the X11 window to the given value (see `crate::colours::Colours`)
pub fn set_border(&self, conn: &Connection<'_>, colour: u32) {
conn.send_request(&ChangeWindowAttributes {
@@ -131,12 +162,17 @@ impl Client {
matches!(self.layout_mode, LayoutMode::Fullscreen)
}
+ /// Whether the client is floating
+ pub const fn floating(&self) -> bool {
+ matches!(self.layout_mode, LayoutMode::Floating)
+ }
+
/// Set the window as tiled
pub fn set_tiled(&mut self, conn: &Connection<'_>) {
let dirty = !matches!(self.layout_mode, LayoutMode::Tiled);
self.layout_mode = LayoutMode::Tiled;
if dirty {
- self.apply_net_wm_state(conn)
+ self.apply_net_wm_state(conn);
}
}
@@ -184,8 +220,7 @@ impl Client {
property: conn.atoms.net_wm_state,
r#type: x::ATOM_ATOM,
data: &[match self.layout_mode {
- LayoutMode::Tiled => 0_u32,
- LayoutMode::Floating => 0_u32,
+ LayoutMode::Tiled | LayoutMode::Floating => 0_u32,
LayoutMode::Fullscreen => conn.atoms.net_wm_fullscreen.resource_id(),
}],
});
@@ -258,6 +293,22 @@ impl Client {
self.urgent = urgent;
}
+ pub const fn x(&self) -> i16 {
+ self.x
+ }
+
+ pub const fn y(&self) -> i16 {
+ self.y
+ }
+
+ pub const fn height(&self) -> u16 {
+ self.height
+ }
+
+ pub const fn width(&self) -> u16 {
+ self.width
+ }
+
pub const fn border_width(&self) -> u16 {
self.border_width
}