summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsscreen.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2012-11-14 12:22:19 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-15 13:55:00 +0100
commit9ae215925159f4e8f1a88fc6691c916eead67539 (patch)
tree0d598f1de9baac82393a3465998a4348a8a97000 /src/plugins/platforms/windows/qwindowsscreen.cpp
parente4c2a5c29f78def39801d8f2ea12b954594f7e7d (diff)
Fix QApplication::primaryScreen() in Windows
QPlatformInterface::screenAdded() documentation specifies that first added screen will be the primary screen, so we need to ensure that the screen Windows reports as the main display gets added first. Task-number: QTBUG-27988 Change-Id: Ibc17b05a6c37007ff749fb54ab62d47ffa40f8ac Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsscreen.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 0717a8ec60..a09ab583c8 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -125,11 +125,19 @@ BOOL QT_WIN_CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM
Qt::PortraitOrientation : Qt::LandscapeOrientation;
// EnumDisplayMonitors (as opposed to EnumDisplayDevices) enumerates only
// virtual desktop screens.
+ data.name = QString::fromWCharArray(info.szDevice);
data.flags = QWindowsScreenData::VirtualDesktop;
- if (info.dwFlags & MONITORINFOF_PRIMARY)
+ if (info.dwFlags & MONITORINFOF_PRIMARY) {
data.flags |= QWindowsScreenData::PrimaryScreen;
- data.name = QString::fromWCharArray(info.szDevice);
- result->append(data);
+ // QPlatformIntegration::screenAdded() documentation specifies that first
+ // added screen will be the primary screen, so order accordingly.
+ // Note that the side effect of this policy is that there is no way to change primary
+ // screen reported by Qt, unless we want to delete all existing screens and add them
+ // again whenever primary screen changes.
+ result->prepend(data);
+ } else {
+ result->append(data);
+ }
return TRUE;
}