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.
This commit is contained in:
Kovid Goyal 2019-04-06 10:05:21 +05:30
parent 790d630d17
commit 8251b906b6
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -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;