mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Replace set_decorations
with set_prefers_status_bar_hidden
on iOS (#1092)
This commit is contained in:
parent
cf0b8babbd
commit
30b4f8dc9f
|
@ -19,7 +19,9 @@
|
||||||
- On iOS, disable overscan compensation for external displays (removes black
|
- On iOS, disable overscan compensation for external displays (removes black
|
||||||
bars surrounding the image).
|
bars surrounding the image).
|
||||||
- On Linux, the functions `is_wayland`, `is_x11`, `xlib_xconnection` and `wayland_display` have been moved to a new `EventLoopWindowTargetExtUnix` trait.
|
- On Linux, the functions `is_wayland`, `is_x11`, `xlib_xconnection` and `wayland_display` have been moved to a new `EventLoopWindowTargetExtUnix` trait.
|
||||||
|
- On iOS, add `set_prefers_status_bar_hidden` extension function instead of
|
||||||
|
hijacking `set_decorations` for this purpose.
|
||||||
|
|
||||||
# 0.20.0 Alpha 2 (2019-07-09)
|
# 0.20.0 Alpha 2 (2019-07-09)
|
||||||
|
|
||||||
- On X11, non-resizable windows now have maximize explicitly disabled.
|
- On X11, non-resizable windows now have maximize explicitly disabled.
|
||||||
|
|
|
@ -140,6 +140,7 @@ If your PR makes notable changes to Winit's features, please update this section
|
||||||
* Setting the `UIView` hidpi factor
|
* Setting the `UIView` hidpi factor
|
||||||
* Valid orientations
|
* Valid orientations
|
||||||
* Home indicator visibility
|
* Home indicator visibility
|
||||||
|
* Status bar visibility
|
||||||
* Deferrring system gestures
|
* Deferrring system gestures
|
||||||
* Support for custom `UIView` derived class
|
* Support for custom `UIView` derived class
|
||||||
* Getting the device idiom
|
* Getting the device idiom
|
||||||
|
@ -164,8 +165,8 @@ Legend:
|
||||||
|Window initialization |✔️ |✔️ |▢[#5] |✔️ |▢[#33]|▢[#33] |❓ |
|
|Window initialization |✔️ |✔️ |▢[#5] |✔️ |▢[#33]|▢[#33] |❓ |
|
||||||
|Providing pointer to init OpenGL |✔️ |✔️ |✔️ |✔️ |✔️ |✔️ |❓ |
|
|Providing pointer to init OpenGL |✔️ |✔️ |✔️ |✔️ |✔️ |✔️ |❓ |
|
||||||
|Providing pointer to init Vulkan |✔️ |✔️ |✔️ |✔️ |✔️ |❓ |**N/A** |
|
|Providing pointer to init Vulkan |✔️ |✔️ |✔️ |✔️ |✔️ |❓ |**N/A** |
|
||||||
|Window decorations |✔️ |✔️ |✔️ |▢[#306] |**N/A**|✔️ |**N/A** |
|
|Window decorations |✔️ |✔️ |✔️ |▢[#306] |**N/A**|**N/A**|**N/A** |
|
||||||
|Window decorations toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|✔️ |**N/A** |
|
|Window decorations toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A** |
|
||||||
|Window resizing |✔️ |▢[#219]|✔️ |▢[#306] |**N/A**|**N/A**|❓ |
|
|Window resizing |✔️ |▢[#219]|✔️ |▢[#306] |**N/A**|**N/A**|❓ |
|
||||||
|Window resize increments |❌ |❌ |❌ |❌ |❌ |❌ |❌ |
|
|Window resize increments |❌ |❌ |❌ |❌ |❌ |❌ |❌ |
|
||||||
|Window transparency |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A** |
|
|Window transparency |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A** |
|
||||||
|
|
|
@ -80,6 +80,16 @@ pub trait WindowExtIOS {
|
||||||
/// and then calls
|
/// and then calls
|
||||||
/// [`-[UIViewController setNeedsUpdateOfScreenEdgesDeferringSystemGestures]`](https://developer.apple.com/documentation/uikit/uiviewcontroller/2887507-setneedsupdateofscreenedgesdefer?language=objc).
|
/// [`-[UIViewController setNeedsUpdateOfScreenEdgesDeferringSystemGestures]`](https://developer.apple.com/documentation/uikit/uiviewcontroller/2887507-setneedsupdateofscreenedgesdefer?language=objc).
|
||||||
fn set_preferred_screen_edges_deferring_system_gestures(&self, edges: ScreenEdge);
|
fn set_preferred_screen_edges_deferring_system_gestures(&self, edges: ScreenEdge);
|
||||||
|
|
||||||
|
/// Sets whether the [`Window`] prefers the status bar hidden.
|
||||||
|
///
|
||||||
|
/// The default is to prefer showing the status bar.
|
||||||
|
///
|
||||||
|
/// This changes the value returned by
|
||||||
|
/// [`-[UIViewController prefersStatusBarHidden]`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621440-prefersstatusbarhidden?language=objc),
|
||||||
|
/// and then calls
|
||||||
|
/// [`-[UIViewController setNeedsStatusBarAppearanceUpdate]`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621354-setneedsstatusbarappearanceupdat?language=objc).
|
||||||
|
fn set_prefers_status_bar_hidden(&self, hidden: bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowExtIOS for Window {
|
impl WindowExtIOS for Window {
|
||||||
|
@ -118,6 +128,11 @@ impl WindowExtIOS for Window {
|
||||||
self.window
|
self.window
|
||||||
.set_preferred_screen_edges_deferring_system_gestures(edges)
|
.set_preferred_screen_edges_deferring_system_gestures(edges)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_prefers_status_bar_hidden(&self, hidden: bool) {
|
||||||
|
self.window.set_prefers_status_bar_hidden(hidden)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Additional methods on [`WindowBuilder`] that are specific to iOS.
|
/// Additional methods on [`WindowBuilder`] that are specific to iOS.
|
||||||
|
@ -163,6 +178,14 @@ pub trait WindowBuilderExtIOS {
|
||||||
self,
|
self,
|
||||||
edges: ScreenEdge,
|
edges: ScreenEdge,
|
||||||
) -> WindowBuilder;
|
) -> WindowBuilder;
|
||||||
|
|
||||||
|
/// Sets whether the [`Window`] prefers the status bar hidden.
|
||||||
|
///
|
||||||
|
/// The default is to prefer showing the status bar.
|
||||||
|
///
|
||||||
|
/// This sets the initial value returned by
|
||||||
|
/// [`-[UIViewController prefersStatusBarHidden]`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621440-prefersstatusbarhidden?language=objc).
|
||||||
|
fn with_prefers_status_bar_hidden(self, hidden: bool) -> WindowBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowBuilderExtIOS for WindowBuilder {
|
impl WindowBuilderExtIOS for WindowBuilder {
|
||||||
|
@ -199,6 +222,12 @@ impl WindowBuilderExtIOS for WindowBuilder {
|
||||||
.preferred_screen_edges_deferring_system_gestures = edges;
|
.preferred_screen_edges_deferring_system_gestures = edges;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn with_prefers_status_bar_hidden(mut self, hidden: bool) -> WindowBuilder {
|
||||||
|
self.platform_specific.prefers_status_bar_hidden = hidden;
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Additional methods on [`MonitorHandle`] that are specific to iOS.
|
/// Additional methods on [`MonitorHandle`] that are specific to iOS.
|
||||||
|
|
|
@ -331,7 +331,7 @@ pub unsafe fn create_view(
|
||||||
|
|
||||||
// requires main thread
|
// requires main thread
|
||||||
pub unsafe fn create_view_controller(
|
pub unsafe fn create_view_controller(
|
||||||
window_attributes: &WindowAttributes,
|
_window_attributes: &WindowAttributes,
|
||||||
platform_attributes: &PlatformSpecificWindowBuilderAttributes,
|
platform_attributes: &PlatformSpecificWindowBuilderAttributes,
|
||||||
view: id,
|
view: id,
|
||||||
) -> id {
|
) -> id {
|
||||||
|
@ -347,10 +347,10 @@ pub unsafe fn create_view_controller(
|
||||||
!view_controller.is_null(),
|
!view_controller.is_null(),
|
||||||
"Failed to initialize `UIViewController` instance"
|
"Failed to initialize `UIViewController` instance"
|
||||||
);
|
);
|
||||||
let status_bar_hidden = if window_attributes.decorations {
|
let status_bar_hidden = if platform_attributes.prefers_status_bar_hidden {
|
||||||
NO
|
|
||||||
} else {
|
|
||||||
YES
|
YES
|
||||||
|
} else {
|
||||||
|
NO
|
||||||
};
|
};
|
||||||
let idiom = event_loop::get_idiom();
|
let idiom = event_loop::get_idiom();
|
||||||
let supported_orientations = UIInterfaceOrientationMask::from_valid_orientations_idiom(
|
let supported_orientations = UIInterfaceOrientationMask::from_valid_orientations_idiom(
|
||||||
|
|
|
@ -214,14 +214,8 @@ impl Inner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_decorations(&self, decorations: bool) {
|
pub fn set_decorations(&self, _decorations: bool) {
|
||||||
unsafe {
|
warn!("`Window::set_decorations` is ignored on iOS")
|
||||||
let status_bar_hidden = if decorations { NO } else { YES };
|
|
||||||
let () = msg_send![
|
|
||||||
self.view_controller,
|
|
||||||
setPrefersStatusBarHidden: status_bar_hidden
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_always_on_top(&self, _always_on_top: bool) {
|
pub fn set_always_on_top(&self, _always_on_top: bool) {
|
||||||
|
@ -414,6 +408,16 @@ impl Inner {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_prefers_status_bar_hidden(&self, hidden: bool) {
|
||||||
|
unsafe {
|
||||||
|
let status_bar_hidden = if hidden { YES } else { NO };
|
||||||
|
let () = msg_send![
|
||||||
|
self.view_controller,
|
||||||
|
setPrefersStatusBarHidden: status_bar_hidden
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Inner {
|
impl Inner {
|
||||||
|
@ -536,6 +540,7 @@ pub struct PlatformSpecificWindowBuilderAttributes {
|
||||||
pub hidpi_factor: Option<f64>,
|
pub hidpi_factor: Option<f64>,
|
||||||
pub valid_orientations: ValidOrientations,
|
pub valid_orientations: ValidOrientations,
|
||||||
pub prefers_home_indicator_hidden: bool,
|
pub prefers_home_indicator_hidden: bool,
|
||||||
|
pub prefers_status_bar_hidden: bool,
|
||||||
pub preferred_screen_edges_deferring_system_gestures: ScreenEdge,
|
pub preferred_screen_edges_deferring_system_gestures: ScreenEdge,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,6 +551,7 @@ impl Default for PlatformSpecificWindowBuilderAttributes {
|
||||||
hidpi_factor: None,
|
hidpi_factor: None,
|
||||||
valid_orientations: Default::default(),
|
valid_orientations: Default::default(),
|
||||||
prefers_home_indicator_hidden: false,
|
prefers_home_indicator_hidden: false,
|
||||||
|
prefers_status_bar_hidden: false,
|
||||||
preferred_screen_edges_deferring_system_gestures: Default::default(),
|
preferred_screen_edges_deferring_system_gestures: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -585,10 +585,7 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
///
|
///
|
||||||
/// - **iOS:** Can only be called on the main thread. Controls whether the status bar is hidden
|
/// - **iOS:** Has no effect.
|
||||||
/// via [`setPrefersStatusBarHidden`].
|
|
||||||
///
|
|
||||||
/// [`setPrefersStatusBarHidden`]: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621440-prefersstatusbarhidden?language=objc
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_decorations(&self, decorations: bool) {
|
pub fn set_decorations(&self, decorations: bool) {
|
||||||
self.window.set_decorations(decorations)
|
self.window.set_decorations(decorations)
|
||||||
|
|
Loading…
Reference in a new issue