diff options
Diffstat (limited to 'src/platformsupport/input/libinput/qlibinputtouch.cpp')
-rw-r--r-- | src/platformsupport/input/libinput/qlibinputtouch.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index 0a0e9daccb..42925a18e1 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -41,6 +41,7 @@ #include <libinput.h> #include <QtGui/QGuiApplication> #include <QtGui/QScreen> +#include <QtGui/private/qhighdpiscaling_p.h> QT_BEGIN_NAMESPACE @@ -63,10 +64,14 @@ QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e static inline QPointF getPos(libinput_event_touch *e) { - const QSize screenSize = QGuiApplication::primaryScreen()->geometry().size(); - const double x = libinput_event_touch_get_x_transformed(e, screenSize.width()); - const double y = libinput_event_touch_get_y_transformed(e, screenSize.height()); - return QPointF(x, y); + // TODO Map to correct screen using QTouchOutputMapping. + // Perhaps investigate libinput_device_get_output_name as well. + // For now just use the primary screen. + QScreen *screen = QGuiApplication::primaryScreen(); + const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen); + const double x = libinput_event_touch_get_x_transformed(e, geom.width()); + const double y = libinput_event_touch_get_y_transformed(e, geom.height()); + return geom.topLeft() + QPointF(x, y); } void QLibInputTouch::registerDevice(libinput_device *dev) |