From 3c231940379998b39866098a5e0a88eaebf269ee Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 12 Jan 2021 14:11:52 +0100 Subject: [PATCH] Process TOUCH_CANCEL events from libinput individually This fixes a bug where cancelled touch sequences get ignored which results in stuck touch focus. --- input.cpp | 2 +- touch_input.cpp | 6 ++++++ touch_input.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/input.cpp b/input.cpp index 8156bef083..2561e17709 100644 --- a/input.cpp +++ b/input.cpp @@ -2326,7 +2326,7 @@ void InputRedirection::setupLibInput() connect(conn, &LibInput::Connection::touchDown, m_touch, &TouchInputRedirection::processDown); connect(conn, &LibInput::Connection::touchUp, m_touch, &TouchInputRedirection::processUp); connect(conn, &LibInput::Connection::touchMotion, m_touch, &TouchInputRedirection::processMotion); - connect(conn, &LibInput::Connection::touchCanceled, m_touch, &TouchInputRedirection::cancel); + connect(conn, &LibInput::Connection::touchCanceled, m_touch, &TouchInputRedirection::processCancel); connect(conn, &LibInput::Connection::touchFrame, m_touch, &TouchInputRedirection::frame); auto handleSwitchEvent = [this] (SwitchEvent::State state, quint32 time, quint64 timeMicroseconds, LibInput::Device *device) { SwitchEvent event(state, time, timeMicroseconds, device); diff --git a/touch_input.cpp b/touch_input.cpp index 269fc9521b..9348826a98 100644 --- a/touch_input.cpp +++ b/touch_input.cpp @@ -201,6 +201,12 @@ void TouchInputRedirection::processMotion(qint32 id, const QPointF &pos, quint32 m_windowUpdatedInCycle = false; } +void TouchInputRedirection::processCancel() +{ + m_touches--; + cancel(); +} + void TouchInputRedirection::cancel() { if (!inited()) { diff --git a/touch_input.h b/touch_input.h index 8d96113ab6..d0d67e7090 100644 --- a/touch_input.h +++ b/touch_input.h @@ -46,6 +46,7 @@ public: void processDown(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device = nullptr); void processUp(qint32 id, quint32 time, LibInput::Device *device = nullptr); void processMotion(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device = nullptr); + void processCancel(); void cancel(); void frame();