autotests: Fix testTouchPoint

Gesture recognition code doesn't handle correctly cancelling a touch
sequence. testTouchPoint in one of its tests simulates pressing the
screen with three fingers and cancelling the touch sequence.
This commit is contained in:
Vlad Zahorodnii 2022-05-12 14:16:47 +03:00
parent f1c9cb5d64
commit be717d5c67
2 changed files with 16 additions and 3 deletions

View file

@ -1088,7 +1088,9 @@ public:
}
if (m_touchPoints.count() >= 3 && !m_gestureCancelled) {
m_gestureTaken = true;
m_syntheticCancel = true;
input()->processFilters(std::bind(&InputEventFilter::touchCancel, std::placeholders::_1));
m_syntheticCancel = false;
input()->shortcuts()->processSwipeStart(DeviceType::Touchscreen, m_touchPoints.count());
return true;
}
@ -1128,12 +1130,23 @@ public:
}
m_gestureTaken &= m_touchPoints.count() > 0;
m_gestureCancelled &= m_gestureTaken;
m_touchGestureCancelSent &= m_gestureTaken;
return true;
}
return false;
}
bool touchCancel() override
{
if (m_syntheticCancel) {
return false;
}
const bool oldGestureTaken = m_gestureTaken;
m_gestureTaken = false;
m_gestureCancelled = false;
m_touchPoints.clear();
return oldGestureTaken;
}
bool touchFrame() override
{
return m_gestureTaken;
@ -1142,7 +1155,7 @@ public:
private:
bool m_gestureTaken = false;
bool m_gestureCancelled = false;
bool m_touchGestureCancelSent = false;
bool m_syntheticCancel = false;
uint32_t m_lastTouchDownTime = 0;
QPointF m_lastAverageDistance;
QMap<int32_t, QPointF> m_touchPoints;

View file

@ -196,7 +196,7 @@ void TouchInputRedirection::cancel()
// the compositor will not receive any TOUCH_MOTION or TOUCH_UP events for that slot.
if (!m_activeTouchPoints.isEmpty()) {
m_activeTouchPoints.clear();
waylandServer()->seat()->notifyTouchCancel();
input()->processFilters(std::bind(&InputEventFilter::touchCancel, std::placeholders::_1));
}
}