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.
This commit is contained in:
Ken Thomases 2014-01-10 03:11:28 -06:00 committed by Alexandre Julliard
parent 9c65d672a2
commit 42a7d7209b
1 changed files with 28 additions and 22 deletions

View File

@ -711,27 +711,7 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
BOOL ret = FALSE; BOOL ret = FALSE;
BOOL active = [NSApp isActive]; BOOL active = [NSApp isActive];
NSNumber* displayIDKey = [NSNumber numberWithUnsignedInt:displayID]; NSNumber* displayIDKey = [NSNumber numberWithUnsignedInt:displayID];
CGDisplayModeRef currentMode = NULL, originalMode; CGDisplayModeRef 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;
originalMode = (CGDisplayModeRef)[originalDisplayModes objectForKey:displayIDKey]; originalMode = (CGDisplayModeRef)[originalDisplayModes objectForKey:displayIDKey];
@ -752,7 +732,11 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
else // ... otherwise, try to restore just the one display else // ... otherwise, try to restore just the one display
{ {
if (active) if (active)
ret = (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr); {
mode = [self modeMatchingMode:mode forDisplay:displayID];
if (mode)
ret = (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr);
}
else else
{ {
[latentDisplayModes removeObjectForKey:displayIDKey]; [latentDisplayModes removeObjectForKey:displayIDKey];
@ -764,6 +748,28 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
} }
else 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 || if ([originalDisplayModes count] || displaysCapturedForFullscreen ||
!active || CGCaptureAllDisplays() == CGDisplayNoErr) !active || CGCaptureAllDisplays() == CGDisplayNoErr)
{ {