Skip to content

Commit

Permalink
feat(macos): Add unhide_application method, closes #182 (#231)
Browse files Browse the repository at this point in the history
* feat(macos): Add `unhide_application` method

* Update src/platform/macos.rs

Co-authored-by: Amr Bashir <[email protected]>

* Reanme to `show_application()`

* Remove broken doc link

Co-authored-by: Amr Bashir <[email protected]>
  • Loading branch information
probablykasper and amrbashir authored Nov 3, 2021
1 parent 9da2f15 commit 7e10b0d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/unhide-applications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
tao: minor
---

Add macOS `show_application()` method
8 changes: 8 additions & 0 deletions src/platform/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ impl MonitorHandleExtMacOS for MonitorHandle {
pub trait EventLoopWindowTargetExtMacOS {
/// Hide the entire application. In most applications this is typically triggered with Command-H.
fn hide_application(&self);
/// Show the entire application.
fn show_application(&self);
/// Hide the other applications. In most applications this is typically triggered with Command+Option-H.
fn hide_other_applications(&self);
}
Expand All @@ -456,6 +458,12 @@ impl<T> EventLoopWindowTargetExtMacOS for EventLoopWindowTarget<T> {
unsafe { msg_send![app, hide: 0] }
}

fn show_application(&self) {
let cls = objc::runtime::Class::get("NSApplication").unwrap();
let app: cocoa::base::id = unsafe { msg_send![cls, sharedApplication] };
unsafe { msg_send![app, unhide: 0] }
}

fn hide_other_applications(&self) {
let cls = objc::runtime::Class::get("NSApplication").unwrap();
let app: cocoa::base::id = unsafe { msg_send![cls, sharedApplication] };
Expand Down

0 comments on commit 7e10b0d

Please sign in to comment.