summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorYuhang Zhao <2546789017@qq.com>2022-01-06 18:03:21 +0800
committerYuhang Zhao <2546789017@qq.com>2022-01-12 14:20:17 +0800
commite9fd1c6aab28f027760da76ebc154f0ff9aefcf8 (patch)
treeb899c639c1b1799b937c57e693d8c56617749489 /src/plugins/platforms/windows
parent11a4546ce928bb7ff1363d7cb3ff3e8856f1f7f8 (diff)
QScreen_win: retrieve user friendly monitor name
[ChangeLog][QtGui][QScreen] QScreen::name() now returns the user friendly name instead of the GDI device name on Windows. This is consistent with other platforms and also obeys the documentation. Fixes: QTBUG-74317 Pick-to: 6.3 6.2 Change-Id: Iefbfaa1f9fd504277a0b5eb8c7a1fc13257c01f2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 4474905744..0c639eb710 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -151,8 +151,20 @@ static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
data->hMonitor = hMonitor;
data->geometry = QRect(QPoint(info.rcMonitor.left, info.rcMonitor.top), QPoint(info.rcMonitor.right - 1, info.rcMonitor.bottom - 1));
data->availableGeometry = QRect(QPoint(info.rcWork.left, info.rcWork.top), QPoint(info.rcWork.right - 1, info.rcWork.bottom - 1));
- data->name = QString::fromWCharArray(info.szDevice);
- if (data->name == u"WinDisc") {
+ DISPLAYCONFIG_PATH_INFO pathInfo = {};
+ const bool hasPathInfo = getPathInfo(info, &pathInfo);
+ if (hasPathInfo) {
+ DISPLAYCONFIG_TARGET_DEVICE_NAME deviceName = {};
+ deviceName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME;
+ deviceName.header.size = sizeof(DISPLAYCONFIG_TARGET_DEVICE_NAME);
+ deviceName.header.adapterId = pathInfo.targetInfo.adapterId;
+ deviceName.header.id = pathInfo.targetInfo.id;
+ if (DisplayConfigGetDeviceInfo(&deviceName.header) == ERROR_SUCCESS)
+ data->name = QString::fromWCharArray(deviceName.monitorFriendlyDeviceName);
+ }
+ if (data->name.isEmpty())
+ data->name = QString::fromWCharArray(info.szDevice);
+ if (wcscmp(info.szDevice, L"WinDisc") == 0) {
data->flags |= QWindowsScreenData::LockScreen;
} else {
if (const HDC hdc = CreateDC(info.szDevice, nullptr, nullptr, nullptr)) {
@@ -174,8 +186,7 @@ static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
// ### We might want to consider storing adapterId/id from DISPLAYCONFIG_PATH_TARGET_INFO,
// if we are going to use DISPLAYCONFIG lookups more.
- DISPLAYCONFIG_PATH_INFO pathInfo = {};
- if (getPathInfo(info, &pathInfo)) {
+ if (hasPathInfo) {
switch (pathInfo.targetInfo.rotation) {
case DISPLAYCONFIG_ROTATION_IDENTITY:
data->orientation = Qt::LandscapeOrientation;