wine-staging/patches/user32-QueryDisplayConfig/0001-user32-Implement-QueryDisplayConfig.patch
2020-07-19 09:25:32 +10:00

118 lines
4.8 KiB
Diff

From 72e9a5081e40600b857d357c8111e344e68aa22f Mon Sep 17 00:00:00 2001
From: Derek Lesho <dlesho@codeweavers.com>
Date: Fri, 10 Jan 2020 15:34:45 -0600
Subject: [PATCH] user32: Implement QueryDisplayConfig
---
dlls/user32/sysparams.c | 89 ++++++++++++++++++++++++++++++++++-------
1 file changed, 74 insertions(+), 15 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c
index a29d17d72ce..84aed3dedb4 100644
--- a/dlls/user32/sysparams.c
+++ b/dlls/user32/sysparams.c
@@ -4757,26 +4757,85 @@ LONG WINAPI QueryDisplayConfig(UINT32 flags, UINT32 *numpathelements, DISPLAYCON
LUID gpu_luid;
WCHAR device_name[CCHDEVICENAME];
DEVMODEW devmode;
+ POINT origin;
+ HMONITOR monitor;
+ MONITORINFOEXW monitor_info;
+ DISPLAYCONFIG_SOURCE_MODE *source_mode = &modeinfo[0].DUMMYUNIONNAME.sourceMode;
+ DISPLAYCONFIG_TARGET_MODE *target_mode = &modeinfo[1].DUMMYUNIONNAME.targetMode;
+ DISPLAYCONFIG_PATH_SOURCE_INFO *source_info = &pathinfo[0].sourceInfo;
+ DISPLAYCONFIG_PATH_TARGET_INFO *target_info = &pathinfo[0].targetInfo;
- FIXME("(%08x %p %p %p %p %p): semi-stub\n", flags, numpathelements, pathinfo, numinfoelements, modeinfo, topologyid);
+ TRACE("(%08x %p %p %p %p %p)\n", flags, numpathelements, pathinfo, numinfoelements, modeinfo, topologyid);
- if (!numpathelements || !numinfoelements)
- return ERROR_INVALID_PARAMETER;
+ if (*numpathelements < 1 || *numinfoelements < 2)
+ return ERROR_INSUFFICIENT_BUFFER;
- if (!*numpathelements || !*numinfoelements)
- return ERROR_INVALID_PARAMETER;
-
- if (flags != QDC_ALL_PATHS &&
- flags != QDC_ONLY_ACTIVE_PATHS &&
- flags != QDC_DATABASE_CURRENT)
- return ERROR_INVALID_PARAMETER;
+ origin.x = 0;
+ origin.y = 0;
+ monitor = MonitorFromPoint(origin, MONITOR_DEFAULTTOPRIMARY);
+ monitor_info.cbSize = sizeof(monitor_info);
+ if (!(GetMonitorInfoW(monitor, (MONITORINFO*) &monitor_info)))
+ {
+ return ERROR_GEN_FAILURE;
+ }
+ if (!(EnumDisplaySettingsW(monitor_info.szDevice, 0, &devmode)))
+ {
+ return ERROR_GEN_FAILURE;
+ }
- if (((flags == QDC_DATABASE_CURRENT) && !topologyid) ||
- ((flags != QDC_DATABASE_CURRENT) && topologyid))
- return ERROR_INVALID_PARAMETER;
+ AllocateLocallyUniqueId(&gpu_luid);
+
+ source_mode->width = devmode.dmPelsWidth;
+ source_mode->height = devmode.dmPelsHeight;
+ source_mode->pixelFormat = DISPLAYCONFIG_PIXELFORMAT_32BPP;
+ source_mode->position.x = 0;
+ source_mode->position.y = 0;
+
+ /* no idea what pixel rate is */
+ target_mode->targetVideoSignalInfo.pixelRate = 0xdeadbeef;
+ target_mode->targetVideoSignalInfo.hSyncFreq.Numerator = devmode.dmDisplayFrequency * devmode.dmPelsHeight;
+ target_mode->targetVideoSignalInfo.hSyncFreq.Denominator = 1;
+ target_mode->targetVideoSignalInfo.vSyncFreq.Numerator = devmode.dmDisplayFrequency;
+ target_mode->targetVideoSignalInfo.vSyncFreq.Denominator = 1;
+ target_mode->targetVideoSignalInfo.activeSize.cx = devmode.dmPelsWidth;
+ target_mode->targetVideoSignalInfo.activeSize.cy = devmode.dmPelsHeight;
+ target_mode->targetVideoSignalInfo.totalSize.cx = devmode.dmPelsWidth;
+ target_mode->targetVideoSignalInfo.totalSize.cy = devmode.dmPelsHeight;
+ target_mode->targetVideoSignalInfo.DUMMYUNIONNAME.videoStandard = D3DKMDT_VSS_NTSC_M;
+ target_mode->targetVideoSignalInfo.scanLineOrdering = DISPLAYCONFIG_SCANLINE_ORDERING_UNSPECIFIED;
+
+ modeinfo[0].infoType = DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE;
+ modeinfo[0].id = 0;
+ modeinfo[0].adapterId = gpu_luid;
+ modeinfo[1].infoType = DISPLAYCONFIG_MODE_INFO_TYPE_TARGET;
+ modeinfo[1].id = 0;
+ modeinfo[1].adapterId = gpu_luid;
+
+ source_info->adapterId = gpu_luid;
+ source_info->id = 0;
+ source_info->DUMMYUNIONNAME.modeInfoIdx = 0;
+ source_info->statusFlags = DISPLAYCONFIG_SOURCE_IN_USE;
+
+ target_info->adapterId = gpu_luid;
+ target_info->id = 0;
+
+ target_info->DUMMYUNIONNAME.modeInfoIdx = 1;
+ target_info->outputTechnology = DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HDMI;
+ target_info->rotation = DISPLAYCONFIG_ROTATION_IDENTITY;
+ target_info->scaling = DISPLAYCONFIG_SCALING_IDENTITY;
+ target_info->refreshRate.Numerator = devmode.dmDisplayFrequency;
+ target_info->refreshRate.Denominator = 1;
+ target_info->scanLineOrdering = DISPLAYCONFIG_SCANLINE_ORDERING_UNSPECIFIED;
+ target_info->targetAvailable = TRUE;
+ target_info->statusFlags = DISPLAYCONFIG_TARGET_IN_USE;
+
+ pathinfo[0].flags = DISPLAYCONFIG_PATH_ACTIVE;
+
+ if (flags == QDC_DATABASE_CURRENT && topologyid)
+ {
+ *topologyid = DISPLAYCONFIG_TOPOLOGY_INTERNAL;
+ }
- if (flags != QDC_ONLY_ACTIVE_PATHS)
- FIXME("only returning active paths\n");
if (topologyid)
{
--
2.27.0