From 4d9302b33cba73557db8a50e443b18331437102a Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 4 Sep 2025 13:14:41 -0700 Subject: [PATCH] Add borderless fullscreen mode for orbital (#4343) --- winit-core/src/window.rs | 7 ++++--- winit-orbital/src/window.rs | 30 +++++++++++++++++++++++++----- winit/src/changelog/unreleased.md | 1 + 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/winit-core/src/window.rs b/winit-core/src/window.rs index 2618e2dc..d2d1d187 100644 --- a/winit-core/src/window.rs +++ b/winit-core/src/window.rs @@ -996,7 +996,8 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug { /// separate spaces are not preferred. /// /// The dock and the menu bar are disabled in exclusive fullscreen mode. - /// - **Wayland:** Does not support exclusive fullscreen mode and will no-op a request. + /// - **Orbital / Wayland:** Does not support exclusive fullscreen mode and will no-op a + /// request. /// - **Windows:** Screen saver is disabled in fullscreen mode. /// - **Web:** Passing a [`MonitorHandle`] or [`VideoMode`] that was not created with detailed /// monitor permissions or calling without a [transient activation] does nothing. @@ -1009,9 +1010,9 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug { /// /// ## Platform-specific /// - /// - **Android / Orbital:** Will always return `None`. + /// - **Android:** Will always return `None`. + /// - **Orbital / Web:** Can only return `None` or `Borderless(None)`. /// - **Wayland:** Can return `Borderless(None)` when there are no monitors. - /// - **Web:** Can only return `None` or `Borderless(None)`. fn fullscreen(&self) -> Option; /// Turn window decorations on or off. diff --git a/winit-orbital/src/window.rs b/winit-orbital/src/window.rs index 7f3918f7..4858b29b 100644 --- a/winit-orbital/src/window.rs +++ b/winit-orbital/src/window.rs @@ -19,6 +19,7 @@ const ORBITAL_FLAG_FRONT: char = 'f'; const ORBITAL_FLAG_HIDDEN: char = 'h'; const ORBITAL_FLAG_BORDERLESS: char = 'l'; const ORBITAL_FLAG_MAXIMIZED: char = 'm'; +const ORBITAL_FLAG_FULLSCREEN: char = 'M'; const ORBITAL_FLAG_RESIZABLE: char = 'r'; const ORBITAL_FLAG_TRANSPARENT: char = 't'; @@ -55,7 +56,10 @@ impl Window { // Async by default. let mut flag_str = ORBITAL_FLAG_ASYNC.to_string(); - if attrs.maximized { + // Fullscreen takes precedence over maximize + if let Some(Fullscreen::Borderless(_)) = attrs.fullscreen { + flag_str.push(ORBITAL_FLAG_FULLSCREEN); + } else if attrs.maximized { flag_str.push(ORBITAL_FLAG_MAXIMIZED); } @@ -63,8 +67,6 @@ impl Window { flag_str.push(ORBITAL_FLAG_RESIZABLE); } - // TODO: fullscreen - if attrs.transparent { flag_str.push(ORBITAL_FLAG_TRANSPARENT); } @@ -323,10 +325,28 @@ impl CoreWindow for Window { self.get_flag(ORBITAL_FLAG_MAXIMIZED).unwrap_or(false) } - fn set_fullscreen(&self, _monitor: Option) {} + fn set_fullscreen(&self, fullscreen: Option) { + match fullscreen { + Some(Fullscreen::Exclusive(..)) => { + // TODO: exclusive fullscreen not supported on orbital + }, + Some(Fullscreen::Borderless(_monitor)) => { + // TODO: monitor selection not supported on orbital + let _ = self.set_flag(ORBITAL_FLAG_FULLSCREEN, true); + }, + None => { + let _ = self.set_flag(ORBITAL_FLAG_FULLSCREEN, false); + }, + } + } fn fullscreen(&self) -> Option { - None + if self.get_flag(ORBITAL_FLAG_FULLSCREEN).unwrap_or(false) { + // TODO: monitor selection not supported on orbital + Some(Fullscreen::Borderless(None)) + } else { + None + } } #[inline] diff --git a/winit/src/changelog/unreleased.md b/winit/src/changelog/unreleased.md index 6c7cbbac..89ca902b 100644 --- a/winit/src/changelog/unreleased.md +++ b/winit/src/changelog/unreleased.md @@ -250,6 +250,7 @@ changelog entry. ### Fixed - On Orbital, `MonitorHandle::name()` now returns `None` instead of a dummy name. +- On Orbital, implement `fullscreen`. - On iOS, fixed `SurfaceResized` and `Window::surface_size` not reporting the size of the actual surface. - On macOS, fixed the scancode conversion for audio volume keys. - On macOS, fixed the scancode conversion for `IntlBackslash`.