diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-22 09:28:57 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-30 20:12:37 +0300 |
| commit | f4f2a1f6deeffa5c13d871c534ac99ea398e9175 (patch) | |
| tree | 52c1797d384c7cfc8b5950be5b6b406434dba1fd /src/layout/floating.rs | |
| parent | a440805ea1136f6e0cb852ff71b89b12dd426a7d (diff) | |
| download | niri-f4f2a1f6deeffa5c13d871c534ac99ea398e9175.tar.gz niri-f4f2a1f6deeffa5c13d871c534ac99ea398e9175.tar.bz2 niri-f4f2a1f6deeffa5c13d871c534ac99ea398e9175.zip | |
floating: Remember and restore window size
Diffstat (limited to 'src/layout/floating.rs')
| -rw-r--r-- | src/layout/floating.rs | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/layout/floating.rs b/src/layout/floating.rs index 4565e2f2..f870b2f2 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -366,24 +366,27 @@ impl<W: LayoutElement> FloatingSpace<W> { ) { tile.update_config(self.scale, self.options.clone()); + // Restore the previous floating window size, and in case the tile is fullscreen, + // unfullscreen it. + let floating_size = tile.floating_window_size(); let win = tile.window_mut(); - let size = if win.is_pending_fullscreen() { - let mut size = Size::from((0, 0)); - - // Make sure fixed-size through window rules keeps working. - let min_size = win.min_size(); - let max_size = win.max_size(); - if min_size.w == max_size.w { - size.w = min_size.w; - } - if min_size.h == max_size.h { - size.h = min_size.h; - } - - size + let mut size = if win.is_pending_fullscreen() { + // If the window was fullscreen without a floating size, ask for (0, 0). + floating_size.unwrap_or_default() } else { - win.size() + // If the window wasn't fullscreen without a floating size (e.g. it was tiled before), + // ask for the current size. + floating_size.unwrap_or_else(|| win.size_to_request()) }; + // Make sure fixed-size through window rules keeps working. + let min_size = win.min_size(); + let max_size = win.max_size(); + if min_size.w != 0 && min_size.w == max_size.w { + size.w = min_size.w; + } + if min_size.h != 0 && min_size.h == max_size.h { + size.h = min_size.h; + } win.request_size_once(size, true); if activate || self.tiles.is_empty() { @@ -761,6 +764,10 @@ impl<W: LayoutElement> FloatingSpace<W> { tile.update_window(); data.update(tile); + // Update the stored floating window size. + let floating_size = tile.window().size_to_request(); + tile.set_floating_window_size(floating_size); + // When resizing by top/left edge, update the position accordingly. if let Some(resize) = resize { let mut offset = Point::from((0., 0.)); |
