Ken Thomases : winemac: Restore display mode to original in more cases.

Alexandre Julliard julliard at winehq.org
Fri Jan 10 13:22:44 CST 2014


Module: wine
Branch: master
Commit: 42a7d7209b5e96cc35681e6524254899e3087e00
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=42a7d7209b5e96cc35681e6524254899e3087e00

Author: Ken Thomases <ken at codeweavers.com>
Date:   Fri Jan 10 03:11:28 2014 -0600

winemac: Restore display mode to original in more cases.

We only care if we have changed the mode and we're changing it back to its
original.  Even if the current mode matches the target mode, we may still
need to release the displays and clear the entry from originalDisplayModes.

---

 dlls/winemac.drv/cocoa_app.m |   50 +++++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index 1b6e72e..3e622b7 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -711,27 +711,7 @@ int macdrv_err_on;
         BOOL ret = FALSE;
         BOOL active = [NSApp isActive];
         NSNumber* displayIDKey = [NSNumber numberWithUnsignedInt:displayID];
-        CGDisplayModeRef currentMode = NULL, originalMode;
-
-        if (!active)
-            currentMode = CGDisplayModeRetain((CGDisplayModeRef)[latentDisplayModes objectForKey:displayIDKey]);
-        if (!currentMode)
-            currentMode = CGDisplayCopyDisplayMode(displayID);
-        if (!currentMode) // Invalid display ID
-            return FALSE;
-
-        if ([self mode:mode matchesMode:currentMode]) // Already there!
-        {
-            CGDisplayModeRelease(currentMode);
-            return TRUE;
-        }
-
-        CGDisplayModeRelease(currentMode);
-        currentMode = NULL;
-
-        mode = [self modeMatchingMode:mode forDisplay:displayID];
-        if (!mode)
-            return FALSE;
+        CGDisplayModeRef originalMode;
 
         originalMode = (CGDisplayModeRef)[originalDisplayModes objectForKey:displayIDKey];
 
@@ -752,7 +732,11 @@ int macdrv_err_on;
             else // ... otherwise, try to restore just the one display
             {
                 if (active)
-                    ret = (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr);
+                {
+                    mode = [self modeMatchingMode:mode forDisplay:displayID];
+                    if (mode)
+                        ret = (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr);
+                }
                 else
                 {
                     [latentDisplayModes removeObjectForKey:displayIDKey];
@@ -764,6 +748,28 @@ int macdrv_err_on;
         }
         else
         {
+            CGDisplayModeRef currentMode = NULL;
+
+            if (!active)
+                currentMode = CGDisplayModeRetain((CGDisplayModeRef)[latentDisplayModes objectForKey:displayIDKey]);
+            if (!currentMode)
+                currentMode = CGDisplayCopyDisplayMode(displayID);
+            if (!currentMode) // Invalid display ID
+                return FALSE;
+
+            if ([self mode:mode matchesMode:currentMode]) // Already there!
+            {
+                CGDisplayModeRelease(currentMode);
+                return TRUE;
+            }
+
+            CGDisplayModeRelease(currentMode);
+            currentMode = NULL;
+
+            mode = [self modeMatchingMode:mode forDisplay:displayID];
+            if (!mode)
+                return FALSE;
+
             if ([originalDisplayModes count] || displaysCapturedForFullscreen ||
                 !active || CGCaptureAllDisplays() == CGDisplayNoErr)
             {




More information about the wine-cvs mailing list