From 8a683c02aa196ae0822c8cf4735f02cc6018aaa1 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 30 May 2013 14:14:30 +0200 Subject: [PATCH] Hooked up Quartz reconfiguration callback. --- src/cocoa_init.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 6c9eeb0a..d0247613 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -71,6 +71,13 @@ static void changeToResourcesDirectory(void) #endif /* _GLFW_USE_CHDIR */ +static void reconfigurationCallback(CGDirectDisplayID displayID, + CGDisplayChangeSummaryFlags flags, + void* data) +{ + _glfwInputMonitorChange(); +} + ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// @@ -95,6 +102,12 @@ int _glfwPlatformInit(void) if (!_glfw.ns.eventSource) return GL_FALSE; + if (CGDisplayRegisterReconfigurationCallback(reconfigurationCallback, + NULL) != kCGErrorSuccess) + { + return GL_FALSE; + } + CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0); return GL_TRUE; @@ -102,6 +115,8 @@ int _glfwPlatformInit(void) void _glfwPlatformTerminate(void) { + CGDisplayRemoveReconfigurationCallback(reconfigurationCallback, NULL); + if (_glfw.ns.eventSource) { CFRelease(_glfw.ns.eventSource);