diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2016-07-08 14:46:34 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2016-07-11 07:42:30 +0000 |
commit | d8b4bef3ddff327598027c8f94a61e3d0b61a2dd (patch) | |
tree | a58c174c9eb1143b2f26bf4027729777b18abd58 | |
parent | f497a5bb87270174b8e0106b7eca1992d44ff15d (diff) |
Fix high-DPI scaling of window decorations for shared memory buffers
Change-Id: I6833ab86ffdb4e37dad5108baddb7a54cfb5e9fa
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
-rw-r--r-- | src/client/qwaylandshmbackingstore.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp index 3bbe24c31..5c93d2ba3 100644 --- a/src/client/qwaylandshmbackingstore.cpp +++ b/src/client/qwaylandshmbackingstore.cpp @@ -301,29 +301,37 @@ void QWaylandShmBackingStore::updateDecorations() QPainter decorationPainter(entireSurface()); decorationPainter.setCompositionMode(QPainter::CompositionMode_Source); QImage sourceImage = windowDecoration()->contentImage(); - QRect target; + + qreal dp = sourceImage.devicePixelRatio(); + int dpWidth = int(sourceImage.width() / dp); + int dpHeight = int(sourceImage.height() / dp); + QMatrix sourceMatrix; + sourceMatrix.scale(dp, dp); + QRect target; // needs to be in device independent pixels + //Top target.setX(0); target.setY(0); - target.setWidth(sourceImage.width()); + target.setWidth(dpWidth); target.setHeight(windowDecorationMargins().top()); - decorationPainter.drawImage(target, sourceImage, target); + decorationPainter.drawImage(target, sourceImage, sourceMatrix.mapRect(target)); //Left target.setWidth(windowDecorationMargins().left()); - target.setHeight(sourceImage.height()); - decorationPainter.drawImage(target, sourceImage, target); + target.setHeight(dpHeight); + decorationPainter.drawImage(target, sourceImage, sourceMatrix.mapRect(target)); //Right - target.setX(sourceImage.width() - windowDecorationMargins().right()); - decorationPainter.drawImage(target, sourceImage, target); + target.setX(dpWidth - windowDecorationMargins().right()); + target.setWidth(windowDecorationMargins().right()); + decorationPainter.drawImage(target, sourceImage, sourceMatrix.mapRect(target)); //Bottom target.setX(0); - target.setY(sourceImage.height() - windowDecorationMargins().bottom()); - target.setWidth(sourceImage.width()); + target.setY(dpHeight - windowDecorationMargins().bottom()); + target.setWidth(dpWidth); target.setHeight(windowDecorationMargins().bottom()); - decorationPainter.drawImage(target, sourceImage, target); + decorationPainter.drawImage(target, sourceImage, sourceMatrix.mapRect(target)); } QWaylandAbstractDecoration *QWaylandShmBackingStore::windowDecoration() const |