This commit is contained in:
Kovid Goyal 2018-12-19 10:07:11 +05:30
commit aaa521bd24
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 16 additions and 4 deletions

View File

@ -372,7 +372,7 @@ parse_input(ChildMonitor *self) {
} }
if (UNLIKELY(kill_signal_received)) { if (UNLIKELY(kill_signal_received)) {
global_state.close_all_windows = true; global_state.terminate = true;
} else { } else {
count = self->count; count = self->count;
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
@ -737,7 +737,6 @@ process_pending_resizes(double now) {
static inline void static inline void
close_all_windows() { 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); 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 static inline bool
@ -793,7 +792,13 @@ main_loop(ChildMonitor *self, PyObject *a UNUSED) {
} }
#endif #endif
parse_input(self); 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); has_open_windows = process_pending_closes(self);
} }
if (PyErr_Occurred()) return NULL; if (PyErr_Occurred()) return NULL;

View File

@ -650,6 +650,12 @@ bool
application_quit_requested() { application_quit_requested() {
return !application_quit_canary || glfwWindowShouldClose(application_quit_canary); return !application_quit_canary || glfwWindowShouldClose(application_quit_canary);
} }
void
request_application_quit() {
if (application_quit_canary)
glfwSetWindowShouldClose(application_quit_canary, true);
}
#endif #endif
// Global functions {{{ // Global functions {{{

View File

@ -144,7 +144,7 @@ typedef struct {
OSWindow *os_windows; OSWindow *os_windows;
size_t num_os_windows, capacity; size_t num_os_windows, capacity;
OSWindow *callback_os_window; OSWindow *callback_os_window;
bool close_all_windows; bool terminate;
bool is_wayland; bool is_wayland;
bool debug_gl, debug_font_fallback; bool debug_gl, debug_font_fallback;
bool has_pending_resizes; bool has_pending_resizes;
@ -209,5 +209,6 @@ typedef enum {
} CocoaPendingAction; } CocoaPendingAction;
void set_cocoa_pending_action(CocoaPendingAction action); void set_cocoa_pending_action(CocoaPendingAction action);
bool application_quit_requested(); bool application_quit_requested();
void request_application_quit();
#endif #endif
void wayland_request_frame_render(OSWindow *w); void wayland_request_frame_render(OSWindow *w);