Client: Fix the mouse being stuck in pressed state after startSystem{Move,Resize}

Fixes: QTBUG-97037
Pick-to: 6.7
Change-Id: I812c25b98909f9ff05ffca122e7201665023172e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
Ilya Fedin 2023-03-19 10:24:59 +04:00
parent 8066293430
commit 1d6cecbb4a
3 changed files with 17 additions and 5 deletions

View File

@ -835,6 +835,8 @@ void QWaylandInputDevice::Pointer::pointer_button(uint32_t serial, uint32_t time
default: return; // invalid button number (as far as Qt is concerned)
}
mLastButton = qt_button;
if (state)
mButtons |= qt_button;
else
@ -873,10 +875,13 @@ void QWaylandInputDevice::Pointer::invalidateFocus()
void QWaylandInputDevice::Pointer::releaseButtons()
{
if (mButtons == Qt::NoButton)
return;
mButtons = Qt::NoButton;
if (auto *window = focusWindow()) {
ReleaseEvent e(focusWindow(), mParent->mTime, mSurfacePos, mGlobalPos, mButtons, Qt::NoButton, mParent->modifiers());
ReleaseEvent e(focusWindow(), mParent->mTime, mSurfacePos, mGlobalPos, mButtons, mLastButton, mParent->modifiers());
window->handleMouse(mParent, e);
}
}

View File

@ -338,6 +338,7 @@ public:
QPointF mSurfacePos;
QPointF mGlobalPos;
Qt::MouseButtons mButtons = Qt::NoButton;
Qt::MouseButton mLastButton = Qt::NoButton;
struct FrameData {
QWaylandPointerEvent *event = nullptr;

View File

@ -1736,15 +1736,21 @@ void QWaylandWindow::propagateSizeHints()
bool QWaylandWindow::startSystemResize(Qt::Edges edges)
{
if (auto *seat = display()->lastInputDevice())
return mShellSurface && mShellSurface->resize(seat, edges);
if (auto *seat = display()->lastInputDevice()) {
bool rc = mShellSurface && mShellSurface->resize(seat, edges);
seat->handleEndDrag();
return rc;
}
return false;
}
bool QtWaylandClient::QWaylandWindow::startSystemMove()
{
if (auto seat = display()->lastInputDevice())
return mShellSurface && mShellSurface->move(seat);
if (auto seat = display()->lastInputDevice()) {
bool rc = mShellSurface && mShellSurface->move(seat);
seat->handleEndDrag();
return rc;
}
return false;
}