winemac: Cope with multiple seemingly-identical display modes, only some of which work, by trying them in sequence.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ken Thomases 2015-11-02 19:23:04 -06:00 committed by Alexandre Julliard
parent 2dc5685897
commit 4db8fc394d
1 changed files with 25 additions and 13 deletions

View File

@ -699,9 +699,9 @@ - (BOOL) mode:(CGDisplayModeRef)mode1 matchesMode:(CGDisplayModeRef)mode2
return TRUE;
}
- (CGDisplayModeRef)modeMatchingMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
- (NSArray*)modesMatchingMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
{
CGDisplayModeRef ret = NULL;
NSMutableArray* ret = [NSMutableArray array];
NSDictionary* options = nil;
#if defined(MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
@ -715,10 +715,7 @@ - (CGDisplayModeRef)modeMatchingMode:(CGDisplayModeRef)mode forDisplay:(CGDirect
{
CGDisplayModeRef candidateMode = (CGDisplayModeRef)candidateModeObject;
if ([self mode:candidateMode matchesMode:mode])
{
ret = candidateMode;
break;
}
[ret addObject:candidateModeObject];
}
return ret;
}
@ -743,11 +740,15 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
}
else // ... otherwise, try to restore just the one display
{
mode = [self modeMatchingMode:mode forDisplay:displayID];
if (mode && CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr)
for (id modeObject in [self modesMatchingMode:mode forDisplay:displayID])
{
[originalDisplayModes removeObjectForKey:displayIDKey];
ret = TRUE;
mode = (CGDisplayModeRef)modeObject;
if (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr)
{
[originalDisplayModes removeObjectForKey:displayIDKey];
ret = TRUE;
break;
}
}
}
}
@ -755,6 +756,7 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
{
BOOL active = [NSApp isActive];
CGDisplayModeRef currentMode;
NSArray* modes;
currentMode = CGDisplayModeRetain((CGDisplayModeRef)[latentDisplayModes objectForKey:displayIDKey]);
if (!currentMode)
@ -771,8 +773,8 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
CGDisplayModeRelease(currentMode);
currentMode = NULL;
mode = [self modeMatchingMode:mode forDisplay:displayID];
if (!mode)
modes = [self modesMatchingMode:mode forDisplay:displayID];
if (!modes.count)
return FALSE;
if ([originalDisplayModes count] || displaysCapturedForFullscreen ||
@ -789,7 +791,17 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
originalMode = currentMode = CGDisplayCopyDisplayMode(displayID);
if (originalMode)
ret = (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr);
{
for (id modeObject in modes)
{
mode = (CGDisplayModeRef)modeObject;
if (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr)
{
ret = TRUE;
break;
}
}
}
if (ret && !(currentMode && [self mode:mode matchesMode:currentMode]))
[originalDisplayModes setObject:(id)originalMode forKey:displayIDKey];
else if (![originalDisplayModes count])