Add macos_hide_from_tasks option

This commit is contained in:
Alex Lau 2018-04-23 21:55:05 -07:00
parent 0b99bb534f
commit 7d4d978d97
4 changed files with 15 additions and 0 deletions

View File

@ -228,6 +228,12 @@ macos_change_titlebar_color(PyObject *self UNUSED, PyObject *val) {
Py_RETURN_NONE;
}
static PyObject*
macos_set_hide_from_tasks(PyObject *self UNUSED, PyObject *val UNUSED) {
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
Py_RETURN_NONE;
}
void
cocoa_set_titlebar_color(void *w)
{
@ -260,6 +266,7 @@ static PyMethodDef module_methods[] = {
{"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""},
{"cwd_of_process", (PyCFunction)cwd_of_process, METH_O, ""},
{"macos_change_titlebar_color", (PyCFunction)macos_change_titlebar_color, METH_O, ""},
{"macos_set_hide_from_tasks", (PyCFunction)macos_set_hide_from_tasks, METH_NOARGS, ""},
{NULL, NULL, 0, NULL} /* Sentinel */
};

View File

@ -318,6 +318,7 @@ type_map = {
'initial_window_width': positive_int,
'initial_window_height': positive_int,
'macos_hide_titlebar': to_bool,
'macos_hide_from_tasks': to_bool,
'macos_option_as_alt': to_bool,
'macos_titlebar_color': macos_titlebar_color,
'box_drawing_scale': box_drawing_scale,

View File

@ -499,4 +499,7 @@ macos_hide_titlebar no
# break any Alt+key keyboard shortcuts in your terminal programs, but you
# can use the macOS unicode input technique.
macos_option_as_alt yes
# Hide the kitty window from running tasks (alt-tab) on macOS.
macos_hide_from_tasks yes
# }}}

View File

@ -45,6 +45,10 @@ def run_app(opts, args):
with cached_values_for('main') as cached_values:
w, h = initial_window_size(opts, cached_values)
window_id = create_os_window(w, h, appname, args.name or args.cls or appname, args.cls or appname, load_all_shaders)
if is_macos and opts.macos_hide_from_tasks:
from .fast_data_types import macos_set_hide_from_tasks
# This needs to be done after creating the OS window as glfw sets the activation policy as well.
macos_set_hide_from_tasks()
startup_ctx = init_startup_notification(window_id)
show_window(window_id)
if not is_wayland and not is_macos: # no window icons on wayland