diff --git a/docs/changelog.rst b/docs/changelog.rst index a96d4ba16..d70630261 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -48,7 +48,9 @@ Changelog working if no kitty window currently has focus. (:iss:`524`) - macOS: Keep kitty running even when the last window is closed. This is in - line with how applications are supposed to behave on macOS (:iss:`543`) + line with how applications are supposed to behave on macOS (:iss:`543`). + There is a new option (:opt:`macos_quit_when_last_window_closed`) to control + this. - macOS: Add macOS standard shortcuts for copy, paste and new OS window (⌘+C, ⌘+V, ⌘+N) diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index 877a5fe77..57797bdb4 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -749,7 +749,9 @@ process_pending_closes(ChildMonitor *self) { } else has_open_windows = true; } #ifdef __APPLE__ - if (!has_open_windows && !application_quit_requested()) has_open_windows = true; + if (!OPT(macos_quit_when_last_window_closed)) { + if (!has_open_windows && !application_quit_requested()) has_open_windows = true; + } #endif return has_open_windows; } diff --git a/kitty/config_data.py b/kitty/config_data.py index d611b1d10..54e54be59 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -657,14 +657,12 @@ probably better off just hiding the titlebar with :opt:`macos_hide_titlebar`. o('macos_hide_titlebar', False, long_text=_(''' Hide the kitty window's title bar on macOS.''')) - o('x11_hide_window_decorations', False, long_text=_(''' Hide the window decorations (title bar and window borders) on X11 and Wayland. Whether this works and exactly what effect it has depends on the window manager, as it is the job of the window manager/compositor to draw window decorations.''')) - o('macos_option_as_alt', True, long_text=_(''' Use the option key as an alt key. With this set to no, kitty will use the macOS native :kbd:`Option+Key` = unicode character behavior. This will @@ -676,6 +674,12 @@ o('macos_hide_from_tasks', False, long_text=_(''' Hide the kitty window from running tasks (:kbd:`Option+Tab`) on macOS. ''')) +o('macos_quit_when_last_window_closed', False, long_text=_(''' +Have kitty quit when all the top-level windows are closed. By default, +kitty will stay running, even with no open windows, as is the expected +behavior on macOS. +''')) + # }}} diff --git a/kitty/state.c b/kitty/state.c index f752c23d5..c1834c300 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -385,6 +385,7 @@ PYWRAP1(set_options) { S(window_alert_on_bell, PyObject_IsTrue); S(macos_option_as_alt, PyObject_IsTrue); S(macos_hide_titlebar, PyObject_IsTrue); + S(macos_quit_when_last_window_closed, PyObject_IsTrue); S(x11_hide_window_decorations, PyObject_IsTrue); S(macos_hide_from_tasks, PyObject_IsTrue); diff --git a/kitty/state.h b/kitty/state.h index c91cdb137..1f538f808 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -23,7 +23,7 @@ typedef struct { color_type url_color, background, active_border_color, inactive_border_color, bell_border_color; double repaint_delay, input_delay; bool focus_follows_mouse; - bool macos_option_as_alt, macos_hide_titlebar, macos_hide_from_tasks, x11_hide_window_decorations; + bool macos_option_as_alt, macos_hide_titlebar, macos_hide_from_tasks, x11_hide_window_decorations, macos_quit_when_last_window_closed; int adjust_line_height_px, adjust_column_width_px; float adjust_line_height_frac, adjust_column_width_frac; float background_opacity, dim_opacity;