Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/winex11.drv/settings.c | 58 +++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 22 deletions(-)
diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c index 800b65dbfd..e867925c26 100644 --- a/dlls/winex11.drv/settings.c +++ b/dlls/winex11.drv/settings.c @@ -154,29 +154,43 @@ void X11DRV_Settings_Init(void) X11DRV_Settings_AddOneMode( primary.right - primary.left, primary.bottom - primary.top, 0, 60); }
-static BOOL get_display_device_reg_key(char *key, unsigned len) +/* Get the primary adapter key in the form of System\CurrentControlSet\Control\Video{Primary adapter GUID}\0000 */ +static BOOL get_primary_adapter_key(char *key, unsigned len) { - static const char display_device_guid_prop[] = "__wine_display_device_guid"; - static const char video_path[] = "System\CurrentControlSet\Control\Video\{"; - static const char display0[] = "}\0000"; - ATOM guid_atom; - - assert(len >= sizeof(video_path) + sizeof(display0) + 40); - - guid_atom = HandleToULong(GetPropA(GetDesktopWindow(), display_device_guid_prop)); - if (!guid_atom) return FALSE; - - memcpy(key, video_path, sizeof(video_path)); - - if (!GlobalGetAtomNameA(guid_atom, key + strlen(key), 40)) - return FALSE; - - strcat(key, display0); - - TRACE("display device key %s\n", wine_dbgstr_a(key)); - return TRUE; + static const CHAR value_prefix[] = "\Registry\Machine\"; + CHAR buffer[MAX_PATH]; + CHAR *substring; + DWORD size; + size_t length; + BOOL ret = FALSE; + + /* Vaule data of \Device\Video0 in HKLM\HARDWARE\DEVICEMAP\VIDEO\ */ + size = sizeof(buffer); + if (RegGetValueA(HKEY_LOCAL_MACHINE, "HARDWARE\DEVICEMAP\VIDEO", "\Device\Video0", + RRF_RT_REG_SZ | RRF_ZEROONFAILURE, NULL, buffer, &size)) + goto fail; + + /* Need to strip "\Registry\Machine" from the value data, which starts with "\Registry\Machine\System..." */ + length = strlen(value_prefix); + if (strncasecmp(buffer, value_prefix, length)) + goto fail; + + substring = buffer + length; + length = strlen(substring); + if (len < length + 1) + goto fail; + + strcpy(key, substring); + + ret = TRUE; + TRACE("primary adapter key %s\n", wine_dbgstr_a(key)); +fail: + if (!ret) + ERR("Failed to get primary adapter registry key\n"); + return ret; }
+ static BOOL read_registry_settings(DEVMODEW *dm) { char wine_x11_reg_key[128]; @@ -186,7 +200,7 @@ static BOOL read_registry_settings(DEVMODEW *dm)
dm->dmFields = 0;
- if (!get_display_device_reg_key(wine_x11_reg_key, sizeof(wine_x11_reg_key))) + if (!get_primary_adapter_key(wine_x11_reg_key, sizeof(wine_x11_reg_key))) return FALSE;
if (RegOpenKeyExA(HKEY_CURRENT_CONFIG, wine_x11_reg_key, 0, KEY_READ, &hkey)) @@ -225,7 +239,7 @@ static BOOL write_registry_settings(const DEVMODEW *dm) HKEY hkey; BOOL ret = TRUE;
- if (!get_display_device_reg_key(wine_x11_reg_key, sizeof(wine_x11_reg_key))) + if (!get_primary_adapter_key(wine_x11_reg_key, sizeof(wine_x11_reg_key))) return FALSE;
if (RegCreateKeyExA(HKEY_CURRENT_CONFIG, wine_x11_reg_key, 0, NULL,
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=48812
Your paranoid android.
=== debian9 (32 bit report) ===
user32: monitor.c:110: Test succeeded inside todo block: #0: failed to open registry, error: 0 monitor.c:118: Test failed: #0: wrong DeviceKey: monitor.c:110: Test succeeded inside todo block: #0: failed to open registry, error: 0 monitor.c:118: Test failed: #0: wrong DeviceKey: msg.c:8713: Test failed: WaitForSingleObject failed 102 msg.c:8719: Test failed: destroy child on thread exit: 0: the msg 0x0082 was expected, but got msg 0x000f instead msg.c:8719: Test failed: destroy child on thread exit: 1: the msg 0x000f was expected, but got msg 0x0014 instead msg.c:8719: Test failed: destroy child on thread exit: 2: the msg sequence is not complete: expected 0014 - actual 0000
=== debian9 (32 bit Chinese:China report) ===
user32: monitor.c:110: Test succeeded inside todo block: #0: failed to open registry, error: 0 monitor.c:118: Test failed: #0: wrong DeviceKey: monitor.c:110: Test succeeded inside todo block: #0: failed to open registry, error: 0 monitor.c:118: Test failed: #0: wrong DeviceKey:
=== debian9 (32 bit WoW report) ===
user32: monitor.c:110: Test succeeded inside todo block: #0: failed to open registry, error: 0 monitor.c:118: Test failed: #0: wrong DeviceKey: monitor.c:110: Test succeeded inside todo block: #0: failed to open registry, error: 0 monitor.c:118: Test failed: #0: wrong DeviceKey:
=== debian9 (64 bit WoW report) ===
user32: monitor.c:110: Test succeeded inside todo block: #0: failed to open registry, error: 0 monitor.c:118: Test failed: #0: wrong DeviceKey: monitor.c:110: Test succeeded inside todo block: #0: failed to open registry, error: 0 monitor.c:118: Test failed: #0: wrong DeviceKey: