From: Paul Gofman pgofman@codeweavers.com
--- dlls/user32/tests/monitor.c | 8 ++++++++ dlls/win32u/sysparams.c | 41 +++++++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index 1dff85b9621..5a717d30360 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -191,6 +191,9 @@ static void test_enumdisplaydevices_monitor(int monitor_index, const char *adapt ok(device->StateFlags <= (DISPLAY_DEVICE_ATTACHED | DISPLAY_DEVICE_ACTIVE), "#%d wrong state %#lx\n", monitor_index, device->StateFlags);
+ trace("DeviceName %s, DeviceString %s, DeviceID %s, DeviceKey %s.\n", + debugstr_a(device->DeviceName), debugstr_a(device->DeviceString), debugstr_a(device->DeviceID), debugstr_a(device->DeviceKey)); + /* DeviceID */ CharLowerA(device->DeviceID); if (flags & EDD_GET_DEVICE_INTERFACE_NAME) @@ -1721,6 +1724,7 @@ static void test_QueryDisplayConfig_result(UINT32 flags, ret = pDisplayConfigGetDeviceInfo(&target_name.header); ok(!ret, "Expected 0, got %ld\n", ret); check_device_path(target_name.monitorDevicePath, &target_name.header.adapterId, target_name.header.id); + trace("flags %#lx, edidManufactureId %#x, edidProductCodeId %#x, friendlyName %s.\n", target_name.flags, target_name.edidManufactureId, target_name.edidProductCodeId, debugstr_w(target_name.monitorFriendlyDeviceName));
todo_wine { preferred_mode.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE; @@ -2618,6 +2622,10 @@ START_TEST(monitor) return; }
+test_display_config(); +test_enumdisplaydevices(); +return; + test_enumdisplaydevices(); test_ChangeDisplaySettingsEx(); test_DisplayConfigSetDeviceInfo(); diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 5e7b04905b8..8ca12d4f808 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -871,7 +871,7 @@ static void prepare_devices(void) REG_OPTION_VOLATILE, NULL );
/* delete monitors */ - reg_empty_key( enum_key, "DISPLAY\DEFAULT_MONITOR" ); + reg_empty_key( enum_key, "DISPLAY" ); sprintf( buffer, "Class\%s", guid_devclass_monitorA ); hkey = reg_create_key( control_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), 0, NULL ); @@ -1300,24 +1300,49 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param ) sizeof(adapter->state_flags) ); }
+static BOOL get_monitor_id_from_edid( char monitor_id_string[16], const unsigned char *edid, unsigned int edid_len ) +{ + unsigned short w; + unsigned char d; + unsigned int i; + + if (!edid || edid_len < 128) return FALSE; + + w = (edid[8] << 8) | edid[9]; /* Manufacturer ID, big endian. */ + for (i = 0; i < 3; ++i) + { + d = w & 0x1f; + if (!d || d - 1 > 'Z' - 'A') return FALSE; + monitor_id_string[2 - i] = 'A' + d - 1; + w >>= 5; + } + if (w) return FALSE; + w = edid[10] | (edid[11] << 8); /* Product code, little endian. */ + sprintf( monitor_id_string + 3, "%04X", w ); + TRACE( "Monitor id %s.\n", monitor_id_string ); + return TRUE; +} + static void add_monitor( const struct gdi_monitor *monitor, void *param ) { struct device_manager_ctx *ctx = param; char buffer[MAX_PATH], instance[64]; unsigned int monitor_index, output_index; + char monitor_id_string[16]; WCHAR bufferW[MAX_PATH]; HKEY hkey, subkey; - - static const WCHAR default_monitorW[] = - {'M','O','N','I','T','O','R','\','D','e','f','a','u','l','t','_','M','o','n','i','t','o','r',0,0}; + unsigned int len;
TRACE( "%s %s\n", wine_dbgstr_rect(&monitor->rc_monitor), wine_dbgstr_rect(&monitor->rc_work) );
monitor_index = ctx->monitor_count++; output_index = ctx->output_count++;
+ if (!get_monitor_id_from_edid( monitor_id_string, monitor->edid, monitor->edid_len )) + strcpy( monitor_id_string, "Default_Monitor" ); + sprintf( buffer, "MonitorID%u", monitor_index ); - sprintf( instance, "DISPLAY\Default_Monitor\%04X&%04X", ctx->video_count - 1, monitor_index ); + sprintf( instance, "DISPLAY\%s\%04X&%04X", monitor_id_string, ctx->video_count - 1, monitor_index ); set_reg_ascii_value( ctx->adapter_key, buffer, instance );
hkey = reg_create_key( enum_key, bufferW, asciiz_to_unicode( bufferW, instance ) - sizeof(WCHAR), @@ -1333,7 +1358,11 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) sprintf( buffer, "%s\%04X", guid_devclass_monitorA, output_index ); set_reg_ascii_value( hkey, "Driver", buffer ); set_reg_value( hkey, class_guidW, REG_SZ, guid_devclass_monitorW, sizeof(guid_devclass_monitorW) ); - set_reg_value( hkey, hardware_idW, REG_MULTI_SZ, default_monitorW, sizeof(default_monitorW) ); + + sprintf( buffer, "MONITOR\%s", monitor_id_string ); + len = asciiz_to_unicode( bufferW, buffer ); + bufferW[len / sizeof(WCHAR)] = 0; + set_reg_value( hkey, hardware_idW, REG_MULTI_SZ, bufferW, len + sizeof(WCHAR) );
if ((subkey = reg_create_key( hkey, device_parametersW, sizeof(device_parametersW), 0, NULL ))) {