summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-08-06 18:49:21 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-08-07 09:19:26 +0000
commit3068b185c5684c6e2175b047095b5ad80a6cbbac (patch)
treed1969102ee436b75e9cd17282ed444fb50e7ede8 /src/plugins/platforms
parente7063e6cc6673857097b865ea386eca6bcd6668f (diff)
macOS: Update window geometries after screen properties change
Task-number: QTBUG-69794 Task-number: QTBUG-68140 Change-Id: I4d33bc2136478d779cc4ae8170c3421d9a7557cc Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qcocoascreen.mm14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm
index a17a02b629..3e8261dfc2 100644
--- a/src/plugins/platforms/cocoa/qcocoascreen.mm
+++ b/src/plugins/platforms/cocoa/qcocoascreen.mm
@@ -138,6 +138,20 @@ void QCocoaScreen::updateGeometry()
QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), availableGeometry());
QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(screen(), m_logicalDpi.first, m_logicalDpi.second);
QWindowSystemInterface::handleScreenRefreshRateChange(screen(), m_refreshRate);
+
+ // When a screen changes its geometry, AppKit will send us a NSWindowDidMoveNotification
+ // for each window, resulting in calls to handleGeometryChange(), but this happens before
+ // the NSApplicationDidChangeScreenParametersNotification, so when we map the new geometry
+ // (which is correct at that point) to the screen using QCocoaScreen::mapFromNative(), we
+ // end up using the stale screen geometry, and the new window geometry we report is wrong.
+ // To make sure we finally report the correct window geometry, we need to do another pass
+ // of geometry reporting, now that the screen properties have been updates. FIXME: Ideally
+ // this would be solved by not caching the screen properties in QCocoaScreen, but that
+ // requires more research.
+ for (QWindow *window : windows()) {
+ if (QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow*>(window->handle()))
+ cocoaWindow->handleGeometryChange();
+ }
}
qreal QCocoaScreen::devicePixelRatio() const