summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp30
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.h1
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h2
3 files changed, 26 insertions, 7 deletions
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index ddc1114485e..57b833b299b 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -762,6 +762,28 @@ static void moveToVirtualScreen(QWindow *w, const QScreen *newScreen)
w->setGeometry(geometry);
}
+void QWindowsScreenManager::addScreen(const QWindowsScreenData &screenData)
+{
+ auto *newScreen = new QWindowsScreen(screenData);
+ m_screens.push_back(newScreen);
+ QWindowSystemInterface::handleScreenAdded(newScreen,
+ screenData.flags & QWindowsScreenData::PrimaryScreen);
+ qCDebug(lcQpaScreen) << "New Monitor: " << screenData;
+
+ // When a new screen is attached Window might move windows to the new screen
+ // automatically, in which case they will get a WM_DPICHANGED event. But at
+ // that point we have not received WM_DISPLAYCHANGE yet, so we fail to reflect
+ // the new screen's DPI. To account for this we explicitly check for screen
+ // change here, now that we are processing the WM_DISPLAYCHANGE.
+ const auto allWindows = QGuiApplication::allWindows();
+ for (QWindow *w : allWindows) {
+ if (w->isVisible() && w->handle() && w->type() != Qt::Desktop) {
+ if (QWindowsWindow *window = QWindowsWindow::windowsWindowOf(w))
+ window->checkForScreenChanged(QWindowsWindow::ScreenChangeMode::FromScreenAdded);
+ }
+ }
+}
+
void QWindowsScreenManager::removeScreen(int index)
{
qCDebug(lcQpaScreen) << "Removing Monitor:" << m_screens.at(index)->data();
@@ -784,7 +806,7 @@ void QWindowsScreenManager::removeScreen(int index)
&& (QWindowsWindow::baseWindowOf(w)->exStyle() & WS_EX_TOOLWINDOW)) {
moveToVirtualScreen(w, primaryScreen);
} else {
- QWindowSystemInterface::handleWindowScreenChanged(w, primaryScreen);
+ QWindowSystemInterface::handleWindowScreenChanged<QWindowSystemInterface::SynchronousDelivery>(w, primaryScreen);
}
++movedWindowCount;
}
@@ -813,11 +835,7 @@ bool QWindowsScreenManager::handleScreenChanges()
if (existingIndex == 0)
primaryScreenChanged = true;
} else {
- auto *newScreen = new QWindowsScreen(newData);
- m_screens.push_back(newScreen);
- QWindowSystemInterface::handleScreenAdded(newScreen,
- newData.flags & QWindowsScreenData::PrimaryScreen);
- qCDebug(lcQpaScreen) << "New Monitor: " << newData;
+ addScreen(newData);
} // exists
} // for new screens.
// Remove deleted ones but keep main monitors if we get only the
diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h
index ea6a29efe38..8d555998388 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.h
+++ b/src/plugins/platforms/windows/qwindowsscreen.h
@@ -119,6 +119,7 @@ public:
static bool isSingleScreen();
private:
+ void addScreen(const QWindowsScreenData &screenData);
void removeScreen(int index);
HWND m_displayChangeObserver = nullptr;
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index 424848503be..b67bd2850b3 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -342,7 +342,7 @@ public:
void alertWindow(int durationMs = 0);
void stopAlertWindow();
- enum ScreenChangeMode { FromGeometryChange, FromDpiChange };
+ enum ScreenChangeMode { FromGeometryChange, FromDpiChange, FromScreenAdded };
void checkForScreenChanged(ScreenChangeMode mode = FromGeometryChange);
void registerTouchWindow();