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++
[macos] Move filtering of synthetic Wheel events to the event eater
Dmitry Kazakovdc7b4c49938e
diff --git a/libs/ui/input/kis_input_manager.cpp b/libs/ui/input/kis_input_manager.cppindex fe308df26f..0abde14c35 100644--- a/libs/ui/input/kis_input_manager.cpp+++ b/libs/ui/input/kis_input_manager.cpp@@ -492,20 +492,6 @@ bool KisInputManager::eventFilterImpl(QEvent * event)d->debugEvent<QWheelEvent>(event);QWheelEvent *wheelEvent = static_cast<QWheelEvent*>(event);-#ifdef Q_OS_MACOS- // Some QT wheel events are actually touch pad pan events. From the QT docs:- // "Wheel events are generated for both mouse wheels and trackpad scroll gestures."-- // We differentiate between touchpad events and real mouse wheels by inspecting the- // event source.-- if (wheelEvent->source() == Qt::MouseEventSource::MouseEventSynthesizedBySystem) {- KisAbstractInputAction::setInputManager(this);- retval = d->matcher.wheelEvent(KisSingleActionShortcut::WheelTrackpad, wheelEvent);- break;- }-#endif-d->accumulatedScrollDelta += wheelEvent->angleDelta().y();KisSingleActionShortcut::WheelAction action;diff --git a/libs/ui/input/kis_input_manager_p.cpp b/libs/ui/input/kis_input_manager_p.cppindex 72f5186b8e..bb45d5bc69 100644--- a/libs/ui/input/kis_input_manager_p.cpp+++ b/libs/ui/input/kis_input_manager_p.cpp@@ -244,6 +244,23 @@ bool KisInputManager::Private::EventEater::eventFilter(QObject* target, QEvent*}}+#ifdef Q_OS_MACOS+ /**+ * MacOS is the only platform where we can differentiate between+ * wheel events generated by a mouse and by a touchpad. More than+ * that, on MacOS touchpad generates NativeGesture events, hence+ * we should just blocked all the synthetic wheel events.+ */++ if (event->type() == QEvent::Wheel) {+ QWheelEvent *we = static_cast<QWheelEvent *>(event);+ if (we->source() == Qt::MouseEventSource::MouseEventSynthesizedBySystem) {+ KisInputManager::Private::debugEvent<QWheelEvent>(event, BlockedBySynthetic);+ return true;+ }+ }+#endif+const bool shouldEatMouseEvents =// On MacOS Qt sends fake mouse events instead of hover events,// so we should not block mouse events when the tablet just hovers@@ -687,9 +704,6 @@ void KisInputManager::Private::addWheelShortcut(KisAbstractInputAction* action,case KisShortcutConfiguration::WheelRight:a = KisSingleActionShortcut::WheelRight;break;- case KisShortcutConfiguration::WheelTrackpad:- a = KisSingleActionShortcut::WheelTrackpad;- break;default:return;}diff --git a/libs/ui/input/kis_shortcut_configuration.cpp b/libs/ui/input/kis_shortcut_configuration.cppindex 3c02bb88d0..2f62647bd3 100644--- a/libs/ui/input/kis_shortcut_configuration.cpp+++ b/libs/ui/input/kis_shortcut_configuration.cpp@@ -427,10 +427,6 @@ QString KisShortcutConfiguration::wheelToText(KisShortcutConfiguration::MouseWhereturn i18n("Mouse Wheel Right");break;- case KisShortcutConfiguration::WheelTrackpad:- return i18n("Trackpad Pan");- break;-default:return i18nc("No mouse wheel buttons for shortcut", "None");break;diff --git a/libs/ui/input/kis_shortcut_configuration.h b/libs/ui/input/kis_shortcut_configuration.hindex a5b01430bc..ffa228b7bb 100644--- a/libs/ui/input/kis_shortcut_configuration.h+++ b/libs/ui/input/kis_shortcut_configuration.h@@ -50,7 +50,6 @@ public:WheelDown, ///< Downwards movement, toward the user.WheelLeft, ///< Left movement.WheelRight, ///< Right movement.- WheelTrackpad, ///< A pan movement on a trackpad.};/**diff --git a/libs/ui/input/kis_single_action_shortcut.h b/libs/ui/input/kis_single_action_shortcut.hindex 8f3d177bf9..ef9399b5ee 100644--- a/libs/ui/input/kis_single_action_shortcut.h+++ b/libs/ui/input/kis_single_action_shortcut.h@@ -23,7 +23,6 @@ public:WheelDown, ///< Mouse wheel moves down.WheelLeft, ///< Mouse wheel moves left.WheelRight, ///< Mouse wheel moves right.- WheelTrackpad, ///< A pan movement on a trackpad.};KisSingleActionShortcut(KisAbstractInputAction *action, int index);