From 42a7d7209b5e96cc35681e6524254899e3087e00 Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Fri, 10 Jan 2014 03:11:28 -0600 Subject: [PATCH] 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 1b6e72e8ade..3e622b70206 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) { -- 2.11.4.GIT