diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-03-17 14:56:29 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-03-17 22:31:19 -0700 |
| commit | 39f52b75856936db01325aa1c7f15fe8f379485d (patch) | |
| tree | 08fcbf8c938aa2b10a9be3014bf292f17225063d /src/layout/mod.rs | |
| parent | b447b1f4de65ee706bdbbdb9b650ab030459c0fb (diff) | |
| download | niri-39f52b75856936db01325aa1c7f15fe8f379485d.tar.gz niri-39f52b75856936db01325aa1c7f15fe8f379485d.tar.bz2 niri-39f52b75856936db01325aa1c7f15fe8f379485d.zip | |
Implement toggle-windowed-fullscreen
Windowed, or fake, or detached, fullscreen, is when a window thinks that it's
fullscreen, but the compositor treats it as a normal window.
Diffstat (limited to 'src/layout/mod.rs')
| -rw-r--r-- | src/layout/mod.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 15d48d6a..64e6877c 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -244,6 +244,13 @@ pub trait LayoutElement { Some(requested) } + fn is_pending_windowed_fullscreen(&self) -> bool { + false + } + fn request_windowed_fullscreen(&mut self, value: bool) { + let _ = value; + } + fn is_child_of(&self, parent: &Self) -> bool; fn rules(&self) -> &ResolvedWindowRules; @@ -3458,6 +3465,20 @@ impl<W: LayoutElement> Layout<W> { } pub fn set_fullscreen(&mut self, id: &W::Id, is_fullscreen: bool) { + // Check if this is a request to unset the windowed fullscreen state. + if !is_fullscreen { + let mut handled = false; + self.with_windows_mut(|window, _| { + if window.id() == id && window.is_pending_windowed_fullscreen() { + window.request_windowed_fullscreen(false); + handled = true; + } + }); + if handled { + return; + } + } + if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move { if move_.tile.window().id() == id { return; @@ -3487,6 +3508,26 @@ impl<W: LayoutElement> Layout<W> { } } + pub fn toggle_windowed_fullscreen(&mut self, id: &W::Id) { + let (_, window) = self.windows().find(|(_, win)| win.id() == id).unwrap(); + if window.is_pending_fullscreen() { + // Remove the real fullscreen. + for ws in self.workspaces_mut() { + if ws.has_window(id) { + ws.set_fullscreen(id, false); + break; + } + } + } + + // This will switch is_pending_fullscreen() to false right away. + self.with_windows_mut(|window, _| { + if window.id() == id { + window.request_windowed_fullscreen(!window.is_pending_windowed_fullscreen()); + } + }); + } + pub fn workspace_switch_gesture_begin(&mut self, output: &Output, is_touchpad: bool) { let monitors = match &mut self.monitor_set { MonitorSet::Normal { monitors, .. } => monitors, |
