mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 21:31:29 +11:00
MacOS: request_user_attention(bool -> enum) (#1021)
This commit is contained in:
parent
53a89f28a0
commit
c1f314ccdc
|
@ -15,6 +15,7 @@ and `WindowEvent::HoveredFile`.
|
||||||
- On macOS, drop unused Metal dependency.
|
- On macOS, drop unused Metal dependency.
|
||||||
- On Windows, fix the trail effect happening on transparent decorated windows. Borderless (or un-decorated) windows were not affected.
|
- On Windows, fix the trail effect happening on transparent decorated windows. Borderless (or un-decorated) windows were not affected.
|
||||||
- On Windows, fix `with_maximized` not properly setting window size to entire window.
|
- On Windows, fix `with_maximized` not properly setting window size to entire window.
|
||||||
|
- On macOS, change `WindowExtMacOS::request_user_attention()` to take an `enum` instead of a `bool`.
|
||||||
|
|
||||||
# 0.20.0 Alpha 1
|
# 0.20.0 Alpha 1
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,26 @@ use crate::{
|
||||||
window::{Window, WindowBuilder},
|
window::{Window, WindowBuilder},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Corresponds to `NSRequestUserAttentionType`.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
pub enum RequestUserAttentionType {
|
||||||
|
/// Corresponds to `NSCriticalRequest`.
|
||||||
|
///
|
||||||
|
/// Dock icon will bounce until the application is focused.
|
||||||
|
Critical,
|
||||||
|
|
||||||
|
/// Corresponds to `NSInformationalRequest`.
|
||||||
|
///
|
||||||
|
/// Dock icon will bounce once.
|
||||||
|
Informational,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for RequestUserAttentionType {
|
||||||
|
fn default() -> Self {
|
||||||
|
RequestUserAttentionType::Critical
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Additional methods on `Window` that are specific to MacOS.
|
/// Additional methods on `Window` that are specific to MacOS.
|
||||||
pub trait WindowExtMacOS {
|
pub trait WindowExtMacOS {
|
||||||
/// Returns a pointer to the cocoa `NSWindow` that is used by this window.
|
/// Returns a pointer to the cocoa `NSWindow` that is used by this window.
|
||||||
|
@ -22,11 +42,7 @@ pub trait WindowExtMacOS {
|
||||||
|
|
||||||
/// Request user attention, causing the application's dock icon to bounce.
|
/// Request user attention, causing the application's dock icon to bounce.
|
||||||
/// Note that this has no effect if the application is already focused.
|
/// Note that this has no effect if the application is already focused.
|
||||||
///
|
fn request_user_attention(&self, request_type: RequestUserAttentionType);
|
||||||
/// The `is_critical` flag has the following effects:
|
|
||||||
/// - `false`: the dock icon will only bounce once.
|
|
||||||
/// - `true`: the dock icon will bounce until the application is focused.
|
|
||||||
fn request_user_attention(&self, is_critical: bool);
|
|
||||||
|
|
||||||
/// Returns whether or not the window is in simple fullscreen mode.
|
/// Returns whether or not the window is in simple fullscreen mode.
|
||||||
fn simple_fullscreen(&self) -> bool;
|
fn simple_fullscreen(&self) -> bool;
|
||||||
|
@ -53,8 +69,8 @@ impl WindowExtMacOS for Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn request_user_attention(&self, is_critical: bool) {
|
fn request_user_attention(&self, request_type: RequestUserAttentionType) {
|
||||||
self.window.request_user_attention(is_critical)
|
self.window.request_user_attention(request_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -28,7 +28,7 @@ use crate::{
|
||||||
error::{ExternalError, NotSupportedError, OsError as RootOsError},
|
error::{ExternalError, NotSupportedError, OsError as RootOsError},
|
||||||
icon::Icon,
|
icon::Icon,
|
||||||
monitor::MonitorHandle as RootMonitorHandle,
|
monitor::MonitorHandle as RootMonitorHandle,
|
||||||
platform::macos::{ActivationPolicy, WindowExtMacOS},
|
platform::macos::{ActivationPolicy, RequestUserAttentionType, WindowExtMacOS},
|
||||||
platform_impl::platform::{
|
platform_impl::platform::{
|
||||||
app_state::AppState,
|
app_state::AppState,
|
||||||
ffi,
|
ffi,
|
||||||
|
@ -778,11 +778,13 @@ impl WindowExtMacOS for UnownedWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn request_user_attention(&self, is_critical: bool) {
|
fn request_user_attention(&self, request_type: RequestUserAttentionType) {
|
||||||
unsafe {
|
unsafe {
|
||||||
NSApp().requestUserAttention_(match is_critical {
|
NSApp().requestUserAttention_(match request_type {
|
||||||
true => NSRequestUserAttentionType::NSCriticalRequest,
|
RequestUserAttentionType::Critical => NSRequestUserAttentionType::NSCriticalRequest,
|
||||||
false => NSRequestUserAttentionType::NSInformationalRequest,
|
RequestUserAttentionType::Informational => {
|
||||||
|
NSRequestUserAttentionType::NSInformationalRequest
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue