diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-01-22 14:38:44 +0100 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2019-01-30 14:34:31 +0000 |
commit | d0063d0972b29e9a2d4bdff837e3d4c23ac2e6cc (patch) | |
tree | fb312f0b51f042f73510be8ae6da22780d7caf4d /src/client | |
parent | 344e884d93bc35a8011427963f39575e56a5418a (diff) |
Client: Fix incorrect decoration size when QT_SCALE_FACTOR is set
[ChangeLog][QPA plugin] Fixed a bug where window decorations were to small for
for the content when QT_SCALE_FACTOR was set.
Fixes: QTBUG-72993
Change-Id: I1ed26e038c27f7c4454a6bcc04f0849e4af789e7
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/qwaylandabstractdecoration.cpp | 11 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 23 | ||||
-rw-r--r-- | src/client/qwaylandwindow_p.h | 2 |
3 files changed, 27 insertions, 9 deletions
diff --git a/src/client/qwaylandabstractdecoration.cpp b/src/client/qwaylandabstractdecoration.cpp index 32fa6e1b5..0f00b9890 100644 --- a/src/client/qwaylandabstractdecoration.cpp +++ b/src/client/qwaylandabstractdecoration.cpp @@ -115,16 +115,17 @@ const QImage &QWaylandAbstractDecoration::contentImage() { Q_D(QWaylandAbstractDecoration); if (d->m_isDirty) { - //Update the decoration backingstore + // Update the decoration backingstore - const int scale = waylandWindow()->scale(); - const QSize imageSize = window()->frameGeometry().size() * scale; + const int bufferScale = waylandWindow()->scale(); + const QSize imageSize = waylandWindow()->surfaceSize() * bufferScale; d->m_decorationContentImage = QImage(imageSize, QImage::Format_ARGB32_Premultiplied); - d->m_decorationContentImage.setDevicePixelRatio(scale); + // Only scale by buffer scale, not QT_SCALE_FACTOR etc. + d->m_decorationContentImage.setDevicePixelRatio(bufferScale); d->m_decorationContentImage.fill(Qt::transparent); this->paint(&d->m_decorationContentImage); - QRegion damage = marginsRegion(window()->geometry().size(), window()->frameMargins()); + QRegion damage = marginsRegion(waylandWindow()->surfaceSize(), waylandWindow()->frameMargins()); for (QRect r : damage) waylandWindow()->damage(r); diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index e81221fb5..9e95b3068 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -341,7 +341,7 @@ void QWaylandWindow::setGeometry(const QRect &rect) sendExposeEvent(exposeGeometry); if (mShellSurface) - mShellSurface->setWindowGeometry(QRect(QPoint(0, 0), window()->frameGeometry().size())); + mShellSurface->setWindowGeometry(windowGeometry()); } void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset) @@ -654,6 +654,23 @@ QMargins QWaylandWindow::frameMargins() const return QPlatformWindow::frameMargins(); } +/*! + * Size, with decorations (including including eventual shadows) in wl_surface coordinates + */ +QSize QWaylandWindow::surfaceSize() const +{ + return geometry().marginsAdded(frameMargins()).size(); +} + +/*! + * Window geometry as defined by the xdg-shell spec (in wl_surface coordinates) + * topLeft is where the shadow stops and the decorations border start. + */ +QRect QWaylandWindow::windowGeometry() const +{ + return QRect(QPoint(), surfaceSize()); +} + QWaylandShellSurface *QWaylandWindow::shellSurface() const { return mShellSurface; @@ -848,9 +865,7 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan #if QT_CONFIG(cursor) if (e.type == QWaylandPointerEvent::Enter) { - QRect windowGeometry = window()->frameGeometry(); - windowGeometry.moveTopLeft({0, 0}); // convert to wayland surface coordinates - QRect contentGeometry = windowGeometry.marginsRemoved(frameMargins()); + QRect contentGeometry = windowGeometry().marginsRemoved(frameMargins()); if (contentGeometry.contains(e.local.toPoint())) restoreMouseCursor(inputDevice); } diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index 146767a1e..0e573f350 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -125,6 +125,8 @@ public: void waitForFrameSync(); QMargins frameMargins() const override; + QSize surfaceSize() const; + QRect windowGeometry() const; static QWaylandWindow *fromWlSurface(::wl_surface *surface); |