diff --git a/src/bugs.rs b/src/bugs.rs index f0b320c3..9635250b 100644 --- a/src/bugs.rs +++ b/src/bugs.rs @@ -12,7 +12,8 @@ static BUGS: Lazy> = Lazy::new(|| { map.insert( "Alacritty", Bugs { - min_size: Some((100, 100)), + min_width: Some(100), + min_height: Some(100), ..Default::default() }, ); @@ -25,11 +26,13 @@ pub fn get(app_id: &str) -> &'static Bugs { pub static NONE: Bugs = Bugs { respect_min_max_size: false, - min_size: None, + min_width: None, + min_height: None, }; #[derive(Default, Debug)] pub struct Bugs { pub respect_min_max_size: bool, - pub min_size: Option<(i32, i32)>, + pub min_width: Option, + pub min_height: Option, } diff --git a/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs b/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs index 6b608d5e..403c3bd5 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs @@ -105,6 +105,7 @@ pub struct XdgToplevel { pub drag: CloneCell>>, is_mapped: Cell, dialog: CloneCell>>, + extents_set: Cell, } impl Debug for XdgToplevel { @@ -144,6 +145,7 @@ impl XdgToplevel { drag: Default::default(), is_mapped: Cell::new(false), dialog: Default::default(), + extents_set: Cell::new(false), } } @@ -160,27 +162,30 @@ impl XdgToplevel { } fn send_configure_checked(&self, mut width: i32, mut height: i32) { - width = width.max(1); - height = height.max(1); - let bugs = self.bugs.get(); - if let Some((mw, mh)) = bugs.min_size { - width = width.max(mw); - height = height.max(mh); + if self.extents_set.get() { + width = width.max(1); + height = height.max(1); } - if bugs.respect_min_max_size { - if let Some(min) = self.min_width.get() { - width = width.max(min); - } - if let Some(min) = self.min_height.get() { - height = height.max(min); - } - if let Some(max) = self.max_width.get() { - width = width.min(max); - } - if let Some(max) = self.max_height.get() { - height = height.min(max); - } + let bugs = self.bugs.get(); + macro_rules! apply { + ($field:expr, $min:ident, $max:ident) => { + if $field != 0 { + if let Some(min) = bugs.$min { + $field = $field.max(min); + } + if bugs.respect_min_max_size { + if let Some(min) = self.$min.get() { + $field = $field.max(min); + } + if let Some(max) = self.$max.get() { + $field = $field.min(max); + } + } + } + }; } + apply!(width, min_width, max_width); + apply!(height, min_height, max_height); self.send_configure(width, height) } @@ -582,6 +587,7 @@ impl ToplevelNodeBase for XdgToplevel { } fn tl_change_extents_impl(self: Rc, rect: &Rect) { + self.extents_set.set(true); let nw = rect.width(); let nh = rect.height(); let de = self.xdg.absolute_desired_extents.get();