Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix lockups in mouse actions when a touch action happens in parallel
Dmitry Kazakov2b9e39a1b143
diff --git a/libs/ui/input/kis_input_manager.cpp b/libs/ui/input/kis_input_manager.cppindex d91da96296..81fccaa4cd 100644--- a/libs/ui/input/kis_input_manager.cpp+++ b/libs/ui/input/kis_input_manager.cpp@@ -695,7 +695,9 @@ bool KisInputManager::eventFilterImpl(QEvent * event)// we don't want to lose this eventKoPointerEvent::copyQtPointerEvent(touchEvent, d->originatingTouchBeginEvent);retval = d->matcher.touchBeginEvent(touchEvent);- d->buttonPressed = false;+ KIS_SAFE_ASSERT_RECOVER(!d->touchStrokeStarted) {+ d->touchStrokeStarted = false;+ }d->resetCompressor();event->accept();}@@ -733,20 +735,16 @@ bool KisInputManager::eventFilterImpl(QEvent * event)|| qAbs(currentPos.y() - d->previousPos.y()) > 1))){d->previousPos = currentPos;- if (!d->buttonPressed)- {+ if (!d->touchStrokeStarted) {// we start it here not in TouchBegin, because Qt::TouchPointStationary doesn't work with hpdi devices.retval = d->matcher.buttonPressed(Qt::LeftButton, d->originatingTouchBeginEvent.data());- d->buttonPressed = true;- break;+ d->touchStrokeStarted = retval;+ } else {+ // if it is a full-fledged stroke, then ignore (currentPos.x - previousPos.x)+ retval = compressMoveEventCommon(touchEvent);+ d->blockMouseEvents();}-- // if it is a full-fledged stroke, then ignore (currentPos.x - previousPos.x)- d->touchStrokeStarted = true;- retval = compressMoveEventCommon(touchEvent);- d->blockMouseEvents();- }- else if (!d->touchStrokeStarted){+ } else {KisAbstractInputAction::setInputManager(this);if (d->touchHasBlockedPressEvents) {retval = compressMoveEventCommon(touchEvent);@@ -773,8 +771,6 @@ bool KisInputManager::eventFilterImpl(QEvent * event)return true;}d->debugEvent<QTouchEvent, false>(event);- endTouch();- d->allowMouseEvents();QTouchEvent *touchEvent = static_cast<QTouchEvent*>(event);retval = d->matcher.touchEndEvent(touchEvent);if (d->touchStrokeStarted) {@@ -783,6 +779,9 @@ bool KisInputManager::eventFilterImpl(QEvent * event)d->touchStrokeStarted = false; // stroke ended}+ endTouch();+ d->allowMouseEvents();+// if the event isn't handled, Qt starts to send MouseEventsif (!KisConfig(true).disableTouchOnCanvas())retval = true;diff --git a/libs/ui/input/kis_input_manager_p.h b/libs/ui/input/kis_input_manager_p.hindex a6d29e7125..4246bd0d76 100644--- a/libs/ui/input/kis_input_manager_p.h+++ b/libs/ui/input/kis_input_manager_p.h@@ -73,7 +73,6 @@ public:QPointF previousPos;QScopedPointer<QEvent> originatingTouchBeginEvent;- bool buttonPressed = false;bool useUnbalancedKeyPressEventWorkaround = false;bool shouldSynchronizeOnNextKeyPress = false;