Module: wine Branch: master Commit: 9c65d672a21c7ece30014f3165844ea420326d0f URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c65d672a21c7ece30014f3165...
Author: Ken Thomases ken@codeweavers.com Date: Fri Jan 10 03:11:25 2014 -0600
winemac: Don't assume the current display mode is the original if we don't have the displays captured.
Another process may have changed the display mode before we queried the current mode, so we may be seeing a non-original mode.
---
dlls/winemac.drv/cocoa_app.m | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 3521e06..1b6e72e 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -726,18 +726,16 @@ int macdrv_err_on; return TRUE; }
+ CGDisplayModeRelease(currentMode); + currentMode = NULL; + mode = [self modeMatchingMode:mode forDisplay:displayID]; if (!mode) - { - CGDisplayModeRelease(currentMode); return FALSE; - }
originalMode = (CGDisplayModeRef)[originalDisplayModes objectForKey:displayIDKey]; - if (!originalMode) - originalMode = currentMode;
- if ([self mode:mode matchesMode:originalMode]) + if (originalMode && [self mode:mode matchesMode:originalMode]) { if ([originalDisplayModes count] == 1) // If this is the last changed display, do a blanket reset { @@ -771,8 +769,17 @@ int macdrv_err_on; { if (active) { - ret = (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr); - if (ret) + // If we get here, we have the displays captured. If we don't + // know the original mode of the display, the current mode must + // be the original. We should re-query the current mode since + // another process could have changed it between when we last + // checked and when we captured the displays. + if (!originalMode) + originalMode = currentMode = CGDisplayCopyDisplayMode(displayID); + + if (originalMode) + ret = (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr); + if (ret && !(currentMode && [self mode:mode matchesMode:currentMode])) [originalDisplayModes setObject:(id)originalMode forKey:displayIDKey]; else if (![originalDisplayModes count]) { @@ -781,6 +788,9 @@ int macdrv_err_on; if (!displaysCapturedForFullscreen) CGReleaseAllDisplays(); } + + if (currentMode) + CGDisplayModeRelease(currentMode); } else { @@ -790,8 +800,6 @@ int macdrv_err_on; } }
- CGDisplayModeRelease(currentMode); - if (ret) [self adjustWindowLevels];