macOS move impl details of platform into platform_impl

This commit is contained in:
Mads Marquart 2021-12-01 12:20:56 +01:00 committed by GitHub
parent 5eb9c9504b
commit 11a44081df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 9 deletions

View file

@ -241,14 +241,10 @@ pub trait EventLoopWindowTargetExtMacOS {
impl<T> EventLoopWindowTargetExtMacOS for EventLoopWindowTarget<T> {
fn hide_application(&self) {
let cls = objc::runtime::Class::get("NSApplication").unwrap();
let app: cocoa::base::id = unsafe { msg_send![cls, sharedApplication] };
unsafe { msg_send![app, hide: 0] }
self.p.hide_application()
}
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] }
self.p.hide_other_applications()
}
}

View file

@ -112,9 +112,7 @@ impl WindowExtWindows for Window {
#[inline]
fn set_enable(&self, enabled: bool) {
unsafe {
winapi::um::winuser::EnableWindow(self.hwnd() as _, enabled as _);
}
self.window.set_enable(enabled)
}
#[inline]

View file

@ -85,6 +85,20 @@ impl<T: 'static> EventLoopWindowTarget<T> {
}
}
impl<T> EventLoopWindowTarget<T> {
pub(crate) fn hide_application(&self) {
let cls = objc::runtime::Class::get("NSApplication").unwrap();
let app: cocoa::base::id = unsafe { msg_send![cls, sharedApplication] };
unsafe { msg_send![app, hide: 0] }
}
pub(crate) 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] }
}
}
pub struct EventLoop<T: 'static> {
pub(crate) delegate: IdRef,

View file

@ -564,6 +564,11 @@ impl Window {
self.window_state.lock().window_icon = window_icon;
}
#[inline]
pub fn set_enable(&self, enabled: bool) {
unsafe { winuser::EnableWindow(self.hwnd() as _, enabled as _) };
}
#[inline]
pub fn set_taskbar_icon(&self, taskbar_icon: Option<Icon>) {
if let Some(ref taskbar_icon) = taskbar_icon {