From be355391235c3174aaae0ae3c7f507d3209ba514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 6 Aug 2018 18:24:20 +0200 Subject: Use consistent naming of QPA screen change callbacks in QGuiApplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I76be8a993e5d71e472faf9a5770b4c1128e8a4c6 Reviewed-by: Gatis Paeglis Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qguiapplication.cpp | 16 ++++++++-------- src/gui/kernel/qguiapplication_p.h | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 2ef689b5b9..e81c88cc71 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1858,19 +1858,19 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv static_cast(e)); break; case QWindowSystemInterfacePrivate::ScreenOrientation: - QGuiApplicationPrivate::reportScreenOrientationChange( + QGuiApplicationPrivate::processScreenOrientationChange( static_cast(e)); break; case QWindowSystemInterfacePrivate::ScreenGeometry: - QGuiApplicationPrivate::reportGeometryChange( + QGuiApplicationPrivate::processScreenGeometryChange( static_cast(e)); break; case QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInch: - QGuiApplicationPrivate::reportLogicalDotsPerInchChange( + QGuiApplicationPrivate::processScreenLogicalDotsPerInchChange( static_cast(e)); break; case QWindowSystemInterfacePrivate::ScreenRefreshRate: - QGuiApplicationPrivate::reportRefreshRateChange( + QGuiApplicationPrivate::processScreenRefreshRateChange( static_cast(e)); break; case QWindowSystemInterfacePrivate::ThemeChange: @@ -2901,7 +2901,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To } } -void QGuiApplicationPrivate::reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e) +void QGuiApplicationPrivate::processScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e) { // This operation only makes sense after the QGuiApplication constructor runs if (QCoreApplication::startingUp()) @@ -2938,7 +2938,7 @@ void QGuiApplicationPrivate::reportScreenOrientationChange(QScreen *s) QCoreApplication::sendEvent(QCoreApplication::instance(), &event); } -void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e) +void QGuiApplicationPrivate::processScreenGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e) { // This operation only makes sense after the QGuiApplication constructor runs if (QCoreApplication::startingUp()) @@ -2981,7 +2981,7 @@ void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate: } } -void QGuiApplicationPrivate::reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e) +void QGuiApplicationPrivate::processScreenLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e) { // This operation only makes sense after the QGuiApplication constructor runs if (QCoreApplication::startingUp()) @@ -2996,7 +2996,7 @@ void QGuiApplicationPrivate::reportLogicalDotsPerInchChange(QWindowSystemInterfa emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); } -void QGuiApplicationPrivate::reportRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e) +void QGuiApplicationPrivate::processScreenRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e) { // This operation only makes sense after the QGuiApplication constructor runs if (QCoreApplication::startingUp()) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 2fefaf0af6..f6f7aa7f8c 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -139,10 +139,10 @@ public: static void updateFilteredScreenOrientation(QScreen *screen); static void reportScreenOrientationChange(QScreen *screen); - static void reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e); - static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e); - static void reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e); - static void reportRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e); + static void processScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e); + static void processScreenGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e); + static void processScreenLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e); + static void processScreenRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e); static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce); static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e); -- cgit v1.2.3 From e7063e6cc6673857097b865ea386eca6bcd6668f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 6 Aug 2018 18:37:14 +0200 Subject: Add QPlatformScreen::windows() helper to return all windows on screen Change-Id: Ib55b37b64ed0890ca777dfea8c4d702e267c34bf Reviewed-by: Gatis Paeglis --- src/gui/kernel/qplatformscreen.cpp | 24 +++++++++++++++--------- src/gui/kernel/qplatformscreen.h | 2 ++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index e22037c1e9..358ff16930 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -103,6 +103,20 @@ QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const return 0; } +/*! + Return all windows residing on this screen. +*/ +QWindowList QPlatformScreen::windows() const +{ + QWindowList windows; + for (QWindow *window : QGuiApplication::allWindows()) { + if (platformScreenForWindow(window) != this) + continue; + windows.append(window); + } + return windows; +} + /*! Find the sibling screen corresponding to \a globalPos. @@ -369,25 +383,17 @@ QPlatformCursor *QPlatformScreen::cursor() const */ void QPlatformScreen::resizeMaximizedWindows() { - QList windows = QGuiApplication::allWindows(); - // 'screen()' still has the old geometry info while 'this' has the new geometry info const QRect oldGeometry = screen()->geometry(); const QRect oldAvailableGeometry = screen()->availableGeometry(); const QRect newGeometry = deviceIndependentGeometry(); const QRect newAvailableGeometry = QHighDpi::fromNative(availableGeometry(), QHighDpiScaling::factor(this), newGeometry.topLeft()); - // make sure maximized and fullscreen windows are updated - for (int i = 0; i < windows.size(); ++i) { - QWindow *w = windows.at(i); - + for (QWindow *w : windows()) { // Skip non-platform windows, e.g., offscreen windows. if (!w->handle()) continue; - if (platformScreenForWindow(w) != this) - continue; - if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) w->setGeometry(newAvailableGeometry); else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index 97fe3fed03..e9d64c8a29 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -123,6 +123,8 @@ public: virtual void setOrientationUpdateMask(Qt::ScreenOrientations mask); virtual QWindow *topLevelAt(const QPoint &point) const; + QWindowList windows() const; + virtual QList virtualSiblings() const; const QPlatformScreen *screenForPosition(const QPoint &point) const; -- cgit v1.2.3 From 3068b185c5684c6e2175b047095b5ad80a6cbbac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 6 Aug 2018 18:49:21 +0200 Subject: macOS: Update window geometries after screen properties change Task-number: QTBUG-69794 Task-number: QTBUG-68140 Change-Id: I4d33bc2136478d779cc4ae8170c3421d9a7557cc Reviewed-by: Erik Verbruggen --- src/plugins/platforms/cocoa/qcocoascreen.mm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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(window->handle())) + cocoaWindow->handleGeometryChange(); + } } qreal QCocoaScreen::devicePixelRatio() const -- cgit v1.2.3 From bedf50a5bb9656a64ec609536366f90929a63c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 6 Aug 2018 17:05:30 +0200 Subject: macOS: Don't blend the backingstore unless the window has a background MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there's no background, we should copy the backingstore, so that the backingstore is not blended with the result of the previous flush. The unified toolbar case is covered by the window having a textured background. Task-number: QTBUG-69773 Change-Id: I2f4eed9f44a60ebe7495ce68cf5a54d3d2424b0c Reviewed-by: Erik Verbruggen Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 091453785e..1343fbc45a 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -162,13 +162,13 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo const qreal devicePixelRatio = m_image.devicePixelRatio(); - // If the flushed window is a content view, and not in unified toolbar mode, - // and is fully opaque, we can get away with copying the backingstore instead - // of blending. + // If the flushed window is a content view, and we're filling the drawn area + // completely, or it doesn't have a window background we need to preserve, + // we can get away with copying instead of blending the backing store. QCocoaWindow *cocoaWindow = static_cast(window->handle()); const NSCompositingOperation compositingOperation = cocoaWindow->isContentView() - && cocoaWindow->isOpaque() && !windowHasUnifiedToolbar() ? - NSCompositingOperationCopy : NSCompositingOperationSourceOver; + && (cocoaWindow->isOpaque() || view.window.backgroundColor == NSColor.clearColor) + ? NSCompositingOperationCopy : NSCompositingOperationSourceOver; #ifdef QT_DEBUG static bool debugBackingStoreFlush = [[NSUserDefaults standardUserDefaults] -- cgit v1.2.3