1
0
Fork 0
forked from wry/wry

Merge pull request #252 from mahkoh/jorth/initila-toplevel-sizing

toplevel: send 0x0 size until window has been mapped
This commit is contained in:
mahkoh 2024-09-04 12:51:26 +02:00 committed by GitHub
commit 19dffba7d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 22 deletions

View file

@ -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()
},
);
@ -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>,
}

View file

@ -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 {
@ -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);
if self.extents_set.get() {
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 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);
}
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<Self>, rect: &Rect) {
self.extents_set.set(true);
let nw = rect.width();
let nh = rect.height();
let de = self.xdg.absolute_desired_extents.get();