Skip to content

Commit

Permalink
Support prefers_home_indicator_hidden (#16005)
Browse files Browse the repository at this point in the history
# Objective

- Fixes #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 <[email protected]>
  • Loading branch information
Soulghost and alice-i-cecile authored Oct 31, 2024
1 parent 88d1692 commit db4a74b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/bevy_window/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,16 @@ pub struct Window {
///
/// [`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
pub titlebar_show_buttons: bool,
/// Sets whether the Window prefers the home indicator hidden.
///
/// Corresponds to [`WindowAttributesExtIOS::with_prefers_home_indicator_hidden`].
///
/// # Platform-specific
///
/// - Only used on iOS.
///
/// [`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
pub prefers_home_indicator_hidden: bool,
}

impl Default for Window {
Expand Down Expand Up @@ -429,6 +439,7 @@ impl Default for Window {
titlebar_transparent: false,
titlebar_show_title: true,
titlebar_show_buttons: true,
prefers_home_indicator_hidden: false,
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions crates/bevy_winit/src/winit_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ impl WinitWindows {
.with_titlebar_buttons_hidden(!window.titlebar_show_buttons);
}

#[cfg(target_os = "ios")]
{
use winit::platform::ios::WindowAttributesExtIOS;
winit_window_attributes = winit_window_attributes
.with_prefers_home_indicator_hidden(window.prefers_home_indicator_hidden);
}

let display_info = DisplayInfo {
window_physical_resolution: (
window.resolution.physical_width(),
Expand Down
2 changes: 2 additions & 0 deletions examples/mobile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ fn main() {
// on iOS, gestures must be enabled.
// This doesn't work on Android
recognize_rotation_gesture: true,
// Only has an effect on iOS
prefers_home_indicator_hidden: true,
..default()
}),
..default()
Expand Down

0 comments on commit db4a74b

Please sign in to comment.