aboutsummaryrefslogtreecommitdiff
path: root/src/layout/workspace.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-12-16 09:03:50 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-12-30 20:12:37 +0300
commitf38acfe98848746598233a275ac3ee226f3df658 (patch)
treecffe239a9cb01cae9ddabbe1a01288904783d842 /src/layout/workspace.rs
parent965619d0964973966bbd1d9d8087d1e8e8ff4867 (diff)
downloadniri-f38acfe98848746598233a275ac3ee226f3df658.tar.gz
niri-f38acfe98848746598233a275ac3ee226f3df658.tar.bz2
niri-f38acfe98848746598233a275ac3ee226f3df658.zip
layout: Remember whether to unfullscreen back into floating
Diffstat (limited to 'src/layout/workspace.rs')
-rw-r--r--src/layout/workspace.rs37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index d4463636..6220fd1e 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -471,12 +471,13 @@ impl<W: LayoutElement> Workspace<W> {
is_full_width: bool,
is_floating: bool,
) {
- let tile = Tile::new(
+ let mut tile = Tile::new(
window,
self.scale.fractional_scale(),
self.clock.clone(),
self.options.clone(),
);
+ tile.set_unfullscreen_to_floating(is_floating);
if is_floating {
self.add_floating_tile(tile, None, activate);
@@ -541,12 +542,13 @@ impl<W: LayoutElement> Workspace<W> {
// TODO: smarter enum, so you can override is_floating = false for floating right_of.
is_floating: bool,
) {
- let tile = Tile::new(
+ let mut tile = Tile::new(
window,
self.scale.fractional_scale(),
self.clock.clone(),
self.options.clone(),
);
+ tile.set_unfullscreen_to_floating(is_floating);
self.add_tile_right_of(right_of, tile, width, is_full_width, is_floating);
}
@@ -972,16 +974,45 @@ impl<W: LayoutElement> Workspace<W> {
}
pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) {
+ let mut unfullscreen_to_floating = false;
if self.floating.has_window(window) {
if is_fullscreen {
+ unfullscreen_to_floating = true;
self.toggle_window_floating(Some(window));
} else {
// Floating windows are never fullscreen, so this is an unfullscreen request for an
// already unfullscreen window.
return;
}
+ } else if !is_fullscreen {
+ // The window is in the scrolling layout and we're requesting an unfullscreen. If it is
+ // indeed fullscreen (i.e. this isn't a duplicate unfullscreen request), then we may
+ // need to unfullscreen into floating.
+ let tile = self
+ .scrolling
+ .tiles()
+ .find(|tile| tile.window().id() == window)
+ .unwrap();
+ if tile.window().is_pending_fullscreen() && tile.unfullscreen_to_floating() {
+ // Unfullscreen and float in one call so it has a chance to notice and request a
+ // (0, 0) size, rather than the scrolling column size.
+ self.toggle_window_floating(Some(window));
+ return;
+ }
+ }
+
+ let changed = self.scrolling.set_fullscreen(window, is_fullscreen);
+
+ // When going to fullscreen, remember if we should unfullscreen to floating.
+ if changed && is_fullscreen {
+ let tile = self
+ .scrolling
+ .tiles_mut()
+ .find(|tile| tile.window().id() == window)
+ .unwrap();
+
+ tile.set_unfullscreen_to_floating(unfullscreen_to_floating);
}
- self.scrolling.set_fullscreen(window, is_fullscreen);
}
pub fn toggle_fullscreen(&mut self, window: &W::Id) {