diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index 5299a2e7e..d8c35199b 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -372,7 +372,7 @@ parse_input(ChildMonitor *self) { } if (UNLIKELY(kill_signal_received)) { - global_state.close_all_windows = true; + global_state.terminate = true; } else { count = self->count; for (size_t i = 0; i < count; i++) { @@ -737,7 +737,6 @@ process_pending_resizes(double now) { static inline void close_all_windows() { for (size_t w = 0; w < global_state.num_os_windows; w++) mark_os_window_for_close(&global_state.os_windows[w], true); - global_state.close_all_windows = false; } static inline bool @@ -793,7 +792,13 @@ main_loop(ChildMonitor *self, PyObject *a UNUSED) { } #endif parse_input(self); - if (global_state.close_all_windows) close_all_windows(); + if (global_state.terminate) { + global_state.terminate = false; + close_all_windows(); +#ifdef __APPLE__ + request_application_quit(); +#endif + } has_open_windows = process_pending_closes(self); } if (PyErr_Occurred()) return NULL; diff --git a/kitty/glfw.c b/kitty/glfw.c index b9c4861d5..1a840a8c1 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -650,6 +650,12 @@ bool application_quit_requested() { return !application_quit_canary || glfwWindowShouldClose(application_quit_canary); } + +void +request_application_quit() { + if (application_quit_canary) + glfwSetWindowShouldClose(application_quit_canary, true); +} #endif // Global functions {{{ diff --git a/kitty/state.h b/kitty/state.h index e8d5ddf12..75852b097 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -144,7 +144,7 @@ typedef struct { OSWindow *os_windows; size_t num_os_windows, capacity; OSWindow *callback_os_window; - bool close_all_windows; + bool terminate; bool is_wayland; bool debug_gl, debug_font_fallback; bool has_pending_resizes; @@ -209,5 +209,6 @@ typedef enum { } CocoaPendingAction; void set_cocoa_pending_action(CocoaPendingAction action); bool application_quit_requested(); +void request_application_quit(); #endif void wayland_request_frame_render(OSWindow *w);