forge
Explore
Log in

Don't you dare go Hollow

layout/tests: Support animation snapshot

Browse files at this commit

5bda3041d0533f4a922498392fc6083c1e952ac8Ivan MolodetskikhParent: 54076b7
Only the size is needed in these tests; needed for testing animation progress.
src/layout/tests.rsmodified+24 -3
@@ -1,4 +1,4 @@
1-use std::cell::Cell;1+use std::cell::{Cell, OnceCell, RefCell};
2 2
3 use niri_config::{3 use niri_config::{
4 FloatOrInt, OutputName, TabIndicatorLength, TabIndicatorPosition, WorkspaceName,4 FloatOrInt, OutputName, TabIndicatorLength, TabIndicatorPosition, WorkspaceName,
@@ -31,6 +31,8 @@ struct TestWindowInner {
31 is_fullscreen: Cell<bool>,31 is_fullscreen: Cell<bool>,
32 is_windowed_fullscreen: Cell<bool>,32 is_windowed_fullscreen: Cell<bool>,
33 is_pending_windowed_fullscreen: Cell<bool>,33 is_pending_windowed_fullscreen: Cell<bool>,
34+ animate_next_configure: Cell<bool>,
35+ animation_snapshot: RefCell<Option<LayoutElementRenderSnapshot>>,
34 }36 }
35 37
36 #[derive(Debug, Clone)]38 #[derive(Debug, Clone)]
@@ -76,6 +78,8 @@ impl TestWindow {
76 is_fullscreen: Cell::new(false),78 is_fullscreen: Cell::new(false),
77 is_windowed_fullscreen: Cell::new(false),79 is_windowed_fullscreen: Cell::new(false),
78 is_pending_windowed_fullscreen: Cell::new(false),80 is_pending_windowed_fullscreen: Cell::new(false),
81+ animate_next_configure: Cell::new(false),
82+ animation_snapshot: RefCell::new(None),
79 }))83 }))
80 }84 }
81 85
@@ -95,11 +99,24 @@ impl TestWindow {
95 }99 }
96 100
97 if self.0.bbox.get() != new_bbox {101 if self.0.bbox.get() != new_bbox {
102+ if self.0.animate_next_configure.get() {
103+ self.0.animation_snapshot.replace(Some(RenderSnapshot {
104+ contents: Vec::new(),
105+ blocked_out_contents: Vec::new(),
106+ block_out_from: None,
107+ size: self.0.bbox.get().size.to_f64(),
108+ texture: OnceCell::new(),
109+ blocked_out_texture: OnceCell::new(),
110+ }));
111+ }
112+
98 self.0.bbox.set(new_bbox);113 self.0.bbox.set(new_bbox);
99 changed = true;114 changed = true;
100 }115 }
101 }116 }
102 117
118+ self.0.animate_next_configure.set(false);
119+
103 if self.0.is_fullscreen.get() != self.0.pending_fullscreen.get() {120 if self.0.is_fullscreen.get() != self.0.pending_fullscreen.get() {
104 self.0.is_fullscreen.set(self.0.pending_fullscreen.get());121 self.0.is_fullscreen.set(self.0.pending_fullscreen.get());
105 changed = true;122 changed = true;
@@ -153,7 +170,11 @@ impl LayoutElement for TestWindow {
153 _animate: bool,170 _animate: bool,
154 _transaction: Option<Transaction>,171 _transaction: Option<Transaction>,
155 ) {172 ) {
156- self.0.requested_size.set(Some(size));173+ if self.0.requested_size.get() != Some(size) {
174+ self.0.requested_size.set(Some(size));
175+ self.0.animate_next_configure.set(true);
176+ }
177+
157 self.0.pending_fullscreen.set(is_fullscreen);178 self.0.pending_fullscreen.set(is_fullscreen);
158 179
159 if is_fullscreen {180 if is_fullscreen {
@@ -245,7 +266,7 @@ impl LayoutElement for TestWindow {
245 }266 }
246 267
247 fn take_animation_snapshot(&mut self) -> Option<LayoutElementRenderSnapshot> {268 fn take_animation_snapshot(&mut self) -> Option<LayoutElementRenderSnapshot> {
248- None269+ self.0.animation_snapshot.take()
249 }270 }
250 271
251 fn set_interactive_resize(&mut self, _data: Option<InteractiveResizeData>) {}272 fn set_interactive_resize(&mut self, _data: Option<InteractiveResizeData>) {}