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
|
|
@ -780,7 +780,8 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
fn initial_configure(self: Rc<Self>) {
|
||||
let rect = self.xdg.absolute_desired_extents.get();
|
||||
if rect.is_empty() {
|
||||
self.send_configure(0, 0);
|
||||
let (w, h) = self.state.predict_tiled_body_size().unwrap_or((0, 0));
|
||||
self.send_configure(w, h);
|
||||
} else {
|
||||
self.send_configure_checked(rect.width(), rect.height());
|
||||
}
|
||||
|
|
|
|||
22
src/state.rs
22
src/state.rs
|
|
@ -1597,6 +1597,28 @@ impl State {
|
|||
self.config.get()?.initial_tile_state(data)
|
||||
}
|
||||
|
||||
pub fn predict_tiled_body_size(&self) -> Option<(i32, i32)> {
|
||||
let seat = self.seat_queue.last();
|
||||
let ws = self.ensure_map_workspace(seat.as_deref());
|
||||
let pos = ws.position.get();
|
||||
if pos.is_empty() {
|
||||
return None;
|
||||
}
|
||||
if let Some(c) = ws.container.get() {
|
||||
let la = c.clone().tl_last_active_child();
|
||||
let target = la
|
||||
.tl_data()
|
||||
.parent
|
||||
.get()
|
||||
.and_then(|n| n.node_into_container())
|
||||
.unwrap_or(c);
|
||||
Some(target.predict_child_body_size())
|
||||
} else {
|
||||
let tpuh = self.theme.title_plus_underline_height();
|
||||
Some((pos.width(), (pos.height() - tpuh).max(0)))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_capabilities(
|
||||
&self,
|
||||
data: &Rc<Client>,
|
||||
|
|
|
|||
|
|
@ -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