From 3e66edd846feae4c6b60c9da485353493f175d81 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 25 Jun 2018 15:49:32 +0200 Subject: [PATCH] Client: Fix cursor hotspot on high-dpi QWaylandInputDevice::setCursor(wl_buffer, QPoint, QSize, bufferscale) assumes a hotspot and a size in surface coordinates, while wl_cursor_image uses pixel coordinates. Divide by bufferScale to get the correct values. This breaks hidpi cursors on kwin 5.13.1 and earlier, where buffer scale for cursor surfaces are ignored. Change-Id: I7c86bc541ccf5fb878facebbe93d2b1f842dfc5c Reviewed-by: David Edmundson Reviewed-by: Paul Olav Tvete --- .../platforms/wayland/qwaylandinputdevice.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 4835bd68e9d..b4b7c4ef323 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -389,11 +389,17 @@ void QWaylandInputDevice::setCursor(const QCursor &cursor, QWaylandScreen *scree void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image, int bufferScale) { - setCursor(buffer, - image ? QPoint(image->hotspot_x, image->hotspot_y) : QPoint(), - image ? QSize(image->width, image->height) : QSize(), bufferScale); + if (image) { + // Convert from pixel coordinates to surface coordinates + QPoint hotspot = QPoint(image->hotspot_x, image->hotspot_y) / bufferScale; + QSize size = QSize(image->width, image->height) / bufferScale; + setCursor(buffer, hotspot, size, bufferScale); + } else { + setCursor(buffer, QPoint(), QSize(), bufferScale); + } } +// size and hotspot are in surface coordinates void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size, int bufferScale) { if (mCaps & WL_SEAT_CAPABILITY_POINTER) {