Implement is_minimized for macOS (#9651)

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2024-03-21 09:36:54 -07:00 committed by GitHub
parent adcb591629
commit e07192e4e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -303,6 +303,14 @@ unsafe fn build_window_class(name: &'static str, superclass: &Class) -> *const C
sel!(concludeDragOperation:),
conclude_drag_operation as extern "C" fn(&Object, Sel, id),
);
decl.add_method(
sel!(windowDidMiniaturize:),
window_did_miniaturize as extern "C" fn(&Object, Sel, id),
);
decl.add_method(
sel!(windowDidDeminiaturize:),
window_did_deminiaturize as extern "C" fn(&Object, Sel, id),
);
decl.register()
}
@ -342,6 +350,7 @@ struct MacWindowState {
input_during_keydown: Option<SmallVec<[ImeInput; 1]>>,
previous_keydown_inserted_text: Option<String>,
external_files_dragged: bool,
mimized: bool,
}
impl MacWindowState {
@ -419,9 +428,8 @@ impl MacWindowState {
}
}
// todo(macos)
fn is_minimized(&self) -> bool {
false
self.mimized
}
fn is_fullscreen(&self) -> bool {
@ -599,6 +607,7 @@ impl MacWindow {
input_during_keydown: None,
previous_keydown_inserted_text: None,
external_files_dragged: false,
mimized: false,
})));
(*native_window).set_ivar(
@ -1818,6 +1827,18 @@ extern "C" fn conclude_drag_operation(this: &Object, _: Sel, _: id) {
);
}
extern "C" fn window_did_miniaturize(this: &Object, _: Sel, _: id) {
let window_state = unsafe { get_window_state(this) };
window_state.lock().mimized = true;
}
extern "C" fn window_did_deminiaturize(this: &Object, _: Sel, _: id) {
let window_state = unsafe { get_window_state(this) };
window_state.lock().mimized = false;
}
async fn synthetic_drag(
window_state: Weak<Mutex<MacWindowState>>,
drag_id: usize,