layout: Unfullscreen before removing for interactive move
Browse files at this commitad3847fad9c8b5ea2c4a3f9def66cd02ffdfd0e2Parent: 9bd860b2 changed files +50 -28
- src/layout/mod.rs +9 -28
- src/tests/fullscreen.rs +41 -0
src/layout/mod.rsmodified+9 -28
| @@ -3838,11 +3838,19 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3838 | // in the middle of interactive_move_update() and the confusion that causes. | 3838 | // in the middle of interactive_move_update() and the confusion that causes. |
| 3839 | self.interactive_move = None; | 3839 | self.interactive_move = None; |
| 3840 | 3840 | ||
| 3841 | + // Unset fullscreen before removing the tile. This will restore its size properly, | ||
| 3842 | + // and move it to floating if needed, so we don't have to deal with that here. | ||
| 3843 | + let ws = self | ||
| 3844 | + .workspaces_mut() | ||
| 3845 | + .find(|ws| ws.has_window(&window_id)) | ||
| 3846 | + .unwrap(); | ||
| 3847 | + ws.set_fullscreen(window, false); | ||
| 3848 | + | ||
| 3841 | let RemovedTile { | 3849 | let RemovedTile { |
| 3842 | mut tile, | 3850 | mut tile, |
| 3843 | width, | 3851 | width, |
| 3844 | is_full_width, | 3852 | is_full_width, |
| 3845 | - mut is_floating, | 3853 | + is_floating, |
| 3846 | } = self.remove_window(window, Transaction::new()).unwrap(); | 3854 | } = self.remove_window(window, Transaction::new()).unwrap(); |
| 3847 | 3855 | ||
| 3848 | tile.stop_move_animations(); | 3856 | tile.stop_move_animations(); |
| @@ -3861,33 +3869,6 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3861 | .adjusted_for_scale(scale); | 3869 | .adjusted_for_scale(scale); |
| 3862 | tile.update_config(view_size, scale, Rc::new(options)); | 3870 | tile.update_config(view_size, scale, Rc::new(options)); |
| 3863 | 3871 | ||
| 3864 | - // Unfullscreen. | ||
| 3865 | - let floating_size = tile.floating_window_size; | ||
| 3866 | - let unfullscreen_to_floating = tile.unfullscreen_to_floating; | ||
| 3867 | - let win = tile.window_mut(); | ||
| 3868 | - if win.is_pending_fullscreen() { | ||
| 3869 | - // If we're unfullscreening to floating, use the stored floating size, | ||
| 3870 | - // otherwise use (0, 0). | ||
| 3871 | - let mut size = if unfullscreen_to_floating { | ||
| 3872 | - floating_size.unwrap_or_default() | ||
| 3873 | - } else { | ||
| 3874 | - Size::from((0, 0)) | ||
| 3875 | - }; | ||
| 3876 | - | ||
| 3877 | - // Apply min/max size window rules. If requesting a concrete size, apply | ||
| 3878 | - // completely; if requesting (0, 0), apply only when min/max results in a fixed | ||
| 3879 | - // size. | ||
| 3880 | - let min_size = win.min_size(); | ||
| 3881 | - let max_size = win.max_size(); | ||
| 3882 | - size.w = ensure_min_max_size_maybe_zero(size.w, min_size.w, max_size.w); | ||
| 3883 | - size.h = ensure_min_max_size_maybe_zero(size.h, min_size.h, max_size.h); | ||
| 3884 | - | ||
| 3885 | - win.request_size_once(size, true); | ||
| 3886 | - | ||
| 3887 | - // If we're unfullscreening to floating, default to the floating layout. | ||
| 3888 | - is_floating = unfullscreen_to_floating; | ||
| 3889 | - } | ||
| 3890 | - | ||
| 3891 | if is_floating { | 3872 | if is_floating { |
| 3892 | // Unlock the view in case we locked it moving a fullscreen window that is | 3873 | // Unlock the view in case we locked it moving a fullscreen window that is |
| 3893 | // going to unfullscreen to floating. | 3874 | // going to unfullscreen to floating. |
src/tests/fullscreen.rsmodified+41 -0
| @@ -1,5 +1,6 @@ | |||
| 1 | use client::ClientId; | 1 | use client::ClientId; |
| 2 | use insta::assert_snapshot; | 2 | use insta::assert_snapshot; |
| 3 | +use smithay::utils::Point; | ||
| 3 | use wayland_client::protocol::wl_surface::WlSurface; | 4 | use wayland_client::protocol::wl_surface::WlSurface; |
| 4 | 5 | ||
| 5 | use super::*; | 6 | use super::*; |
| @@ -214,3 +215,43 @@ fn unfullscreen_before_fullscreen_ack_doesnt_prevent_view_offset_save_restore() | |||
| 214 | // The view position should restore to the first window. | 215 | // The view position should restore to the first window. |
| 215 | assert_snapshot!(f.niri().layout.active_workspace().unwrap().scrolling().view_pos(), @"-16"); | 216 | assert_snapshot!(f.niri().layout.active_workspace().unwrap().scrolling().view_pos(), @"-16"); |
| 216 | } | 217 | } |
| 218 | + | ||
| 219 | +#[test] | ||
| 220 | +fn interactive_move_unfullscreen_to_scrolling_restores_size() { | ||
| 221 | + let (mut f, id, surface) = set_up(); | ||
| 222 | + | ||
| 223 | + let _ = f.client(id).window(&surface).recent_configures(); | ||
| 224 | + | ||
| 225 | + let niri = f.niri(); | ||
| 226 | + let mapped = niri.layout.windows().next().unwrap().1; | ||
| 227 | + let window = mapped.window.clone(); | ||
| 228 | + niri.layout.set_fullscreen(&window, true); | ||
| 229 | + f.double_roundtrip(id); | ||
| 230 | + | ||
| 231 | + // This should request a fullscreen size. | ||
| 232 | + assert_snapshot!( | ||
| 233 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 234 | + @"size: 1920 × 1080, bounds: 1888 × 1048, states: [Activated, Fullscreen]" | ||
| 235 | + ); | ||
| 236 | + | ||
| 237 | + // Start an interactive move which causes an unfullscreen. | ||
| 238 | + let output = f.niri_output(1); | ||
| 239 | + let niri = f.niri(); | ||
| 240 | + let mapped = niri.layout.windows().next().unwrap().1; | ||
| 241 | + let window = mapped.window.clone(); | ||
| 242 | + niri.layout | ||
| 243 | + .interactive_move_begin(window.clone(), &output, Point::default()); | ||
| 244 | + niri.layout.interactive_move_update( | ||
| 245 | + &window, | ||
| 246 | + Point::from((1000., 0.)), | ||
| 247 | + output, | ||
| 248 | + Point::default(), | ||
| 249 | + ); | ||
| 250 | + f.double_roundtrip(id); | ||
| 251 | + | ||
| 252 | + // This should request the tiled size. | ||
| 253 | + assert_snapshot!( | ||
| 254 | + f.client(id).window(&surface).format_recent_configures(), | ||
| 255 | + @"size: 936 × 1048, bounds: 1920 × 1080, states: [Activated]" | ||
| 256 | + ); | ||
| 257 | +} | ||