user32: Improve EnumDisplayDevicesW stub.

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2019-06-10 22:08:40 +08:00 committed by Alexandre Julliard
parent 7f57cda707
commit 8f5fbfeb42
2 changed files with 68 additions and 24 deletions

View File

@ -39,6 +39,33 @@
WINE_DEFAULT_DEBUG_CHANNEL(win);
static const WCHAR default_adapter_name[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
static const WCHAR default_monitor_name[] =
{'\\','\\','.','\\',
'D','I','S','P','L','A','Y','1','\\',
'M','o','n','i','t','o','r','0',0};
static const WCHAR default_adapter_string[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0};
static const WCHAR default_monitor_string[] =
{'G','e','n','e','r','i','c',' ','N','o','n','-','P','n','P',' ','M','o','n','i','t','o','r',0};
static const WCHAR default_adapter_id[] =
{'P','C','I','\\',
'V','E','N','_','0','0','0','0','&',
'D','E','V','_','0','0','0','0','&',
'S','U','B','S','Y','S','_','0','0','0','0','0','0','0','0','&',
'R','E','V','_','0','0',0};
static const WCHAR default_monitor_id[] =
{'M','O','N','I','T','O','R','\\',
'D','e','f','a','u','l','t','_','M','o','n','i','t','o','r','\\',
'{','4','d','3','6','e','9','6','e','-','e','3','2','5','-','1','1','c','e','-',
'b','f','c','1','-','0','8','0','0','2','b','e','1','0','3','1','8','}',
'\\','0','0','0','0',0};
static const WCHAR default_monitor_interface_id[] =
{'\\','\\','\?','\\',
'D','I','S','P','L','A','Y','#','D','e','f','a','u','l','t','_','M','o','n','i','t','o','r','#',
'4','&','1','7','f','0','f','f','5','4','&','0','&','U','I','D','0','#',
'{','e','6','f','0','7','b','5','f','-','e','e','9','7','-','4','a','9','0','-',
'b','0','7','6','-','3','3','f','5','7','b','f','4','e','a','a','7','}',0};
#define IMM_INIT_MAGIC 0x19650412
static HWND (WINAPI *imm_get_ui_window)(HKL);
BOOL (WINAPI *imm_register_window)(HWND) = NULL;
@ -243,12 +270,6 @@ DWORD WINAPI SetLogonNotifyWindow(HWINSTA hwinsta,HWND hwnd)
return 1;
}
static const WCHAR primary_device_name[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
static const WCHAR primary_device_string[] = {'X','1','1',' ','W','i','n','d','o','w','i','n','g',' ',
'S','y','s','t','e','m',0};
static const WCHAR primary_device_deviceid[] = {'P','C','I','\\','V','E','N','_','0','0','0','0','&',
'D','E','V','_','0','0','0','0',0};
/***********************************************************************
* EnumDisplayDevicesA (USER32.@)
*/
@ -293,16 +314,39 @@ BOOL WINAPI EnumDisplayDevicesW( LPCWSTR lpDevice, DWORD i, LPDISPLAY_DEVICEW lp
if (i)
return FALSE;
memcpy(lpDisplayDevice->DeviceName, primary_device_name, sizeof(primary_device_name));
memcpy(lpDisplayDevice->DeviceString, primary_device_string, sizeof(primary_device_string));
lpDisplayDevice->StateFlags =
DISPLAY_DEVICE_ATTACHED_TO_DESKTOP |
DISPLAY_DEVICE_PRIMARY_DEVICE |
DISPLAY_DEVICE_VGA_COMPATIBLE;
/* Adapter */
if (!lpDevice)
{
memcpy(lpDisplayDevice->DeviceName, default_adapter_name, sizeof(default_adapter_name));
memcpy(lpDisplayDevice->DeviceString, default_adapter_string, sizeof(default_adapter_string));
lpDisplayDevice->StateFlags =
DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE;
if(lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(lpDisplayDevice->DeviceID))
{
if (dwFlags & EDD_GET_DEVICE_INTERFACE_NAME)
lpDisplayDevice->DeviceID[0] = 0;
else
memcpy(lpDisplayDevice->DeviceID, default_adapter_id, sizeof(default_adapter_id));
}
}
/* Monitor */
else
{
if (lstrcmpiW(default_adapter_name, lpDevice))
return FALSE;
memcpy(lpDisplayDevice->DeviceName, default_monitor_name, sizeof(default_monitor_name));
memcpy(lpDisplayDevice->DeviceString, default_monitor_string, sizeof(default_monitor_string));
lpDisplayDevice->StateFlags = DISPLAY_DEVICE_ACTIVE | DISPLAY_DEVICE_ATTACHED;
if (lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(lpDisplayDevice->DeviceID))
{
if (dwFlags & EDD_GET_DEVICE_INTERFACE_NAME)
memcpy(lpDisplayDevice->DeviceID, default_monitor_interface_id, sizeof(default_monitor_interface_id));
else
memcpy(lpDisplayDevice->DeviceID, default_monitor_id, sizeof(default_monitor_id));
}
}
if(lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(lpDisplayDevice->DeviceID))
memcpy(lpDisplayDevice->DeviceID, primary_device_deviceid, sizeof(primary_device_deviceid));
if(lpDisplayDevice->cb >= offsetof(DISPLAY_DEVICEW, DeviceKey) + sizeof(lpDisplayDevice->DeviceKey))
lpDisplayDevice->DeviceKey[0] = 0;

View File

@ -146,13 +146,13 @@ static void test_enumdisplaydevices_adapter(int index, const DISPLAY_DEVICEA *de
* by changing the data and rerun EnumDisplayDevices. But it's difficult to find corresponding PCI device on
* userland. So here we check the expected format instead. */
if (flags & EDD_GET_DEVICE_INTERFACE_NAME)
todo_wine ok(strlen(device->DeviceID) == 0 || /* vista+ */
ok(strlen(device->DeviceID) == 0 || /* vista+ */
sscanf(device->DeviceID, "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X",
&vendor_id, &device_id, &subsys_id, &revision_id) == 4, /* XP/2003 ignores EDD_GET_DEVICE_INTERFACE_NAME */
"#%d: got %s\n", index, device->DeviceID);
else
{
todo_wine ok(broken(strlen(device->DeviceID) == 0) || /* XP on Testbot returns an empty string, whereas real machine doesn't */
ok(broken(strlen(device->DeviceID) == 0) || /* XP on Testbot returns an empty string, whereas real machine doesn't */
sscanf(device->DeviceID, "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X", &vendor_id, &device_id, &subsys_id,
&revision_id) == 4, "#%d: wrong DeviceID %s\n", index, device->DeviceID);
}
@ -173,14 +173,14 @@ static void test_enumdisplaydevices_monitor(int adapter_index, int monitor_index
/* DeviceName */
lstrcpyA(monitor_name, adapter_name);
sprintf(monitor_name + strlen(monitor_name), "\\Monitor%d", monitor_index);
todo_wine ok(!strcmp(monitor_name, device->DeviceName), "#%d: expect %s, got %s\n", monitor_index, monitor_name, device->DeviceName);
ok(!strcmp(monitor_name, device->DeviceName), "#%d: expect %s, got %s\n", monitor_index, monitor_name, device->DeviceName);
/* DeviceString */
ok(strlen(device->DeviceString) > 0, "#%d: expect DeviceString not empty\n", monitor_index);
/* StateFlags */
if (adapter_index == 0 && monitor_index == 0)
todo_wine ok(device->StateFlags & DISPLAY_DEVICE_ATTACHED, "#%d expect to have a primary monitor attached\n", monitor_index);
ok(device->StateFlags & DISPLAY_DEVICE_ATTACHED, "#%d expect to have a primary monitor attached\n", monitor_index);
else
ok(device->StateFlags <= (DISPLAY_DEVICE_ATTACHED | DISPLAY_DEVICE_ACTIVE), "#%d wrong state %#x\n", monitor_index,
device->StateFlags);
@ -191,7 +191,7 @@ static void test_enumdisplaydevices_monitor(int adapter_index, int monitor_index
{ /* HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\Default_Monitor\4&2abfaa30&0&UID0 GUID_DEVINTERFACE_MONITOR
* ^ ^ ^
* Expect format \\?\DISPLAY#Default_Monitor#4&2abfaa30&0&UID0#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7} */
todo_wine ok(strlen(device->DeviceID) == 0 || /* vista ~ win7 */
ok(strlen(device->DeviceID) == 0 || /* vista ~ win7 */
sscanf(device->DeviceID, "\\\\?\\DISPLAY#Default_Monitor#%[^#]#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}", buffer) == 1 || /* win8+ */
(!lstrcmpiA(buffer, device_id_prefix) &&
sscanf(device->DeviceID + sizeof(device_id_prefix) - 1, "%04d", &number) == 1), /* XP/2003 ignores EDD_GET_DEVICE_INTERFACE_NAME */
@ -201,9 +201,9 @@ static void test_enumdisplaydevices_monitor(int adapter_index, int monitor_index
{
/* Expect HarewareID value data + Driver value data in HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\Default_Monitor\{Instance} */
/* But we don't know which monitor instance this belongs to, so check format instead */
todo_wine ok(!lstrcmpiA(buffer, device_id_prefix), "#%d wrong DeviceID : %s\n", monitor_index, device->DeviceID);
todo_wine ok(sscanf(device->DeviceID + sizeof(device_id_prefix) - 1, "%04d", &number) == 1,
"#%d wrong DeviceID : %s\n", monitor_index, device->DeviceID);
ok(!lstrcmpiA(buffer, device_id_prefix), "#%d wrong DeviceID : %s\n", monitor_index, device->DeviceID);
ok(sscanf(device->DeviceID + sizeof(device_id_prefix) - 1, "%04d", &number) == 1,
"#%d wrong DeviceID : %s\n", monitor_index, device->DeviceID);
}
/* DeviceKey */
@ -235,7 +235,7 @@ static void test_enumdisplaydevices(void)
/* Doesn't accept \\.\DISPLAY */
dd.cb = sizeof(dd);
ret = pEnumDisplayDevicesA("\\\\.\\DISPLAY", 0, &dd, 0);
todo_wine ok(!ret, "Expect failure\n");
ok(!ret, "Expect failure\n");
/* Enumeration */
for (flag_index = 0; flag_index < ARRAY_SIZE(flags); flag_index++)