forge
Explore
Log in

Don't you dare go Hollow

floating: Don't use fullscreen size as floating size

Browse files at this commit

5488aaf69ffeb6ef504a4bec0b54a893155713cfIvan MolodetskikhParent: 96e493d
src/layout/floating.rsmodified+9 -6
@@ -375,8 +375,9 @@ impl<W: LayoutElement> FloatingSpace<W> {
375 floating_size.unwrap_or_default()375 floating_size.unwrap_or_default()
376 } else {376 } else {
377 // If the window wasn't fullscreen without a floating size (e.g. it was tiled before),377 // If the window wasn't fullscreen without a floating size (e.g. it was tiled before),
378- // ask for the current size.378+ // ask for the current size. If the current size is unknown (the window was only ever
379- floating_size.unwrap_or_else(|| win.expected_size())379+ // fullscreen until now), fall back to (0, 0).
380+ floating_size.unwrap_or_else(|| win.expected_size().unwrap_or_default())
380 };381 };
381 // Make sure fixed-size through window rules keeps working.382 // Make sure fixed-size through window rules keeps working.
382 let min_size = win.min_size();383 let min_size = win.min_size();
@@ -482,8 +483,10 @@ impl<W: LayoutElement> FloatingSpace<W> {
482 }483 }
483 }484 }
484 485
485- // Store the floating size.486+ // Store the floating size if we have one.
486- tile.set_floating_window_size(tile.window().expected_size());487+ if let Some(size) = tile.window().expected_size() {
488+ tile.set_floating_window_size(size);
489+ }
487 490
488 let width = ColumnWidth::Fixed(tile.window_size().w);491 let width = ColumnWidth::Fixed(tile.window_size().w);
489 RemovedTile {492 RemovedTile {
@@ -600,7 +603,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
600 win_width = ensure_min_max_size(win_width, min_size.w, max_size.w);603 win_width = ensure_min_max_size(win_width, min_size.w, max_size.w);
601 win_width = max(1, win_width);604 win_width = max(1, win_width);
602 605
603- let win_height = win.expected_size().h;606+ let win_height = win.expected_size().unwrap_or_default().h;
604 let win_height = ensure_min_max_size(win_height, min_size.h, max_size.h);607 let win_height = ensure_min_max_size(win_height, min_size.h, max_size.h);
605 608
606 let win_size = Size::from((win_width, win_height));609 let win_size = Size::from((win_width, win_height));
@@ -626,7 +629,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
626 win_height = ensure_min_max_size(win_height, min_size.h, max_size.h);629 win_height = ensure_min_max_size(win_height, min_size.h, max_size.h);
627 win_height = max(1, win_height);630 win_height = max(1, win_height);
628 631
629- let win_width = win.expected_size().w;632+ let win_width = win.expected_size().unwrap_or_default().w;
630 let win_width = ensure_min_max_size(win_width, min_size.w, max_size.w);633 let win_width = ensure_min_max_size(win_width, min_size.w, max_size.w);
631 634
632 let win_size = Size::from((win_width, win_height));635 let win_size = Size::from((win_width, win_height));
src/layout/mod.rsmodified+14 -6
@@ -197,7 +197,7 @@ pub trait LayoutElement {
197 /// Size previously requested through [`LayoutElement::request_size()`].197 /// Size previously requested through [`LayoutElement::request_size()`].
198 fn requested_size(&self) -> Option<Size<i32, Logical>>;198 fn requested_size(&self) -> Option<Size<i32, Logical>>;
199 199
200- /// Size that we expect this window has or will shortly have.200+ /// Non-fullscreen size that we expect this window has or will shortly have.
201 ///201 ///
202 /// This can be different from [`requested_size()`](LayoutElement::requested_size()). For202 /// This can be different from [`requested_size()`](LayoutElement::requested_size()). For
203 /// example, for floating windows this will generally return the current window size, rather203 /// example, for floating windows this will generally return the current window size, rather
@@ -205,10 +205,15 @@ pub trait LayoutElement {
205 /// size freely. But not always: if we just requested a floating window to resize and it hasn't205 /// size freely. But not always: if we just requested a floating window to resize and it hasn't
206 /// responded to it yet, this will return the newly requested size.206 /// responded to it yet, this will return the newly requested size.
207 ///207 ///
208- /// This function should never return a 0 size component.208+ /// This function should never return a 0 size component. `None` means there's no known
209+ /// expected size (for example, the window is fullscreen).
209 ///210 ///
210 /// The default impl is for testing only, it will not preserve the window's own size changes.211 /// The default impl is for testing only, it will not preserve the window's own size changes.
211- fn expected_size(&self) -> Size<i32, Logical> {212+ fn expected_size(&self) -> Option<Size<i32, Logical>> {
213+ if self.is_fullscreen() {
214+ return None;
215+ }
216+
212 let mut requested = self.requested_size().unwrap_or_default();217 let mut requested = self.requested_size().unwrap_or_default();
213 let current = self.size();218 let current = self.size();
214 if requested.w == 0 {219 if requested.w == 0 {
@@ -217,7 +222,7 @@ pub trait LayoutElement {
217 if requested.h == 0 {222 if requested.h == 0 {
218 requested.h = current.h;223 requested.h = current.h;
219 }224 }
220- requested225+ Some(requested)
221 }226 }
222 227
223 fn is_child_of(&self, parent: &Self) -> bool;228 fn is_child_of(&self, parent: &Self) -> bool;
@@ -2722,7 +2727,8 @@ impl<W: LayoutElement> Layout<W> {
2722 if move_.is_floating {2727 if move_.is_floating {
2723 let floating_size = move_.tile.floating_window_size();2728 let floating_size = move_.tile.floating_window_size();
2724 let win = move_.tile.window_mut();2729 let win = move_.tile.window_mut();
2725- let mut size = floating_size.unwrap_or_else(|| win.expected_size());2730+ let mut size =
2731+ floating_size.unwrap_or_else(|| win.expected_size().unwrap_or_default());
2726 // Make sure fixed-size through window rules keeps working.2732 // Make sure fixed-size through window rules keeps working.
2727 let min_size = win.min_size();2733 let min_size = win.min_size();
2728 let max_size = win.max_size();2734 let max_size = win.max_size();
@@ -3479,7 +3485,9 @@ impl<W: LayoutElement> Layout<W> {
3479 // Set the floating size so it takes into account any window resizing that3485 // Set the floating size so it takes into account any window resizing that
3480 // took place during the move.3486 // took place during the move.
3481 let mut tile = move_.tile;3487 let mut tile = move_.tile;
3482- tile.set_floating_window_size(tile.window().expected_size());3488+ if let Some(size) = tile.window().expected_size() {
3489+ tile.set_floating_window_size(size);
3490+ }
3483 3491
3484 mon.add_floating_tile(ws_idx, tile, Some(pos), true);3492 mon.add_floating_tile(ws_idx, tile, Some(pos), true);
3485 }3493 }
src/tests/floating.rsmodified+60 -0
@@ -725,3 +725,63 @@ fn interactive_move_restores_floating_size_when_set_to_floating() {
725 @""725 @""
726 );726 );
727 }727 }
728+
729+#[test]
730+fn floating_doesnt_store_fullscreen_size() {
731+ let mut f = Fixture::new();
732+ f.add_output(1, (1920, 1080));
733+ f.add_output(2, (1280, 720));
734+
735+ // Open a window fullscreen.
736+ let id = f.add_client();
737+ let window = f.client(id).create_window();
738+ let surface = window.surface.clone();
739+ window.set_fullscreen(None);
740+ window.commit();
741+ f.roundtrip(id);
742+
743+ let window = f.client(id).window(&surface);
744+ window.attach_new_buffer();
745+ window.set_size(1920, 1080);
746+ window.ack_last_and_commit();
747+ f.double_roundtrip(id);
748+
749+ let _ = f.client(id).window(&surface).recent_configures();
750+
751+ // Make it floating.
752+ f.niri().layout.toggle_window_floating(None);
753+ f.double_roundtrip(id);
754+
755+ // This should request 0 × 0 to unfullscreen.
756+ assert_snapshot!(
757+ f.client(id).window(&surface).format_recent_configures(),
758+ @"size: 0 × 0, bounds: 1920 × 1080, states: [Activated]"
759+ );
760+
761+ // Without committing, make it tiling again. We never committed while floating, so there's no
762+ // floating size to remember.
763+ f.niri().layout.toggle_window_floating(None);
764+ f.double_roundtrip(id);
765+
766+ // This should request the tiled size.
767+ assert_snapshot!(
768+ f.client(id).window(&surface).format_recent_configures(),
769+ @"size: 1920 × 1048, bounds: 1888 × 1048, states: [Activated]"
770+ );
771+
772+ // Commit in response.
773+ let window = f.client(id).window(&surface);
774+ window.set_size(100, 100);
775+ window.ack_last_and_commit();
776+ f.roundtrip(id);
777+
778+ // Make the window floating again.
779+ f.niri().layout.toggle_window_floating(None);
780+ f.double_roundtrip(id);
781+
782+ // This shouldn't request any size change, particularly not the fullscreen size.
783+ assert_snapshot!(
784+ f.client(id).window(&surface).format_recent_configures(),
785+ @"size: 100 × 100, bounds: 1920 × 1080, states: [Activated]"
786+ );
787+}
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@fsT-wfsAA-spA1.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1248 × 688, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@fsT-wfsAA-spA2.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1248 × 688, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@fsT-wfsAA-spB1.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1280 × 720, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@out1-fsT-wfsAA-spA1.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1248 × 688, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@out1-fsT-wfsAA-spA2.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1248 × 688, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@out1-fsT-wfsAA-spB1.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1280 × 720, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@out1-fsT-wfsAA-spB2.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1280 × 720, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-fsT-wfsAA-spA1.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1248 × 688, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-fsT-wfsAA-spA2.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1248 × 688, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-fsT-wfsAA-spB1.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1280 × 720, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-fsT-wfsAA-spB2.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1280 × 720, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-out1-fsT-wfsAA-spA1.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1248 × 688, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-out1-fsT-wfsAA-spA2.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1248 × 688, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-out1-fsT-wfsAA-spB1.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1280 × 720, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-out1-fsT-wfsAA-spB2.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1280 × 720, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-out2-fsT-wfsAA-spA1.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1248 × 688, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-out2-fsT-wfsAA-spA2.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1248 × 688, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-out2-fsT-wfsAA-spB1.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1280 × 720, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/tests/snapshots/niri__tests__window_opening__check_target_output_and_workspace@ws1-out2-fsT-wfsAA-spB2.snapmodified+1 -1
@@ -12,4 +12,4 @@ size: 1280 × 720, bounds: 1280 × 720, states: [Fullscreen]
12 12
13 post-map configures:13 post-map configures:
14 size: 0 × 0, bounds: 1280 × 720, states: []14 size: 0 × 0, bounds: 1280 × 720, states: []
15-size: 1 × 1, bounds: 1280 × 720, states: [Activated]15+size: 0 × 0, bounds: 1280 × 720, states: [Activated]
src/window/mapped.rsmodified+33 -14
@@ -829,8 +829,9 @@ impl LayoutElement for Mapped {
829 self.toplevel().with_pending_state(|state| state.size)829 self.toplevel().with_pending_state(|state| state.size)
830 }830 }
831 831
832- fn expected_size(&self) -> Size<i32, Logical> {832+ fn expected_size(&self) -> Option<Size<i32, Logical>> {
833- let current_size = self.window.geometry().size;833+ // We can only use current size if it's not fullscreen.
834+ let current_size = (!self.is_fullscreen()).then(|| self.window.geometry().size);
834 835
835 // Check if we should be using the current window size.836 // Check if we should be using the current window size.
836 //837 //
@@ -849,12 +850,17 @@ impl LayoutElement for Mapped {
849 return current_size;850 return current_size;
850 }851 }
851 852
852- let pending_size = with_toplevel_role(self.toplevel(), |role| {853+ let pending = with_toplevel_role(self.toplevel(), |role| {
853 // If we have a server-pending size change that we haven't sent yet, use that size.854 // If we have a server-pending size change that we haven't sent yet, use that size.
854 if let Some(server_pending) = &role.server_pending {855 if let Some(server_pending) = &role.server_pending {
855 let current_server = role.current_server_state();856 let current_server = role.current_server_state();
856 if server_pending.size != current_server.size {857 if server_pending.size != current_server.size {
857- return Some(server_pending.size.unwrap_or_default());858+ return Some((
859+ server_pending.size.unwrap_or_default(),
860+ server_pending
861+ .states
862+ .contains(xdg_toplevel::State::Fullscreen),
863+ ));
858 }864 }
859 }865 }
860 866
@@ -871,23 +877,36 @@ impl LayoutElement for Mapped {
871 877
872 if let Some(current_serial) = role.current_serial {878 if let Some(current_serial) = role.current_serial {
873 if !current_serial.is_no_older_than(&last_serial) {879 if !current_serial.is_no_older_than(&last_serial) {
874- return Some(last_sent.size.unwrap_or_default());880+ return Some((
881+ last_sent.size.unwrap_or_default(),
882+ last_sent.states.contains(xdg_toplevel::State::Fullscreen),
883+ ));
875 }884 }
876 }885 }
877 886
878 None887 None
879 });888 });
880 889
881- // If we have no pending size change (size change that the window hasn't committed to), or890+ if let Some((mut size, fullscreen)) = pending {
882- // if some component of the pending size change is zero, use the current window size.891+ // If the pending change is fullscreen, we can't use that size.
883- let mut size = pending_size.unwrap_or_default();892+ if fullscreen {
884- if size.w == 0 {893+ return None;
885- size.w = current_size.w;894+ }
886- }895+
887- if size.h == 0 {896+ // If some component of the pending size is zero, substitute it with the current window
888- size.h = current_size.h;897+ // size. But only if the current size is not fullscreen.
898+ if size.w == 0 {
899+ size.w = current_size?.w;
900+ }
901+ if size.h == 0 {
902+ size.h = current_size?.h;
903+ }
904+
905+ Some(size)
906+ } else {
907+ // No pending size, return the current size if it's non-fullscreen.
908+ current_size
889 }909 }
890- size
891 }910 }
892 911
893 fn is_child_of(&self, parent: &Self) -> bool {912 fn is_child_of(&self, parent: &Self) -> bool {