diff options
-rw-r--r-- | src/clients/mod.rs | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/src/clients/mod.rs b/src/clients/mod.rs index 7a06210..6152be5 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -1,7 +1,7 @@ //! Tracking and managing windows. use std::{ - cmp::{min, Ordering}, + cmp::{max, min, Ordering}, mem, }; @@ -64,34 +64,19 @@ impl WM<'_> { c.configure_notify(&self.conn); } else { - let (mut x, mut y, mut width, mut height, mut border_width) = - (0_i32, 0_i32, 1_u32, 1_u32, 0_u32); - - if e.value_mask().contains(ConfigWindowMask::X) { - x = i32::from(e.x()); - } - if e.value_mask().contains(ConfigWindowMask::Y) { - y = i32::from(e.y()); - } - if e.value_mask().contains(ConfigWindowMask::HEIGHT) { - height = u32::from(e.height()); - } - if e.value_mask().contains(ConfigWindowMask::WIDTH) { - width = u32::from(e.width()); - } - if e.value_mask().contains(ConfigWindowMask::BORDER_WIDTH) { - border_width = u32::from(e.border_width()); - } - // Configure it as requested, and sort the rest when we actually map the window + // According to spec, we should check the property mask and only set properties that are specified, setting defaults + // for other ones. + // Unfortunately, some clients (such as Audacity) will not set the mask correctly. + // So instead we just use all the properties, and the ones that can be invalid (width, height > 0) we clamp. self.conn.send_request(&ConfigureWindow { window: e.window(), value_list: &[ - ConfigWindow::X(x), - ConfigWindow::Y(y), - ConfigWindow::Width(width), - ConfigWindow::Height(height), - ConfigWindow::BorderWidth(border_width), + ConfigWindow::X(e.x().into()), + ConfigWindow::Y(e.y().into()), + ConfigWindow::Width(max(e.width().into(), 1)), + ConfigWindow::Height(max(e.height().into(), 1)), + ConfigWindow::BorderWidth(e.border_width().into()), ConfigWindow::StackMode(e.stack_mode()), ], }); |