summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qhighdpiscaling_p.h
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-06-02 15:32:02 +0200
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-06-03 07:51:47 +0000
commit39413100cdc8cd7d3ef55ff3c79d94b7cf89cc5e (patch)
treef95d0ebd3a7bb69bab3b3bdef675667a9b978b07 /src/gui/kernel/qhighdpiscaling_p.h
parentd0a017e9b03dd3cf19b640fad4dd56ef0494ce5f (diff)
Fix drag and drop for Xcb
Make the xcb plugin work in native coordinates, using platform windows as much as possible. As part of this, replace QMouseEvent in QBasicDrag with just a QPoint. This is private API, so we can change this without warning. In addition to xcb, QBasicDrag is used in QSimpleDrag and for Wayland. QSimpleDrag does not yet have a fix for highDpi, but it should continue working in the non-scaled case. Wayland (and any other module which uses QBasicDrag) will need a compile fix. Also fix bug in QWindowSystemInterface: handleDrag()/handleDrop() take positions in window local coordinates, not global. Change-Id: I86543e4f52a7b3ba1efeac815cf89bbd97c0a0a2 Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qhighdpiscaling_p.h')
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 827c21ad5c..6c96fa2e07 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -171,6 +171,18 @@ inline QRect fromNativeScreenGeometry(const QRect &nativeScreenGeometry, const Q
return QRect(nativeScreenGeometry.topLeft(), fromNative(nativeScreenGeometry.size(), QHighDpiScaling::factor(screen)));
}
+inline QPoint fromNativeLocalPosition(const QPoint &pos, const QWindow *window)
+{
+ const qreal scaleFactor = QHighDpiScaling::factor(window);
+ return pos / scaleFactor;
+}
+
+inline QPoint toNativeLocalPosition(const QPoint &pos, const QWindow *window)
+{
+ const qreal scaleFactor = QHighDpiScaling::factor(window);
+ return pos * scaleFactor;
+}
+
inline QPointF fromNativeLocalPosition(const QPointF &pos, const QWindow *window)
{
const qreal scaleFactor = QHighDpiScaling::factor(window);