From 78f1b8bd1504247148f6e04eb7121e058e9e84a0 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 10 Mar 2014 12:42:30 +0100 Subject: [PATCH] Fixed invalid video mode being restored. --- src/cocoa_monitor.m | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index f430734e..88cae085 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -200,10 +200,8 @@ GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired) monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID); CGDisplayFadeReservationToken token = beginFadeReservation(); - CGDisplayCapture(monitor->ns.displayID); CGDisplaySetDisplayMode(monitor->ns.displayID, native, NULL); - endFadeReservation(token); } @@ -224,12 +222,17 @@ GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired) // void _glfwRestoreVideoMode(_GLFWmonitor* monitor) { - CGDisplayFadeReservationToken token = beginFadeReservation(); + if (monitor->ns.previousMode) + { + CGDisplayFadeReservationToken token = beginFadeReservation(); + CGDisplaySetDisplayMode(monitor->ns.displayID, + monitor->ns.previousMode, NULL); + CGDisplayRelease(monitor->ns.displayID); + endFadeReservation(token); - CGDisplaySetDisplayMode(monitor->ns.displayID, monitor->ns.previousMode, NULL); - CGDisplayRelease(monitor->ns.displayID); - - endFadeReservation(token); + CGDisplayModeRelease(monitor->ns.previousMode); + monitor->ns.previousMode = NULL; + } }