summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-06-25 15:49:32 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-06-27 11:20:00 +0000
commita1f92161be0676b048034d1d378d7a9729d1d728 (patch)
tree2c1ec99c3576f79c5796cbd13905ed4efcb14012 /src/client
parentfbcb9769d3f1748b95e243064fd0b6da8215f3b9 (diff)
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 <davidedmundson@kde.org> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/client')
-rw-r--r--src/client/qwaylandinputdevice.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
index 4835bd68e..b4b7c4ef3 100644
--- a/src/client/qwaylandinputdevice.cpp
+++ b/src/client/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) {