mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-26 03:36:32 +11:00
macOS: add function to hide other applications
This commit is contained in:
parent
ff66bdda7c
commit
03335cef85
2 changed files with 9 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
- On Web, prevent the webpage from scrolling when the user is focused on a winit canvas
|
- On Web, prevent the webpage from scrolling when the user is focused on a winit canvas
|
||||||
|
|
||||||
- On Wayland, fix deadlock when calling to `set_inner_size` from a callback.
|
- On Wayland, fix deadlock when calling to `set_inner_size` from a callback.
|
||||||
|
- On macOS, add `hide__other_applications` to `EventLoopWindowTarget` via existing `EventLoopWindowTargetExtMacOS` trait. `hide_other_applications` will hide other applications by calling `-[NSApplication hideOtherApplications: nil]`.
|
||||||
|
|
||||||
# 0.22.2 (2020-05-16)
|
# 0.22.2 (2020-05-16)
|
||||||
|
|
||||||
|
|
|
@ -215,6 +215,8 @@ impl MonitorHandleExtMacOS for MonitorHandle {
|
||||||
pub trait EventLoopWindowTargetExtMacOS {
|
pub trait EventLoopWindowTargetExtMacOS {
|
||||||
/// Hide the entire application. In most applications this is typically triggered with Command-H.
|
/// Hide the entire application. In most applications this is typically triggered with Command-H.
|
||||||
fn hide_application(&self);
|
fn hide_application(&self);
|
||||||
|
/// Hide the other applications. In most applications this is typically triggered with Command+Option-H.
|
||||||
|
fn hide_other_applications(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> EventLoopWindowTargetExtMacOS for EventLoopWindowTarget<T> {
|
impl<T> EventLoopWindowTargetExtMacOS for EventLoopWindowTarget<T> {
|
||||||
|
@ -223,4 +225,10 @@ impl<T> EventLoopWindowTargetExtMacOS for EventLoopWindowTarget<T> {
|
||||||
let app: cocoa::base::id = unsafe { msg_send![cls, sharedApplication] };
|
let app: cocoa::base::id = unsafe { msg_send![cls, sharedApplication] };
|
||||||
unsafe { msg_send![app, hide: 0] }
|
unsafe { msg_send![app, hide: 0] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hide_other_applications(&self) {
|
||||||
|
let cls = objc::runtime::Class::get("NSApplication").unwrap();
|
||||||
|
let app: cocoa::base::id = unsafe { msg_send![cls, sharedApplication] };
|
||||||
|
unsafe { msg_send![app, hideOtherApplications: 0] }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue