Module: wine
Branch: master
Commit: 9c65d672a21c7ece30014f3165844ea420326d0f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c65d672a21c7ece30014f316…
Author: Ken Thomases <ken(a)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];
Module: wine
Branch: master
Commit: fe1c0ab952d1b17c6079fef9ca418fafa812a878
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fe1c0ab952d1b17c6079fef9c…
Author: Ken Thomases <ken(a)codeweavers.com>
Date: Fri Jan 10 03:11:19 2014 -0600
winemac: Don't record original display modes when not the active app.
originalDisplayModes should be used when active, empty when inactive.
latentDisplayModes is used when inactive, empty when active.
The count of entries in originalDisplayModes is used to test whether the
process has the displays captured so adding entries when inactive would give
incorrect results. This could have led us to mistakenly change the display
mode when we don't have the displays captured.
---
dlls/winemac.drv/cocoa_app.m | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index fea30e3..3521e06 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -770,21 +770,23 @@ int macdrv_err_on;
!active || CGCaptureAllDisplays() == CGDisplayNoErr)
{
if (active)
+ {
ret = (CGDisplaySetDisplayMode(displayID, mode, NULL) == CGDisplayNoErr);
+ if (ret)
+ [originalDisplayModes setObject:(id)originalMode forKey:displayIDKey];
+ else if (![originalDisplayModes count])
+ {
+ CGRestorePermanentDisplayConfiguration();
+ [latentDisplayModes removeAllObjects];
+ if (!displaysCapturedForFullscreen)
+ CGReleaseAllDisplays();
+ }
+ }
else
{
[latentDisplayModes setObject:(id)mode forKey:displayIDKey];
ret = TRUE;
}
- if (ret)
- [originalDisplayModes setObject:(id)originalMode forKey:displayIDKey];
- else if (![originalDisplayModes count])
- {
- CGRestorePermanentDisplayConfiguration();
- [latentDisplayModes removeAllObjects];
- if (!displaysCapturedForFullscreen)
- CGReleaseAllDisplays();
- }
}
}