diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 87b30a54d..143a8e4e2 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -568,6 +568,16 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL; [super dealloc]; } +-(void)setLayer:(CALayer*)layer +{ + [super setLayer:layer]; + if (window->context.client != GLFW_NO_API) { + // this is needed for initial rendering on mojave, see + // https://github.com/kovidgoyal/kitty/issues/887 + [window->context.nsgl.object update]; + } +} + - (_GLFWwindow*)glfwWindow { return window; } diff --git a/kitty/cocoa_window.m b/kitty/cocoa_window.m index d3198b399..fbeb22c46 100644 --- a/kitty/cocoa_window.m +++ b/kitty/cocoa_window.m @@ -99,12 +99,6 @@ cocoa_set_new_window_trigger(PyObject *self UNUSED, PyObject *args) { Py_RETURN_FALSE; } -void -cocoa_update_nsgl_context(void* id) { - NSOpenGLContext *ctx = id; - [ctx update]; -} - void cocoa_create_global_menu(void) { NSString* app_name = find_app_name(); diff --git a/kitty/glfw.c b/kitty/glfw.c index 74063c3e2..215f03e95 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -14,7 +14,6 @@ extern bool cocoa_toggle_fullscreen(void *w, bool); extern void cocoa_create_global_menu(void); extern void cocoa_set_hide_from_tasks(void); extern void cocoa_set_titlebar_color(void *w, color_type color); -extern void cocoa_update_nsgl_context(void* id); #if GLFW_KEY_LAST >= MAX_KEY_COUNT @@ -816,13 +815,6 @@ is_mouse_hidden(OSWindow *w) { void swap_window_buffers(OSWindow *w) { -#ifdef __APPLE__ - if (w->nsgl_ctx_updated++ < 2) { - // Needed on Mojave for initial window render, see - // https://github.com/kovidgoyal/kitty/issues/887 - cocoa_update_nsgl_context(glfwGetNSGLContext(w->handle)); - } -#endif glfwSwapBuffers(w->handle); }