|
Krita Source Code Documentation
|
Central object to manage canvas input. More...
#include <kis_input_manager.h>
Inheritance diagram for KisInputManager:Classes | |
| class | Private |
Public Member Functions | |
| void | addTrackedCanvas (KisCanvas2 *canvas) |
| void | attachPriorityEventFilter (QObject *filter, int priority=0) |
| attachPriorityEventFilter | |
| KisCanvas2 * | canvas () const |
| void | detachPriorityEventFilter (QObject *filter) |
| detachPriorityEventFilter | |
| bool | eventFilter (QObject *object, QEvent *event) override |
| KisInputManager (QObject *parent) | |
| void | registerPopupWidget (KisPopupWidgetInterface *popupWidget) |
| void | removeTrackedCanvas (KisCanvas2 *canvas) |
| void | setupAsEventFilter (QObject *receiver) |
| void | toggleTabletLogger () |
| QPointer< KisToolProxy > | toolProxy () const |
| ~KisInputManager () override | |
Private Slots | |
| void | deregisterPopupWidget () |
| void | profileChanged () |
| void | slotAboutToChangeTool () |
| void | slotCompressedMoveEvent () |
| void | slotConfigChanged () |
| void | slotTextModeChanged () |
| void | slotToolChanged () |
Private Member Functions | |
| template<class Event > | |
| bool | compressMoveEventCommon (Event *event) |
| void | endTouch () |
| bool | eventFilterImpl (QEvent *event) |
| bool | startTouch (bool &retval) |
Private Attributes | |
| Private *const | d |
Central object to manage canvas input.
The Input Manager class manages all canvas input. It is created by KisCanvas2 and processes all events related to input sent to the canvas.
The Input Manager keeps track of a set of actions and a set of shortcuts. The actions are pre-defined while the shortcuts are set from configuration.
For each event, it will try to determine if there is a shortcut that matches the input. It will then activate this action and pass all consecutive events on to this action.
Definition at line 37 of file kis_input_manager.h.
| KisInputManager::KisInputManager | ( | QObject * | parent | ) |
Constructor.
Definition at line 63 of file kis_input_manager.cpp.
References connect(), d, KoToolManager::instance(), KisConfigNotifier::instance(), KisInputManager::Private::matcher, KisInputManager::Private::moveEventCompressor, KisInputManager::Private::setupActions(), slotAboutToChangeTool(), slotCompressedMoveEvent(), slotConfigChanged(), slotTextModeChanged(), and slotToolChanged().
|
override |
Destructor.
Definition at line 87 of file kis_input_manager.cpp.
References d.
| void KisInputManager::addTrackedCanvas | ( | KisCanvas2 * | canvas | ) |
Definition at line 95 of file kis_input_manager.cpp.
References KisInputManager::Private::CanvasSwitcher::addCanvas(), canvas(), KisInputManager::Private::canvasSwitcher, and d.
| void KisInputManager::attachPriorityEventFilter | ( | QObject * | filter, |
| int | priority = 0 ) |
attachPriorityEventFilter
| filter | |
| priority |
Definition at line 143 of file kis_input_manager.cpp.
References d, kismpl::mem_equal_to(), kismpl::mem_greater(), KisInputManager::Private::priorityEventFilter, and KisInputManager::Private::priorityEventFilterSeqNo.
| KisCanvas2 * KisInputManager::canvas | ( | ) | const |
Return the canvas this input manager is associated with.
Definition at line 908 of file kis_input_manager.cpp.
References KisInputManager::Private::canvas, and d.
|
private |
We construct a copy of this event object, so we must ensure it has a correct type.
Compress the events if the tool doesn't need high resolution input
On Linux Qt eats the rest of unneeded events if we ignore the first of the chunk of tablet events. So generally we should never activate this feature. Only for testing purposes!
Definition at line 239 of file kis_input_manager.cpp.
References KisInputManager::Private::compressedMoveEvent, d, KisInputManager::Private::handleCompressedTabletEvent(), KisInputManager::Private::matcher, KisInputManager::Private::moveEventCompressor, slotCompressedMoveEvent(), KisSignalCompressor::start(), KisShortcutMatcher::supportsHiResInputEvents(), KisInputManager::Private::testingAcceptCompressedTabletEvents, and KisInputManager::Private::testingCompressBrushEvents.
|
privateslot |
Definition at line 115 of file kis_input_manager.cpp.
References d, KisPopupWidgetInterface::dismiss(), KIS_ASSERT, KisPopupWidgetInterface::onScreen(), and KisInputManager::Private::popupWidget.
| void KisInputManager::detachPriorityEventFilter | ( | QObject * | filter | ) |
detachPriorityEventFilter
| filter |
Definition at line 161 of file kis_input_manager.cpp.
References d, kismpl::mem_equal_to(), and KisInputManager::Private::priorityEventFilter.
|
private |
Definition at line 890 of file kis_input_manager.cpp.
References d, and KisInputManager::Private::touchHasBlockedPressEvents.
|
override |
Event filter method. Overridden from QObject.
If the filter removed itself from the filters list or added something there, just exit the loop
Definition at line 191 of file kis_input_manager.cpp.
References d, KisInputManager::Private::eventEater, KisInputManager::Private::EventEater::eventFilter(), eventFilterImpl(), KisInputManager::Private::eventsReceiver, KisShortcutMatcher::hasRunningShortcut(), KisInputManager::Private::matcher, KisInputManager::Private::priorityEventFilter, KisInputManager::Private::priorityEventFilterSeqNo, and KisInputManager::Private::toolProxy.
|
private |
When Krita (as an application) has no input focus, we cannot handle key events. But at the same time, when the user hovers Krita canvas, we should still show him the correct cursor.
So here we just add a simple workaround to resync shortcut matcher's state at least against the basic modifiers, like Shift, Control and Alt.
On Windows, when the user presses some global window manager shortcuts, e.g. Alt+Space (to show window title menu), events for these key presses and releases are not delivered (see bug 424319). This code is a workaround for this problem. It checks consistency of standard modifiers and resets shortcut's matcher state in case of a trouble.
Re-check the native platform key API against keys we are unsure about, and fix them in case they now show as released.
The other part of the fix is placed in the handler of ShortcutOverride, because it needs a custom set of the presset keys.
See a comment in the handler of KeyRelease event for shouldSynchronizeOnNextKeyPress explanation
There is also a case when Krita gets focus via Win+1 key, then the polled key '1' gets into the matcher, but OS does not deliver any signals for it (see bug 451424)
On some systems Qt fails to generate a correct sequence of events when the user releases a modifier key while some other key is pressed.
In such cases Qt doesn't understand that the key has changed its name in the meantime and sends incorrect key-release event for it (or an auto- repeated key-release/key-press pair).
Example (on en-US keyboard):
1) Press Shift (Key_Shift-press is delivered) 2) Press '2' (Key_At-press is delivered) 3) Release Shift (Key_Shift-release is delivered) 4) Release '2' (Key_2-release is delivered, which is unbalanced)
The same issue happens with non-latin keyboards, where Qt does auto-key-replace routines when Control modifier is pressed.
https://bugs.kde.org/show_bug.cgi?id=454256 https://bugreports.qt.io/browse/QTBUG-103868
Ignore delta 0 events on OSX, since they are triggered by tablet proximity when using Wacom devices.
We won't get a TabletProximityLeave event when the tablet is hovering above some other widget, so restore cursor events processing right now.
The flow of tablet events means the tablet is in the proximity area, so activate it even when the TabletEnterProximity event was missed (may happen when changing focus of the window with tablet in the proximity area)
Definition at line 306 of file kis_input_manager.cpp.
References KisInputManager::Private::accumulatedScrollDelta, KisInputManager::Private::allowMouseEvents(), KisShortcutMatcher::autoRepeatedKeyPressed(), KisInputManager::Private::blockMouseEvents(), KisShortcutMatcher::buttonPressed(), KisShortcutMatcher::buttonReleased(), canvas(), KisCanvas2::canvasWidget, compressMoveEventCommon(), KisInputManager::Private::containsPointer, d, KisInputManager::Private::debugEvent(), KisShortcutMatcher::debugPressedKeys(), deregisterPopupWidget(), KisConfig::disableTouchOnCanvas(), KisInputManager::Private::eatOneMousePress(), endTouch(), KisShortcutMatcher::enterEvent(), KisInputManager::Private::eventsReceiver, KisInputManager::Private::fixShortcutMatcherModifiersState(), KisShortcutMatcher::hasPolledKeys(), KisShortcutMatcher::keyPressed(), KisShortcutMatcher::keyReleased(), KIS_SAFE_ASSERT_RECOVER, KisShortcutMatcher::leaveEvent(), length(), KisShortcutMatcher::lostFocusEvent(), KisInputManager::Private::matcher, KisShortcutMatcher::nativeGestureBeginEvent(), KisShortcutMatcher::nativeGestureEndEvent(), KisShortcutMatcher::nativeGestureEvent(), KisPopupWidgetInterface::onScreen(), KisInputManager::Private::originatingTouchBeginEvent, KisInputManager::Private::popupWasActive, KisInputManager::Private::popupWidget, KisInputManager::Private::previousPos, KisInputManager::Private::processUnhandledEvent(), KisExtendedModifiersMapper::queryExtendedModifiers(), KisExtendedModifiersMapper::queryStandardModifiers(), KisShortcutMatcher::reinitializeButtons(), KisInputManager::Private::resetCompressor(), KisShortcutMatcher::sanityCheckModifiersCorrectness(), KisAbstractInputAction::setInputManager(), shouldResetWheelDelta(), KisInputManager::Private::shouldSynchronizeOnNextKeyPress, KisAlgebra2D::signPZ(), KisInputManager::Private::startBlockingTouch(), startTouch(), KisInputManager::Private::stopBlockingTouch(), KisInputManager::Private::tabletLatencyTracker, KisShortcutMatcher::touchBeginEvent(), KisShortcutMatcher::touchCancelEvent(), KisShortcutMatcher::touchEndEvent(), KisInputManager::Private::touchHasBlockedPressEvents, KisInputManager::Private::touchStrokeStarted, KisShortcutMatcher::touchUpdateEvent(), KisInputManager::Private::useUnbalancedKeyPressEventWorkaround, KisSingleActionShortcut::WheelDown, KisShortcutMatcher::wheelEvent(), KisSingleActionShortcut::WheelLeft, KisSingleActionShortcut::WheelRight, KisSingleActionShortcut::WheelTrackpad, KisSingleActionShortcut::WheelUp, and KisExtendedModifiersMapper::workaroundShiftAltMetaHell().
|
privateslot |
Definition at line 970 of file kis_input_manager.cpp.
References KisInputManager::Private::addKeyShortcut(), KisInputManager::Private::addNativeGestureShortcut(), KisInputManager::Private::addStrokeShortcut(), KisInputManager::Private::addTouchShortcut(), KisInputManager::Private::addWheelShortcut(), KisInputProfile::allShortcuts(), KisShortcutMatcher::clearShortcuts(), KisInputProfileManager::currentProfile, d, dbgInput, dbgUI, KisShortcutConfiguration::GestureType, KisInputProfileManager::instance(), KisShortcutConfiguration::KeyCombinationType, KisInputManager::Private::matcher, KisShortcutConfiguration::MouseButtonType, and KisShortcutConfiguration::MouseWheelType.
| void KisInputManager::registerPopupWidget | ( | KisPopupWidgetInterface * | popupWidget | ) |
Definition at line 105 of file kis_input_manager.cpp.
References connect(), d, deregisterPopupWidget(), KIS_ASSERT, and KisInputManager::Private::popupWidget.
| void KisInputManager::removeTrackedCanvas | ( | KisCanvas2 * | canvas | ) |
Definition at line 100 of file kis_input_manager.cpp.
References canvas(), KisInputManager::Private::canvasSwitcher, d, and KisInputManager::Private::CanvasSwitcher::removeCanvas().
| void KisInputManager::setupAsEventFilter | ( | QObject * | receiver | ) |
Installs the input manager as an event filter for receiver. Please note that KisInputManager is supposed to handle events for a single receiver only. This is defined by the fact that it resends some of the events back through the Qt's queue to the receiver. That is why the input manager will assert when it gets an event with wrong destination.
Definition at line 174 of file kis_input_manager.cpp.
References d, and KisInputManager::Private::eventsReceiver.
|
privateslot |
Definition at line 918 of file kis_input_manager.cpp.
References canvas(), KisCanvas2::canvasWidget, d, KisShortcutMatcher::lostFocusEvent(), KisInputManager::Private::matcher, and KisAbstractInputAction::setInputManager().
|
privateslot |
Definition at line 895 of file kis_input_manager.cpp.
References KisInputManager::Private::compressedMoveEvent, d, KisInputManager::Private::handleCompressedTabletEvent(), and void().
|
privateslot |
Definition at line 129 of file kis_input_manager.cpp.
References d, KisInputManager::Private::fixShortcutMatcherModifiersState(), and KisConfig::ignoreHighFunctionKeys().
|
privateslot |
Definition at line 953 of file kis_input_manager.cpp.
References KoToolManager::activeToolId(), canvas(), KisInputManager::Private::canvas, d, KisInputManager::Private::forwardAllEventsToTool, KoToolManager::instance(), KoToolBase::isInTextMode(), KisInputManager::Private::matcher, KisShortcutMatcher::suppressAllKeyboardActions, and KoToolManager::toolById().
|
privateslot |
Definition at line 930 of file kis_input_manager.cpp.
References KoToolManager::activeToolId(), canvas(), KisInputManager::Private::canvas, d, KisInputManager::Private::forwardAllEventsToTool, KoToolManager::instance(), KoToolBase::isInTextMode(), KoToolBase::maskSyntheticEvents(), KisInputManager::Private::matcher, KisAbstractInputAction::setInputManager(), KisInputManager::Private::setMaskSyntheticEvents(), KisShortcutMatcher::suppressAllKeyboardActions, KisShortcutMatcher::suppressConflictingKeyActions(), KoToolManager::toolById(), KisShortcutMatcher::toolHasBeenActivated(), and toolProxy().
|
private |
Definition at line 878 of file kis_input_manager.cpp.
References d, and KisInputManager::Private::eatOneMousePress().
| void KisInputManager::toggleTabletLogger | ( | ) |
Definition at line 138 of file kis_input_manager.cpp.
References KisTabletDebugger::instance(), and KisTabletDebugger::toggleDebugging().
| QPointer< KisToolProxy > KisInputManager::toolProxy | ( | ) | const |
The tool proxy of the current application.
Definition at line 913 of file kis_input_manager.cpp.
References d, and KisInputManager::Private::toolProxy.
|
private |
Definition at line 116 of file kis_input_manager.h.