summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-02-24 13:13:36 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-02-26 07:16:48 +0000
commitc0963486ce689e778d59dafd26d36d8ef9e3ee74 (patch)
tree3660d692015ea3b83358d09eeb1cf76582dc3ea5 /src/gui/kernel
parent44357dbe423d430246504d977f4422ed0e2e7a5a (diff)
QScreen::grabWindow(): Scale the coordinates.
The coordinates need to be scaled before calling QPlatformScreen::grabWindow() On return, set a devicePixelRatio on the pixmap. Adapt the QWidget test to scale the grabbed pixmaps. Fixes pixeltool displaying the wrong part of the screen when High DPI scaling is in effect. Task-number: QTBUG-46615 Change-Id: I12de7df0da669230cf0fae74f4a42d43f061d5ff Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qscreen.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index 52e7686439..e87f58d735 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -40,6 +40,7 @@
#include <QtCore/QDebug>
#include <QtCore/private/qobject_p.h>
+#include "qhighdpiscaling_p.h"
QT_BEGIN_NAMESPACE
@@ -683,7 +684,19 @@ QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height)
qWarning("invoked with handle==0");
return QPixmap();
}
- return platformScreen->grabWindow(window, x, y, width, height);
+ const qreal factor = QHighDpiScaling::factor(this);
+ if (qFuzzyCompare(factor, 1))
+ return platformScreen->grabWindow(window, x, y, width, height);
+
+ const QPoint nativePos = QHighDpi::toNative(QPoint(x, y), factor);
+ QSize nativeSize(width, height);
+ if (nativeSize.isValid())
+ nativeSize = QHighDpi::toNative(nativeSize, factor);
+ QPixmap result =
+ platformScreen->grabWindow(window, nativePos.x(), nativePos.y(),
+ nativeSize.width(), nativeSize.height());
+ result.setDevicePixelRatio(factor);
+ return result;
}
#ifndef QT_NO_DEBUG_STREAM