aboutsummaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-08-12 22:34:13 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-08-14 15:58:59 +0300
commit5bda3041d0533f4a922498392fc6083c1e952ac8 (patch)
tree5fc0aef552be7bf326134031d206577197112375 /src/layout
parent54076b76321f47fd1485ec3183373a55da5a641e (diff)
downloadniri-5bda3041d0533f4a922498392fc6083c1e952ac8.tar.gz
niri-5bda3041d0533f4a922498392fc6083c1e952ac8.tar.bz2
niri-5bda3041d0533f4a922498392fc6083c1e952ac8.zip
layout/tests: Support animation snapshot
Only the size is needed in these tests; needed for testing animation progress.
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/tests.rs27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/layout/tests.rs b/src/layout/tests.rs
index 9d8c3139..ae7a16c6 100644
--- a/src/layout/tests.rs
+++ b/src/layout/tests.rs
@@ -1,4 +1,4 @@
-use std::cell::Cell;
+use std::cell::{Cell, OnceCell, RefCell};
use niri_config::{
FloatOrInt, OutputName, TabIndicatorLength, TabIndicatorPosition, WorkspaceName,
@@ -31,6 +31,8 @@ struct TestWindowInner {
is_fullscreen: Cell<bool>,
is_windowed_fullscreen: Cell<bool>,
is_pending_windowed_fullscreen: Cell<bool>,
+ animate_next_configure: Cell<bool>,
+ animation_snapshot: RefCell<Option<LayoutElementRenderSnapshot>>,
}
#[derive(Debug, Clone)]
@@ -76,6 +78,8 @@ impl TestWindow {
is_fullscreen: Cell::new(false),
is_windowed_fullscreen: Cell::new(false),
is_pending_windowed_fullscreen: Cell::new(false),
+ animate_next_configure: Cell::new(false),
+ animation_snapshot: RefCell::new(None),
}))
}
@@ -95,11 +99,24 @@ impl TestWindow {
}
if self.0.bbox.get() != new_bbox {
+ if self.0.animate_next_configure.get() {
+ self.0.animation_snapshot.replace(Some(RenderSnapshot {
+ contents: Vec::new(),
+ blocked_out_contents: Vec::new(),
+ block_out_from: None,
+ size: self.0.bbox.get().size.to_f64(),
+ texture: OnceCell::new(),
+ blocked_out_texture: OnceCell::new(),
+ }));
+ }
+
self.0.bbox.set(new_bbox);
changed = true;
}
}
+ self.0.animate_next_configure.set(false);
+
if self.0.is_fullscreen.get() != self.0.pending_fullscreen.get() {
self.0.is_fullscreen.set(self.0.pending_fullscreen.get());
changed = true;
@@ -153,7 +170,11 @@ impl LayoutElement for TestWindow {
_animate: bool,
_transaction: Option<Transaction>,
) {
- self.0.requested_size.set(Some(size));
+ if self.0.requested_size.get() != Some(size) {
+ self.0.requested_size.set(Some(size));
+ self.0.animate_next_configure.set(true);
+ }
+
self.0.pending_fullscreen.set(is_fullscreen);
if is_fullscreen {
@@ -245,7 +266,7 @@ impl LayoutElement for TestWindow {
}
fn take_animation_snapshot(&mut self) -> Option<LayoutElementRenderSnapshot> {
- None
+ self.0.animation_snapshot.take()
}
fn set_interactive_resize(&mut self, _data: Option<InteractiveResizeData>) {}