History

Implement is_minimized for macOS (#9651)

Release Notes: - N/A

Mikayla Maki committed 2 years ago

Commit e07192e1 parent adcb5911 file · +23 −2Browse files

Unified · Split

crates/gpui/src/platform/mac/window.rs+23−2
@@ -303,6 +303,14 @@ unsafe fn build_window_class(name: &'static str, superclass: &Class) -> *const C · 302 unmodified lines
303303 sel!(concludeDragOperation:),
304304 conclude_drag_operation as extern "C" fn(&Object, Sel, id),
305305 );
306+ decl.add_method(
307+ sel!(windowDidMiniaturize:),
308+ window_did_miniaturize as extern "C" fn(&Object, Sel, id),
309+ );
310+ decl.add_method(
311+ sel!(windowDidDeminiaturize:),
312+ window_did_deminiaturize as extern "C" fn(&Object, Sel, id),
313+ );
306314
307315 decl.register()
308316 }
@@ -342,6 +350,7 @@ struct MacWindowState { · 33 unmodified lines
342350 input_during_keydown: Option<SmallVec<[ImeInput; 1]>>,
343351 previous_keydown_inserted_text: Option<String>,
344352 external_files_dragged: bool,
353+ mimized: bool,
345354 }
346355
347356 impl MacWindowState {
@@ -419,9 +428,8 @@ impl MacWindowState { · 71 unmodified lines
419428 }
420429 }
421430
422− // todo(macos)
423431 fn is_minimized(&self) -> bool {
424− false
432+ self.mimized
425433 }
426434
427435 fn is_fullscreen(&self) -> bool {
@@ -599,6 +607,7 @@ impl MacWindow { · 171 unmodified lines
599607 input_during_keydown: None,
600608 previous_keydown_inserted_text: None,
601609 external_files_dragged: false,
610+ mimized: false,
602611 })));
603612
604613 (*native_window).set_ivar(
@@ -1818,6 +1827,18 @@ extern "C" fn conclude_drag_operation(this: &Object, _: Sel, _: id) { · 1213 unmodified lines
18181827 );
18191828 }
18201829
1830+extern "C" fn window_did_miniaturize(this: &Object, _: Sel, _: id) {
1831+ let window_state = unsafe { get_window_state(this) };
1832+
1833+ window_state.lock().mimized = true;
1834+}
1835+
1836+extern "C" fn window_did_deminiaturize(this: &Object, _: Sel, _: id) {
1837+ let window_state = unsafe { get_window_state(this) };
1838+
1839+ window_state.lock().mimized = false;
1840+}
1841+
18211842 async fn synthetic_drag(
18221843 window_state: Weak<Mutex<MacWindowState>>,
18231844 drag_id: usize,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t