Skip to content

Commit db4a74b

Browse files
Support prefers_home_indicator_hidden (bevyengine#16005)
# Objective - Fixes bevyengine#15757 ## Solution - Add the platform specific property `prefers_home_indicator_hidden` to bevy's Window configuration, and applying it by invoking `with_prefers_home_indicator_hidden` in `winit`. ## Testing - I have tested the `bevy_mobile_example` on the iOS platform. ## Showcase - Currently, the `prefers_home_indicator_hidden` is enabled in the bevy_mobile_example demo. You can test it with an iOS device. The home indicator will disappear after several seconds of inactivity in the bottom areas. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
1 parent 88d1692 commit db4a74b

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

crates/bevy_window/src/window.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,16 @@ pub struct Window {
388388
///
389389
/// [`WindowAttributesExtMacOS::with_titlebar_buttons_hidden`]: https://docs.rs/winit/latest/x86_64-apple-darwin/winit/platform/macos/trait.WindowAttributesExtMacOS.html#tymethod.with_titlebar_buttons_hidden
390390
pub titlebar_show_buttons: bool,
391+
/// Sets whether the Window prefers the home indicator hidden.
392+
///
393+
/// Corresponds to [`WindowAttributesExtIOS::with_prefers_home_indicator_hidden`].
394+
///
395+
/// # Platform-specific
396+
///
397+
/// - Only used on iOS.
398+
///
399+
/// [`WindowAttributesExtIOS::with_prefers_home_indicator_hidden`]: https://docs.rs/winit/latest/x86_64-apple-darwin/winit/platform/ios/trait.WindowAttributesExtIOS.html#tymethod.with_prefers_home_indicator_hidden
400+
pub prefers_home_indicator_hidden: bool,
391401
}
392402

393403
impl Default for Window {
@@ -429,6 +439,7 @@ impl Default for Window {
429439
titlebar_transparent: false,
430440
titlebar_show_title: true,
431441
titlebar_show_buttons: true,
442+
prefers_home_indicator_hidden: false,
432443
}
433444
}
434445
}

crates/bevy_winit/src/winit_windows.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ impl WinitWindows {
140140
.with_titlebar_buttons_hidden(!window.titlebar_show_buttons);
141141
}
142142

143+
#[cfg(target_os = "ios")]
144+
{
145+
use winit::platform::ios::WindowAttributesExtIOS;
146+
winit_window_attributes = winit_window_attributes
147+
.with_prefers_home_indicator_hidden(window.prefers_home_indicator_hidden);
148+
}
149+
143150
let display_info = DisplayInfo {
144151
window_physical_resolution: (
145152
window.resolution.physical_width(),

examples/mobile/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ fn main() {
2727
// on iOS, gestures must be enabled.
2828
// This doesn't work on Android
2929
recognize_rotation_gesture: true,
30+
// Only has an effect on iOS
31+
prefers_home_indicator_hidden: true,
3032
..default()
3133
}),
3234
..default()

0 commit comments

Comments
 (0)