From 54285dd5f6a660ce0ddd45b222d6c4dcd8ea6f74 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 22 Aug 2018 16:47:52 +0200 Subject: Compositor: Fix incorrect hotspot when output.scaleFactor != dpr This makes WaylandCursorItem automatically move the cursor hotspot when the scale factor or dpr changes Task-number: QTBUG-70134 Change-Id: I146ad81e92fe708a6141271ea173bf053b5e05c8 Reviewed-by: Paul Olav Tvete --- src/imports/compositor/WaylandCursorItem.qml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/imports/compositor/WaylandCursorItem.qml b/src/imports/compositor/WaylandCursorItem.qml index c835ef8b0..331784109 100644 --- a/src/imports/compositor/WaylandCursorItem.qml +++ b/src/imports/compositor/WaylandCursorItem.qml @@ -39,17 +39,24 @@ import QtQuick 2.0 import QtWayland.Compositor 1.0 +import QtQuick.Window 2.11 WaylandQuickItem { id: cursorItem property QtObject seat property int hotspotX: 0 property int hotspotY: 0 + // If we've set an output scale factor different from the device pixel ratio + // then the item will be rendered scaled, so we need to shift the hotspot accordingly + property real scaleCorrection: output ? output.scaleFactor / Screen.devicePixelRatio : 1 visible: cursorItem.surface != null inputEventsEnabled: false enabled: false - transform: Translate { x: -hotspotX; y: -hotspotY } + transform: Translate { + x: -hotspotX * scaleCorrection + y: -hotspotY * scaleCorrection + } Connections { target: seat -- cgit v1.2.3