diff --git a/kitty/glfw.c b/kitty/glfw.c index c34db7393..61e124ad4 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -6,7 +6,6 @@ #include "state.h" #include "cleanup.h" -#include "fonts.h" #include "monotonic.h" #include "charsets.h" #include @@ -323,9 +322,13 @@ change_live_resize_state(OSWindow *w, bool in_progress) { if (in_progress != w->live_resize.in_progress) { w->live_resize.in_progress = in_progress; w->live_resize.num_of_resize_events = 0; - apply_swap_interval(in_progress ? 0 : -1); #ifdef __APPLE__ cocoa_out_of_sequence_render(w); +#else + GLFWwindow *orig_ctx = make_os_window_context_current(w); + apply_swap_interval(in_progress ? 0 : -1); + if (orig_ctx) glfwMakeContextCurrent(orig_ctx); + #endif } } @@ -753,13 +756,14 @@ set_default_window_icon(PyObject UNUSED *self, PyObject *args) { } -void +void* make_os_window_context_current(OSWindow *w) { GLFWwindow *current_context = glfwGetCurrentContext(); if (w->handle != current_context) { glfwMakeContextCurrent(w->handle); - global_state.current_opengl_context_id = w->id; + return current_context; } + return NULL; } void @@ -1176,7 +1180,6 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) { w->cursor_blink_zero_time = now; w->last_mouse_activity_at = now; w->is_semi_transparent = is_semi_transparent; - global_state.current_opengl_context_id = w->id; if (want_semi_transparent && !w->is_semi_transparent) { static bool warned = false; if (!warned) { diff --git a/kitty/state.h b/kitty/state.h index e9d57b75f..25dac80de 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -255,7 +255,7 @@ typedef struct { typedef struct { Options opts; - id_type os_window_id_counter, tab_id_counter, window_id_counter, current_opengl_context_id; + id_type os_window_id_counter, tab_id_counter, window_id_counter; PyObject *boss; BackgroundImage *bgimage; OSWindow *os_windows; @@ -286,7 +286,7 @@ extern GlobalState global_state; void gl_init(void); void remove_vao(ssize_t vao_idx); bool remove_os_window(id_type os_window_id); -void make_os_window_context_current(OSWindow *w); +void* make_os_window_context_current(OSWindow *w); void set_os_window_size(OSWindow *os_window, int x, int y); void get_os_window_size(OSWindow *os_window, int *w, int *h, int *fw, int *fh); void get_os_window_content_scale(OSWindow *os_window, double *xdpi, double *ydpi, float *xscale, float *yscale);