[PATCH] winemac: Use the display unit number rather than display ID for the initial display mode registry key.

Ken Thomases ken at codeweavers.com
Mon Nov 16 22:11:12 CST 2015


On Macs with dual GPUs that automatically switch, the display ID is not stable.
It changes when the active GPU changes.  The resulted in the lookup of the
initial display mode failing and games not being able to restore it properly.

The display unit number should be more reliable, although still not perfect.

Signed-off-by: Ken Thomases <ken at codeweavers.com>
---
 dlls/winemac.drv/display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c
index e1357d8..ad01191 100644
--- a/dlls/winemac.drv/display.c
+++ b/dlls/winemac.drv/display.c
@@ -187,7 +187,7 @@ static BOOL write_display_settings(HKEY parent_hkey, CGDirectDisplayID displayID
     size_t len;
     WCHAR* buf = NULL;
 
-    snprintf(display_key_name, sizeof(display_key_name), "Display 0x%08x", displayID);
+    snprintf(display_key_name, sizeof(display_key_name), "Display 0x%08x", CGDisplayUnitNumber(displayID));
     /* @@ Wine registry key: HKLM\Software\Wine\Mac Driver\Initial Display Mode\Display 0xnnnnnnnn */
     if (RegCreateKeyExA(parent_hkey, display_key_name, 0, NULL,
                         REG_OPTION_VOLATILE, KEY_WRITE, NULL, &display_hkey, NULL))
@@ -328,7 +328,7 @@ static struct display_mode_descriptor* create_original_display_mode_descriptor(C
 
     init_original_display_mode();
 
-    snprintf(display_key, sizeof(display_key), display_key_format, displayID);
+    snprintf(display_key, sizeof(display_key), display_key_format, CGDisplayUnitNumber(displayID));
     /* @@ Wine registry key: HKLM\Software\Wine\Mac Driver\Initial Display Mode\Display 0xnnnnnnnn */
     if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, display_key, 0, KEY_READ, &hkey))
         return NULL;
-- 
2.6.0




More information about the wine-patches mailing list