container: predict window size for initial configure
previously, windows were allowed determine their own initial dimensions, then fed a resize afterwards. we now look up the parent container and try to predict + report the real size up front to minimise visual artifacting on spawn/destroy
This commit is contained in:
parent
fdf8569952
commit
f94d6c644c
3 changed files with 50 additions and 1 deletions
|
|
@ -377,6 +377,32 @@ impl ContainerNode {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn predict_child_body_size(&self) -> (i32, i32) {
|
||||
let tpuh = self.state.theme.title_plus_underline_height();
|
||||
if self.mono_child.is_some() {
|
||||
let mb = self.mono_body.get();
|
||||
return (mb.width(), mb.height());
|
||||
}
|
||||
let spacing = self.state.theme.sizes.gap.get().max(
|
||||
self.state.theme.sizes.border_width.get(),
|
||||
);
|
||||
let nc = self.num_children.get() as i32 + 1;
|
||||
match self.split.get() {
|
||||
ContainerSplit::Horizontal => {
|
||||
let content_w = self.width.get().sub((nc - 1) * spacing).max(0);
|
||||
(content_w / nc, self.height.get().sub(tpuh).max(0))
|
||||
}
|
||||
ContainerSplit::Vertical => {
|
||||
let content_h = self
|
||||
.height
|
||||
.get()
|
||||
.sub(tpuh + (nc - 1) * (spacing + tpuh))
|
||||
.max(0);
|
||||
(self.width.get(), content_h / nc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_spaces_changed(self: &Rc<Self>) {
|
||||
self.update_content_size();
|
||||
// log::info!("on_spaces_changed");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue