layout/tests: Implement going into fullscreen state
Browse files at this commitfbb399f01d739b8f1e3774dee725ae6ef33c2af9Parent: 6a80ec41 changed file +34 -3
- src/layout/tests.rs +34 -3
src/layout/tests.rsmodified+34 -3
| @@ -28,6 +28,7 @@ struct TestWindowInner { | |||
| 28 | max_size: Size<i32, Logical>, | 28 | max_size: Size<i32, Logical>, |
| 29 | pending_fullscreen: Cell<bool>, | 29 | pending_fullscreen: Cell<bool>, |
| 30 | pending_activated: Cell<bool>, | 30 | pending_activated: Cell<bool>, |
| 31 | + is_fullscreen: Cell<bool>, | ||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | #[derive(Debug, Clone)] | 34 | #[derive(Debug, Clone)] |
| @@ -70,10 +71,13 @@ impl TestWindow { | |||
| 70 | max_size: params.min_max_size.1, | 71 | max_size: params.min_max_size.1, |
| 71 | pending_fullscreen: Cell::new(false), | 72 | pending_fullscreen: Cell::new(false), |
| 72 | pending_activated: Cell::new(false), | 73 | pending_activated: Cell::new(false), |
| 74 | + is_fullscreen: Cell::new(false), | ||
| 73 | })) | 75 | })) |
| 74 | } | 76 | } |
| 75 | 77 | ||
| 76 | fn communicate(&self) -> bool { | 78 | fn communicate(&self) -> bool { |
| 79 | + let mut changed = false; | ||
| 80 | + | ||
| 77 | if let Some(size) = self.0.requested_size.get() { | 81 | if let Some(size) = self.0.requested_size.get() { |
| 78 | assert!(size.w >= 0); | 82 | assert!(size.w >= 0); |
| 79 | assert!(size.h >= 0); | 83 | assert!(size.h >= 0); |
| @@ -88,11 +92,16 @@ impl TestWindow { | |||
| 88 | 92 | ||
| 89 | if self.0.bbox.get() != new_bbox { | 93 | if self.0.bbox.get() != new_bbox { |
| 90 | self.0.bbox.set(new_bbox); | 94 | self.0.bbox.set(new_bbox); |
| 91 | - return true; | 95 | + changed = true; |
| 92 | } | 96 | } |
| 93 | } | 97 | } |
| 94 | 98 | ||
| 95 | - false | 99 | + if self.0.is_fullscreen.get() != self.0.pending_fullscreen.get() { |
| 100 | + self.0.is_fullscreen.set(self.0.pending_fullscreen.get()); | ||
| 101 | + changed = true; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + changed | ||
| 96 | } | 105 | } |
| 97 | } | 106 | } |
| 98 | 107 | ||
| @@ -182,7 +191,7 @@ impl LayoutElement for TestWindow { | |||
| 182 | fn set_floating(&mut self, _floating: bool) {} | 191 | fn set_floating(&mut self, _floating: bool) {} |
| 183 | 192 | ||
| 184 | fn is_fullscreen(&self) -> bool { | 193 | fn is_fullscreen(&self) -> bool { |
| 185 | - false | 194 | + self.0.is_fullscreen.get() |
| 186 | } | 195 | } |
| 187 | 196 | ||
| 188 | fn is_pending_fullscreen(&self) -> bool { | 197 | fn is_pending_fullscreen(&self) -> bool { |
| @@ -3156,6 +3165,28 @@ fn disable_tabbed_mode_in_fullscreen() { | |||
| 3156 | check_ops(&ops); | 3165 | check_ops(&ops); |
| 3157 | } | 3166 | } |
| 3158 | 3167 | ||
| 3168 | +#[test] | ||
| 3169 | +fn unfullscreen_with_large_border() { | ||
| 3170 | + let ops = [ | ||
| 3171 | + Op::AddWindow { | ||
| 3172 | + params: TestWindowParams::new(0), | ||
| 3173 | + }, | ||
| 3174 | + Op::FullscreenWindow(0), | ||
| 3175 | + Op::Communicate(0), | ||
| 3176 | + Op::FullscreenWindow(0), | ||
| 3177 | + ]; | ||
| 3178 | + | ||
| 3179 | + let options = Options { | ||
| 3180 | + border: niri_config::Border { | ||
| 3181 | + off: false, | ||
| 3182 | + width: niri_config::FloatOrInt(10000.), | ||
| 3183 | + ..Default::default() | ||
| 3184 | + }, | ||
| 3185 | + ..Default::default() | ||
| 3186 | + }; | ||
| 3187 | + check_ops_with_options(options, &ops); | ||
| 3188 | +} | ||
| 3189 | + | ||
| 3159 | fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool { | 3190 | fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool { |
| 3160 | if parent_id == id { | 3191 | if parent_id == id { |
| 3161 | return true; | 3192 | return true; |