diff options
author | tcmal <me@aria.rip> | 2024-08-28 18:14:51 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-09-05 18:04:28 +0100 |
commit | 250808c16b8e1179cd34f8a95c46177f25104d39 (patch) | |
tree | 1cf20f90b1c5cdabcb0af3396ffb831956666d4f /src/clients/mod.rs | |
parent | cdeab41621f600771fd9a7bb20376260d24f49c7 (diff) |
Fix some issues with splash screens, etc
Diffstat (limited to 'src/clients/mod.rs')
-rw-r--r-- | src/clients/mod.rs | 58 |
1 files changed, 49 insertions, 9 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs index 7216545..01f3205 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -1,9 +1,13 @@ //! Tracking and managing windows. -use std::{cmp::Ordering, mem}; +use std::{ + cmp::{min, Ordering}, + mem, +}; use crate::{ buttons, + config::BORDER_WIDTH, conn_info::Connection, debug, error::{Error, Result}, @@ -12,9 +16,9 @@ use crate::{ use xcb::{ x::{ self, ChangeProperty, CloseDown, ConfigWindow, ConfigWindowMask, ConfigureNotifyEvent, - ConfigureRequestEvent, ConfigureWindow, DeleteProperty, DestroyNotifyEvent, EventMask, - GetWindowAttributes, InputFocus, KillClient, MapRequestEvent, PropMode, SetCloseDownMode, - SetInputFocus, UnmapNotifyEvent, Window, + ConfigureRequestEvent, ConfigureWindow, DeleteProperty, DestroyNotifyEvent, Drawable, + EventMask, GetGeometry, GetWindowAttributes, InputFocus, KillClient, MapRequestEvent, + PropMode, SetCloseDownMode, SetInputFocus, UnmapNotifyEvent, Window, }, xinerama, BaseEvent, Extension, Xid, }; @@ -60,15 +64,34 @@ impl WM<'_> { c.configure_notify(&self.conn); } else { + let (mut x, mut y, mut width, mut height, mut border_width) = + (0_i32, 0_i32, 0_u32, 0_u32, 0_u32); + + if e.value_mask().contains(ConfigWindowMask::X) { + x = e.x() as i32; + } + if e.value_mask().contains(ConfigWindowMask::Y) { + y = e.y() as i32; + } + if e.value_mask().contains(ConfigWindowMask::HEIGHT) { + height = e.height() as u32; + } + if e.value_mask().contains(ConfigWindowMask::WIDTH) { + width = e.width() as u32; + } + if e.value_mask().contains(ConfigWindowMask::BORDER_WIDTH) { + border_width = e.border_width() as u32; + } + // Configure it as requested, and sort the rest when we actually map the window self.conn.send_and_check_request(&ConfigureWindow { window: e.window(), value_list: &[ - ConfigWindow::X(e.x().into()), - ConfigWindow::Y(e.y().into()), - ConfigWindow::Width(e.width().into()), - ConfigWindow::Height(e.height().into()), - ConfigWindow::BorderWidth(e.border_width().into()), + ConfigWindow::X(x), + ConfigWindow::Y(y), + ConfigWindow::Width(width), + ConfigWindow::Height(height), + ConfigWindow::BorderWidth(border_width), ConfigWindow::StackMode(e.stack_mode()), ], })?; @@ -167,10 +190,27 @@ impl ClientState { let new_idx = self.clients.len(); self.clients.push(Client::new(window, tag)); + 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 mon_geom = self.focused_mon().screen_info; let c = &mut self.clients[new_idx]; + #[allow(clippy::cast_sign_loss)] + c.set_geom( + conn, + geom.x(), + geom.y(), + min(geom.width(), mon_geom.width.saturating_sub(geom.x() as u16)), + min( + geom.height(), + mon_geom.height.saturating_sub(geom.y() as u16), + ), + BORDER_WIDTH, + ); c.set_border(conn, conn.colours.border_normal()); if floating { c.set_floating(conn); |