-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements PlatformExt::set_modal for macOS (#1221)
- Loading branch information
1 parent
96f4632
commit 809b149
Showing
5 changed files
with
51 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use objc::runtime::Object; | ||
use objc::{msg_send, sel, sel_impl}; | ||
use raw_window_handle::{HasWindowHandle, RawWindowHandle}; | ||
|
||
pub fn with_window<T>(win: impl HasWindowHandle, f: impl FnOnce(*mut Object) -> T) -> T { | ||
// Get NSView. | ||
let win = win.window_handle().unwrap(); | ||
let win = match win.as_ref() { | ||
RawWindowHandle::AppKit(v) => v.ns_view.as_ptr().cast::<Object>(), | ||
_ => unreachable!(), | ||
}; | ||
|
||
// Get NSWindow. | ||
f(unsafe { msg_send![win, window] }) | ||
} |