winemac: Simplify display mode code.

When originalDisplayModes has entries, the app is active.  When the app is
active, latentDisplayModes is empty.
This commit is contained in:
Ken Thomases 2014-01-10 03:11:33 -06:00 committed by Alexandre Julliard
parent d4d92a759e
commit ce5a87b1ef
1 changed files with 9 additions and 22 deletions

View File

@ -709,7 +709,6 @@ - (CGDisplayModeRef)modeMatchingMode:(CGDisplayModeRef)mode forDisplay:(CGDirect
- (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
{
BOOL ret = FALSE;
BOOL active = [NSApp isActive];
NSNumber* displayIDKey = [NSNumber numberWithUnsignedInt:displayID];
CGDisplayModeRef originalMode;
@ -718,39 +717,28 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
if (originalMode && [self mode:mode matchesMode:originalMode])
{
if ([originalDisplayModes count] == 1) // If this is the last changed display, do a blanket reset
{
if (active)
{
CGRestorePermanentDisplayConfiguration();
if (!displaysCapturedForFullscreen)
CGReleaseAllDisplays();
}
[originalDisplayModes removeAllObjects];
[latentDisplayModes removeAllObjects];
ret = TRUE;
}
else // ... otherwise, try to restore just the one display
{
if (active)
{
mode = [self modeMatchingMode:mode forDisplay:displayID];
if (mode)
ret = (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr);
}
else
if (mode && CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr)
{
[latentDisplayModes removeObjectForKey:displayIDKey];
[originalDisplayModes removeObjectForKey:displayIDKey];
ret = TRUE;
}
if (ret)
[originalDisplayModes removeObjectForKey:displayIDKey];
}
}
else
{
CGDisplayModeRef currentMode = NULL;
BOOL active = [NSApp isActive];
CGDisplayModeRef currentMode;
if (!active)
currentMode = CGDisplayModeRetain((CGDisplayModeRef)[latentDisplayModes objectForKey:displayIDKey]);
if (!currentMode)
currentMode = CGDisplayCopyDisplayMode(displayID);
@ -790,7 +778,6 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
else if (![originalDisplayModes count])
{
CGRestorePermanentDisplayConfiguration();
[latentDisplayModes removeAllObjects];
if (!displaysCapturedForFullscreen)
CGReleaseAllDisplays();
}