Implemented focus_window (#1944)

This commit is contained in:
Max de Danschutter 2021-05-19 18:39:53 +02:00 committed by GitHub
parent 91591c4e94
commit b371b406d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 107 additions and 0 deletions

View file

@ -970,6 +970,21 @@ impl UnownedWindow {
}
}
#[inline]
pub fn focus_window(&self) {
let is_minimized: BOOL = unsafe { msg_send![*self.ns_window, isMiniaturized] };
let is_minimized = is_minimized == YES;
let is_visible: BOOL = unsafe { msg_send![*self.ns_window, isVisible] };
let is_visible = is_visible == YES;
if !is_minimized && is_visible {
unsafe {
NSApp().activateIgnoringOtherApps_(YES);
util::make_key_and_order_front_async(*self.ns_window);
}
}
}
#[inline]
pub fn request_user_attention(&self, request_type: Option<UserAttentionType>) {
let ns_request_type = request_type.map(|ty| match ty {