From f54d7a2697261754cfcfcc06d0fb5682955f1859 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Thu, 1 Jul 2021 01:34:54 +0200 Subject: [PATCH] xdgshellclient: fix moveresize with touch and CSD When moveresize is done with touch we need to use the current touch point and not the mouse position. BUG: 438283 CCBUG: 431489 --- src/xdgshellclient.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/xdgshellclient.cpp b/src/xdgshellclient.cpp index 6e0798ac98..d21d108289 100644 --- a/src/xdgshellclient.cpp +++ b/src/xdgshellclient.cpp @@ -21,6 +21,7 @@ #if KWIN_BUILD_ACTIVITIES #include "activities.h" #endif +#include "touch_input.h" #include #include @@ -961,7 +962,13 @@ void XdgToplevelClient::handleMoveRequested(SeatInterface *seat, quint32 serial) return; } if (isMovable()) { - performMouseCommand(Options::MouseMove, Cursors::self()->mouse()->pos()); + QPoint cursorPos; + if (seat->hasImplicitPointerGrab(serial)) { + cursorPos = Cursors::self()->mouse()->pos(); + } else { + cursorPos = input()->touch()->position().toPoint(); + } + performMouseCommand(Options::MouseMove, cursorPos); } else { qCDebug(KWIN_CORE) << this << "is immovable, ignoring the move request"; } @@ -979,7 +986,13 @@ void XdgToplevelClient::handleResizeRequested(SeatInterface *seat, Qt::Edges edg finishInteractiveMoveResize(false); } setInteractiveMoveResizePointerButtonDown(true); - setInteractiveMoveOffset(Cursors::self()->mouse()->pos() - pos()); // map from global + QPoint cursorPos; + if (seat->hasImplicitPointerGrab(serial)) { + cursorPos = Cursors::self()->mouse()->pos(); + } else { + cursorPos = input()->touch()->position().toPoint(); + } + setInteractiveMoveOffset(cursorPos - pos()); // map from global setInvertedInteractiveMoveOffset(rect().bottomRight() - interactiveMoveOffset()); setUnrestrictedInteractiveMoveResize(false); auto toPosition = [edges] {