From 8802826de6d8a87ad6f29b98eff1eb36964c3e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 25 Sep 2018 12:20:37 +0200 Subject: Make grabWindow return pixmap with correct dpr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The devicePixelRatio on the returned pixmap should be the product of the Qt and platform scale factors. This handles the corner case of setting QT_SCALE_FACTOR on macOS with a high-dpi display. Change-Id: I3600165d47c03c4e043bcc5e375932cc3fc0c544 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/kernel/qscreen.cpp') diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 479e228e27..0ff439abea 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -748,7 +748,7 @@ QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height) QPixmap result = platformScreen->grabWindow(window, nativePos.x(), nativePos.y(), nativeSize.width(), nativeSize.height()); - result.setDevicePixelRatio(factor); + result.setDevicePixelRatio(result.devicePixelRatio() * factor); return result; } -- cgit v1.2.3 From c9f375f4e3d90e1296d8159f98f003c7570f902f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 25 Sep 2018 13:37:20 +0200 Subject: Document QScreen::grabWindow high-DPI behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib32510ff30e907365e64921fda14e686a495c77c Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qscreen.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gui/kernel/qscreen.cpp') diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 0ff439abea..f208eb02be 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -701,6 +701,11 @@ void QScreenPrivate::updatePrimaryOrientation() border of the window. If \a height is negative, the function copies everything to the bottom of the window. + The offset and size arguments are specified in device independent + pixels. The returned pixmap may be larger than the requested size + when grabbing from a high-DPI screen. Call QPixmap::devicePixelRatio() + to determine if this is the case. + The window system identifier (\c WId) can be retrieved using the QWidget::winId() function. The rationale for using a window identifier and not a QWidget, is to enable grabbing of windows -- cgit v1.2.3