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:
parent
d4d92a759e
commit
ce5a87b1ef
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue