mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 17:27:39 +02:00
Do notcheck for closed windows on every loop tick
This commit is contained in:
@@ -824,6 +824,7 @@ close_all_windows() {
|
|||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
process_pending_closes(ChildMonitor *self) {
|
process_pending_closes(ChildMonitor *self) {
|
||||||
|
global_state.has_pending_closes = false;
|
||||||
bool has_open_windows = false;
|
bool has_open_windows = false;
|
||||||
for (size_t w = global_state.num_os_windows; w > 0; w--) {
|
for (size_t w = global_state.num_os_windows; w > 0; w--) {
|
||||||
OSWindow *os_window = global_state.os_windows + w - 1;
|
OSWindow *os_window = global_state.os_windows + w - 1;
|
||||||
@@ -906,7 +907,8 @@ process_global_state(void *data) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
report_reaped_pids();
|
report_reaped_pids();
|
||||||
bool has_open_windows = process_pending_closes(self);
|
bool has_open_windows = true;
|
||||||
|
if (global_state.has_pending_closes) has_open_windows = process_pending_closes(self);
|
||||||
if (has_open_windows) {
|
if (has_open_windows) {
|
||||||
if (maximum_wait >= 0) {
|
if (maximum_wait >= 0) {
|
||||||
if (maximum_wait == 0) request_tick_callback();
|
if (maximum_wait == 0) request_tick_callback();
|
||||||
|
|||||||
27
kitty/glfw.c
27
kitty/glfw.c
@@ -109,6 +109,7 @@ blank_os_window(OSWindow *w) {
|
|||||||
static void
|
static void
|
||||||
window_close_callback(GLFWwindow* window) {
|
window_close_callback(GLFWwindow* window) {
|
||||||
if (!set_callback_window(window)) return;
|
if (!set_callback_window(window)) return;
|
||||||
|
global_state.has_pending_closes = true;
|
||||||
request_tick_callback();
|
request_tick_callback();
|
||||||
global_state.callback_os_window = NULL;
|
global_state.callback_os_window = NULL;
|
||||||
}
|
}
|
||||||
@@ -713,8 +714,10 @@ application_quit_requested() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
request_application_quit() {
|
request_application_quit() {
|
||||||
if (application_quit_canary)
|
if (application_quit_canary) {
|
||||||
|
global_state.has_pending_closes = true;
|
||||||
glfwSetWindowShouldClose(application_quit_canary, true);
|
glfwSetWindowShouldClose(application_quit_canary, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -913,6 +916,7 @@ wakeup_main_loop() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
mark_os_window_for_close(OSWindow* w, bool yes) {
|
mark_os_window_for_close(OSWindow* w, bool yes) {
|
||||||
|
global_state.has_pending_closes = true;
|
||||||
glfwSetWindowShouldClose(w->handle, yes);
|
glfwSetWindowShouldClose(w->handle, yes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -988,26 +992,6 @@ set_primary_selection(PyObject UNUSED *self, PyObject *args) {
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject*
|
|
||||||
os_window_should_close(PyObject UNUSED *self, PyObject *args) {
|
|
||||||
int q = -1001;
|
|
||||||
id_type os_window_id;
|
|
||||||
if (!PyArg_ParseTuple(args, "K|i", &os_window_id, &q)) return NULL;
|
|
||||||
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
|
||||||
OSWindow *w = global_state.os_windows + i;
|
|
||||||
if (w->id == os_window_id) {
|
|
||||||
if (q == -1001) {
|
|
||||||
if (should_os_window_close(w)) Py_RETURN_TRUE;
|
|
||||||
Py_RETURN_FALSE;
|
|
||||||
}
|
|
||||||
glfwSetWindowShouldClose(w->handle, q ? GLFW_TRUE : GLFW_FALSE);
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PyErr_SetString(PyExc_ValueError, "no such OSWindow");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
os_window_swap_buffers(PyObject UNUSED *self, PyObject *args) {
|
os_window_swap_buffers(PyObject UNUSED *self, PyObject *args) {
|
||||||
id_type os_window_id;
|
id_type os_window_id;
|
||||||
@@ -1167,7 +1151,6 @@ static PyMethodDef module_methods[] = {
|
|||||||
METHODB(toggle_fullscreen, METH_NOARGS),
|
METHODB(toggle_fullscreen, METH_NOARGS),
|
||||||
METHODB(change_os_window_state, METH_VARARGS),
|
METHODB(change_os_window_state, METH_VARARGS),
|
||||||
METHODB(glfw_window_hint, METH_VARARGS),
|
METHODB(glfw_window_hint, METH_VARARGS),
|
||||||
METHODB(os_window_should_close, METH_VARARGS),
|
|
||||||
METHODB(os_window_swap_buffers, METH_VARARGS),
|
METHODB(os_window_swap_buffers, METH_VARARGS),
|
||||||
METHODB(get_primary_selection, METH_NOARGS),
|
METHODB(get_primary_selection, METH_NOARGS),
|
||||||
METHODB(x11_display, METH_NOARGS),
|
METHODB(x11_display, METH_NOARGS),
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ typedef struct {
|
|||||||
bool is_wayland;
|
bool is_wayland;
|
||||||
bool has_render_frames;
|
bool has_render_frames;
|
||||||
bool debug_gl, debug_font_fallback;
|
bool debug_gl, debug_font_fallback;
|
||||||
bool has_pending_resizes;
|
bool has_pending_resizes, has_pending_closes;
|
||||||
bool in_sequence_mode;
|
bool in_sequence_mode;
|
||||||
bool tab_bar_hidden;
|
bool tab_bar_hidden;
|
||||||
double font_sz_in_pts;
|
double font_sz_in_pts;
|
||||||
|
|||||||
Reference in New Issue
Block a user