Fix for kitty window not being rendered until moved/resized on macOS Mojave

Fixes #887
This commit is contained in:
Kovid Goyal 2018-09-26 19:43:04 +05:30
parent 9b293ad66a
commit b82e74f99a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 21 additions and 0 deletions

View File

@ -192,6 +192,7 @@ def generate_wrappers(glfw_header, glfw_native_header):
functions.append(Function(decl))
for line in '''\
void* glfwGetCocoaWindow(GLFWwindow* window)
void* glfwGetNSGLContext(GLFWwindow *window)
uint32_t glfwGetCocoaMonitor(GLFWmonitor* monitor)
GLFWcocoatextinputfilterfun glfwSetCocoaTextInputFilter(GLFWwindow* window, GLFWcocoatextinputfilterfun callback)
GLFWcocoatogglefullscreenfun glfwSetCocoaToggleFullscreenIntercept(GLFWwindow *window, GLFWcocoatogglefullscreenfun callback)

View File

@ -99,6 +99,12 @@ 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();

2
kitty/glfw-wrapper.c generated
View File

@ -358,6 +358,8 @@ load_glfw(const char* path) {
*(void **) (&glfwGetCocoaWindow_impl) = dlsym(handle, "glfwGetCocoaWindow");
*(void **) (&glfwGetNSGLContext_impl) = dlsym(handle, "glfwGetNSGLContext");
*(void **) (&glfwGetCocoaMonitor_impl) = dlsym(handle, "glfwGetCocoaMonitor");
*(void **) (&glfwSetCocoaTextInputFilter_impl) = dlsym(handle, "glfwSetCocoaTextInputFilter");

4
kitty/glfw-wrapper.h generated
View File

@ -1848,6 +1848,10 @@ typedef void* (*glfwGetCocoaWindow_func)(GLFWwindow*);
glfwGetCocoaWindow_func glfwGetCocoaWindow_impl;
#define glfwGetCocoaWindow glfwGetCocoaWindow_impl
typedef void* (*glfwGetNSGLContext_func)(GLFWwindow*);
glfwGetNSGLContext_func glfwGetNSGLContext_impl;
#define glfwGetNSGLContext glfwGetNSGLContext_impl
typedef uint32_t (*glfwGetCocoaMonitor_func)(GLFWmonitor*);
glfwGetCocoaMonitor_func glfwGetCocoaMonitor_impl;
#define glfwGetCocoaMonitor glfwGetCocoaMonitor_impl

View File

@ -14,6 +14,8 @@ 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
#error "glfw has too many keys, you should increase MAX_KEY_COUNT"
@ -808,6 +810,11 @@ hide_mouse(OSWindow *w) {
void
swap_window_buffers(OSWindow *w) {
#ifdef __APPLE__
if (w->nsgl_ctx_updated++ < 2) {
cocoa_update_nsgl_context(glfwGetNSGLContext(w->handle));
}
#endif
glfwSwapBuffers(w->handle);
}

View File

@ -126,6 +126,7 @@ typedef struct {
FONTS_DATA_HANDLE fonts_data;
id_type temp_font_group_id;
double pending_scroll_pixels;
unsigned int nsgl_ctx_updated;
} OSWindow;