Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toplevel: send 0x0 size until window has been mapped #252

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/bugs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ static BUGS: Lazy<AHashMap<&'static str, Bugs>> = Lazy::new(|| {
map.insert(
"Alacritty",
Bugs {
min_size: Some((100, 100)),
min_width: Some(100),
min_height: Some(100),
..Default::default()
},
);
Expand All @@ -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<i32>,
pub min_height: Option<i32>,
}
44 changes: 25 additions & 19 deletions src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub struct XdgToplevel {
pub drag: CloneCell<Option<Rc<XdgToplevelDragV1>>>,
is_mapped: Cell<bool>,
dialog: CloneCell<Option<Rc<XdgDialogV1>>>,
extents_set: Cell<bool>,
}

impl Debug for XdgToplevel {
Expand Down Expand Up @@ -144,6 +145,7 @@ impl XdgToplevel {
drag: Default::default(),
is_mapped: Cell::new(false),
dialog: Default::default(),
extents_set: Cell::new(false),
}
}

Expand All @@ -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)
}

Expand Down Expand Up @@ -582,6 +587,7 @@ impl ToplevelNodeBase for XdgToplevel {
}

fn tl_change_extents_impl(self: Rc<Self>, rect: &Rect) {
self.extents_set.set(true);
let nw = rect.width();
let nh = rect.height();
let de = self.xdg.absolute_desired_extents.get();
Expand Down
Loading