container: defer repaints to prevent visual artifacts
This commit is contained in:
parent
fb85fad953
commit
fdf8569952
1 changed files with 31 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use {
|
||||
crate::{
|
||||
async_engine::SpawnedFuture,
|
||||
backend::ButtonState,
|
||||
cursor::KnownCursor,
|
||||
cursor_user::CursorUser,
|
||||
|
|
@ -137,6 +138,8 @@ pub struct ContainerNode {
|
|||
scroller: Scroller,
|
||||
toplevel_data: ToplevelData,
|
||||
attention_requests: ThresholdCounter,
|
||||
pending_layout_damage: Cell<bool>,
|
||||
layout_damage_timeout: Cell<Option<SpawnedFuture<()>>>,
|
||||
}
|
||||
|
||||
impl Debug for ContainerNode {
|
||||
|
|
@ -253,6 +256,8 @@ impl ContainerNode {
|
|||
weak,
|
||||
),
|
||||
attention_requests: Default::default(),
|
||||
pending_layout_damage: Cell::new(false),
|
||||
layout_damage_timeout: Cell::new(None),
|
||||
});
|
||||
child.tl_set_parent(slf.clone());
|
||||
slf.pull_child_properties(&child_node_ref);
|
||||
|
|
@ -401,9 +406,21 @@ impl ContainerNode {
|
|||
fn schedule_layout(self: &Rc<Self>) {
|
||||
if !self.layout_scheduled.replace(true) {
|
||||
self.state.pending_container_layout.push(self.clone());
|
||||
if self.toplevel_data.visible.get() {
|
||||
self.damage();
|
||||
}
|
||||
if self.toplevel_data.visible.get() {
|
||||
self.pending_layout_damage.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
fn schedule_layout_immediate(self: &Rc<Self>) {
|
||||
self.schedule_layout();
|
||||
self.flush_layout_damage();
|
||||
}
|
||||
|
||||
fn flush_layout_damage(&self) {
|
||||
if self.pending_layout_damage.replace(false) {
|
||||
self.damage();
|
||||
self.layout_damage_timeout.take();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -421,6 +438,14 @@ impl ContainerNode {
|
|||
// log::info!("perform_layout");
|
||||
self.schedule_render_titles();
|
||||
self.schedule_compute_render_positions();
|
||||
if self.pending_layout_damage.get() {
|
||||
let slf = self.clone();
|
||||
let timeout = self.state.eng.spawn("layout damage timeout", async move {
|
||||
slf.state.wheel.timeout(16).await.ok();
|
||||
slf.flush_layout_damage();
|
||||
});
|
||||
self.layout_damage_timeout.set(Some(timeout));
|
||||
}
|
||||
}
|
||||
|
||||
fn perform_mono_layout(self: &Rc<Self>, child: &ContainerChild) {
|
||||
|
|
@ -660,7 +685,7 @@ impl ContainerNode {
|
|||
op.child.factor.set(child_factor);
|
||||
self.sum_factors.set(sum_factors);
|
||||
// log::info!("pointer_move");
|
||||
self.schedule_layout();
|
||||
self.schedule_layout_immediate();
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
@ -1734,6 +1759,7 @@ impl Node for ContainerNode {
|
|||
if let Some(node) = cn.get(&child.node_id()) {
|
||||
self.update_child_size(node, width, height);
|
||||
}
|
||||
self.flush_layout_damage();
|
||||
}
|
||||
|
||||
fn node_child_active_changed(self: Rc<Self>, child: &dyn Node, active: bool, depth: u32) {
|
||||
|
|
@ -2183,7 +2209,7 @@ impl ContainingNode for ContainerNode {
|
|||
sum_factors = sum_factors - child.factor.get() + factor;
|
||||
child.factor.set(factor);
|
||||
self.sum_factors.set(sum_factors);
|
||||
self.schedule_layout();
|
||||
self.schedule_layout_immediate();
|
||||
}
|
||||
}
|
||||
let pos = self.node_absolute_position();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue