From 8251b906b6dfda264662e604ad93d0a51bb43c56 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 6 Apr 2019 10:05:21 +0530 Subject: [PATCH] Add a listener for GPU changed events on macOS Currently does nothing, but could potentially be used to fix: https://github.com/kovidgoyal/kitty/issues/794 Will need someone with the hardware though to test exactly what needs to be done to restore the custom cursor image. --- glfw/cocoa_window.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index fddcee4d4..772f9decc 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -286,6 +286,18 @@ static int translateKey(unsigned int key, GLFWbool apply_keymap) return _glfw.ns.keycodes[key]; } +static void +display_reconfigured(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo) +{ + (void)(userInfo); (void)(display); (void)(flags); + if (flags & kCGDisplayBeginConfigurationFlag) { + return; + } + if (flags & kCGDisplaySetModeFlag) { + // GPU possibly changed + } +} + // Translate a GLFW keycode to a Cocoa modifier flag // static NSUInteger translateKeyToModifierFlag(int key) @@ -488,9 +500,15 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification { [NSApp stop:nil]; + CGDisplayRegisterReconfigurationCallback(display_reconfigured, NULL); _glfwPlatformPostEmptyEvent(); } +- (void)applicationWillTerminate:(NSNotification *)aNotification +{ + CGDisplayRemoveReconfigurationCallback(display_reconfigured, NULL); +} + - (void)applicationDidHide:(NSNotification *)notification { int i;