From 1df10c3518c3568c5273b0125249770fd67f7ef7 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 17 Oct 2022 13:36:17 +0100 Subject: [PATCH] Handle scale override in locked and confined pointers BUG: 460532 --- src/wayland/pointerconstraints_v1_interface.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/wayland/pointerconstraints_v1_interface.cpp b/src/wayland/pointerconstraints_v1_interface.cpp index b149ce78d2..87983ce2d2 100644 --- a/src/wayland/pointerconstraints_v1_interface.cpp +++ b/src/wayland/pointerconstraints_v1_interface.cpp @@ -16,6 +16,15 @@ namespace KWaylandServer { static const int s_version = 1; +static QRegion mapScaleOverride(const QRegion ®ion, qreal scaleOverride) +{ + QRegion out; + for (const QRect &rect : region) { + out += QRect(rect.topLeft() / scaleOverride, rect.size() / scaleOverride); + } + return out; +} + PointerConstraintsV1InterfacePrivate::PointerConstraintsV1InterfacePrivate(Display *display) : QtWaylandServer::zwp_pointer_constraints_v1(*display, s_version) { @@ -138,13 +147,14 @@ LockedPointerV1InterfacePrivate::LockedPointerV1InterfacePrivate(LockedPointerV1 void LockedPointerV1InterfacePrivate::commit() { + qreal scaleOverride = surface->scaleOverride(); if (hasPendingRegion) { - region = pendingRegion; + region = mapScaleOverride(pendingRegion, scaleOverride); hasPendingRegion = false; Q_EMIT q->regionChanged(); } if (hasPendingHint) { - hint = pendingHint; + hint = pendingHint / scaleOverride; hasPendingHint = false; Q_EMIT q->cursorPositionHintChanged(); } @@ -243,8 +253,9 @@ ConfinedPointerV1InterfacePrivate::ConfinedPointerV1InterfacePrivate(ConfinedPoi void ConfinedPointerV1InterfacePrivate::commit() { + qreal scaleOverride = surface->scaleOverride(); if (hasPendingRegion) { - region = pendingRegion; + region = mapScaleOverride(pendingRegion, scaleOverride); hasPendingRegion = false; Q_EMIT q->regionChanged(); }