Skip to content

Commit 4d9302b

Browse files
authored
Add borderless fullscreen mode for orbital (#4343)
1 parent 488c036 commit 4d9302b

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

winit-core/src/window.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,8 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug {
996996
/// separate spaces are not preferred.
997997
///
998998
/// The dock and the menu bar are disabled in exclusive fullscreen mode.
999-
/// - **Wayland:** Does not support exclusive fullscreen mode and will no-op a request.
999+
/// - **Orbital / Wayland:** Does not support exclusive fullscreen mode and will no-op a
1000+
/// request.
10001001
/// - **Windows:** Screen saver is disabled in fullscreen mode.
10011002
/// - **Web:** Passing a [`MonitorHandle`] or [`VideoMode`] that was not created with detailed
10021003
/// monitor permissions or calling without a [transient activation] does nothing.
@@ -1009,9 +1010,9 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug {
10091010
///
10101011
/// ## Platform-specific
10111012
///
1012-
/// - **Android / Orbital:** Will always return `None`.
1013+
/// - **Android:** Will always return `None`.
1014+
/// - **Orbital / Web:** Can only return `None` or `Borderless(None)`.
10131015
/// - **Wayland:** Can return `Borderless(None)` when there are no monitors.
1014-
/// - **Web:** Can only return `None` or `Borderless(None)`.
10151016
fn fullscreen(&self) -> Option<Fullscreen>;
10161017

10171018
/// Turn window decorations on or off.

winit-orbital/src/window.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const ORBITAL_FLAG_FRONT: char = 'f';
1919
const ORBITAL_FLAG_HIDDEN: char = 'h';
2020
const ORBITAL_FLAG_BORDERLESS: char = 'l';
2121
const ORBITAL_FLAG_MAXIMIZED: char = 'm';
22+
const ORBITAL_FLAG_FULLSCREEN: char = 'M';
2223
const ORBITAL_FLAG_RESIZABLE: char = 'r';
2324
const ORBITAL_FLAG_TRANSPARENT: char = 't';
2425

@@ -55,16 +56,17 @@ impl Window {
5556
// Async by default.
5657
let mut flag_str = ORBITAL_FLAG_ASYNC.to_string();
5758

58-
if attrs.maximized {
59+
// Fullscreen takes precedence over maximize
60+
if let Some(Fullscreen::Borderless(_)) = attrs.fullscreen {
61+
flag_str.push(ORBITAL_FLAG_FULLSCREEN);
62+
} else if attrs.maximized {
5963
flag_str.push(ORBITAL_FLAG_MAXIMIZED);
6064
}
6165

6266
if attrs.resizable {
6367
flag_str.push(ORBITAL_FLAG_RESIZABLE);
6468
}
6569

66-
// TODO: fullscreen
67-
6870
if attrs.transparent {
6971
flag_str.push(ORBITAL_FLAG_TRANSPARENT);
7072
}
@@ -323,10 +325,28 @@ impl CoreWindow for Window {
323325
self.get_flag(ORBITAL_FLAG_MAXIMIZED).unwrap_or(false)
324326
}
325327

326-
fn set_fullscreen(&self, _monitor: Option<Fullscreen>) {}
328+
fn set_fullscreen(&self, fullscreen: Option<Fullscreen>) {
329+
match fullscreen {
330+
Some(Fullscreen::Exclusive(..)) => {
331+
// TODO: exclusive fullscreen not supported on orbital
332+
},
333+
Some(Fullscreen::Borderless(_monitor)) => {
334+
// TODO: monitor selection not supported on orbital
335+
let _ = self.set_flag(ORBITAL_FLAG_FULLSCREEN, true);
336+
},
337+
None => {
338+
let _ = self.set_flag(ORBITAL_FLAG_FULLSCREEN, false);
339+
},
340+
}
341+
}
327342

328343
fn fullscreen(&self) -> Option<Fullscreen> {
329-
None
344+
if self.get_flag(ORBITAL_FLAG_FULLSCREEN).unwrap_or(false) {
345+
// TODO: monitor selection not supported on orbital
346+
Some(Fullscreen::Borderless(None))
347+
} else {
348+
None
349+
}
330350
}
331351

332352
#[inline]

winit/src/changelog/unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ changelog entry.
250250
### Fixed
251251

252252
- On Orbital, `MonitorHandle::name()` now returns `None` instead of a dummy name.
253+
- On Orbital, implement `fullscreen`.
253254
- On iOS, fixed `SurfaceResized` and `Window::surface_size` not reporting the size of the actual surface.
254255
- On macOS, fixed the scancode conversion for audio volume keys.
255256
- On macOS, fixed the scancode conversion for `IntlBackslash`.

0 commit comments

Comments
 (0)