Better fix for initial window render failure on mojave

This commit is contained in:
Kovid Goyal 2018-10-23 09:04:12 +05:30
parent d24977d164
commit ae9d049011
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 10 additions and 14 deletions

View File

@ -568,6 +568,16 @@ - (void)dealloc
[super dealloc]; [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 { - (_GLFWwindow*)glfwWindow {
return window; return window;
} }

View File

@ -99,12 +99,6 @@ + (GlobalMenuTarget *) shared_instance
Py_RETURN_FALSE; Py_RETURN_FALSE;
} }
void
cocoa_update_nsgl_context(void* id) {
NSOpenGLContext *ctx = id;
[ctx update];
}
void void
cocoa_create_global_menu(void) { cocoa_create_global_menu(void) {
NSString* app_name = find_app_name(); NSString* app_name = find_app_name();

View File

@ -14,7 +14,6 @@ extern bool cocoa_toggle_fullscreen(void *w, bool);
extern void cocoa_create_global_menu(void); extern void cocoa_create_global_menu(void);
extern void cocoa_set_hide_from_tasks(void); extern void cocoa_set_hide_from_tasks(void);
extern void cocoa_set_titlebar_color(void *w, color_type color); 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 #if GLFW_KEY_LAST >= MAX_KEY_COUNT
@ -816,13 +815,6 @@ is_mouse_hidden(OSWindow *w) {
void void
swap_window_buffers(OSWindow *w) { 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); glfwSwapBuffers(w->handle);
} }