1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-25 14:22:37 +03:00

macos: spawn new window when clicking on dock icon

If there are no windows, clicking on the dock icon will spawn a new
window.

Requires that `quit_when_all_windows_are_closed=false`

refs:  https://github.com/wez/wezterm/issues/3057
This commit is contained in:
Wez Furlong 2023-02-05 17:56:01 -07:00
parent 6968ad5c3c
commit 2271c3ae59
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387

View File

@ -68,6 +68,14 @@ extern "C" fn application_will_finish_launching(
log::debug!("application_will_finish_launching");
}
extern "C" fn application_open_untitled_file(_self: &mut Object, _sel: Sel, _app: *mut Object) {
if let Some(conn) = Connection::get() {
conn.dispatch_app_event(ApplicationEvent::PerformKeyAssignment(
KeyAssignment::SpawnWindow,
));
}
}
extern "C" fn wezterm_perform_key_assignment(
_self: &mut Object,
_sel: Sel,
@ -167,6 +175,10 @@ fn get_class() -> &'static Class {
sel!(weztermShowAbout:),
wezterm_show_about as extern "C" fn(&mut Object, Sel, *mut Object),
);
cls.add_method(
sel!(applicationOpenUntitledFile:),
application_open_untitled_file as extern "C" fn(&mut Object, Sel, *mut Object),
);
}
cls.register()