Krita Source Code Documentation
Loading...
Searching...
No Matches
KisInputManager::Private Class Reference

#include <kis_input_manager_p.h>

Classes

class  CanvasSwitcher
 
class  ProximityNotifier
 
class  TabletLatencyTracker
 

Public Types

typedef QList< PriorityPair > PriorityList
 
typedef QPair< int, QPointer< QObject > > PriorityPair
 

Public Member Functions

void addKeyShortcut (KisAbstractInputAction *action, int index, const QList< Qt::Key > &keys)
 
bool addNativeGestureShortcut (KisAbstractInputAction *action, int index, KisShortcutConfiguration::NativeGestureAction gesture)
 
void addStrokeShortcut (KisAbstractInputAction *action, int index, const QList< Qt::Key > &modifiers, Qt::MouseButtons buttons)
 
void addTouchShortcut (KisAbstractInputAction *action, int index, KisShortcutConfiguration::TouchGestureAction gesture, bool isTouchPainting=false)
 
void addWheelShortcut (KisAbstractInputAction *action, int index, const QList< Qt::Key > &modifiers, KisShortcutConfiguration::MouseWheelMovement wheelAction)
 
void fixShortcutMatcherModifiersState ()
 
void fixShortcutMatcherModifiersState (QVector< Qt::Key > newKeys, Qt::KeyboardModifiers modifiers)
 
bool handleCompressedTabletEvent (QEvent *event)
 
 Private (KisInputManager *qq, KoToolManager *toolManagerArg)
 
bool processUnhandledEvent (QEvent *event)
 
void resetCompressor ()
 
void setMaskSyntheticEvents (bool value)
 
void setupActions ()
 

Public Attributes

QPoint accumulatedScrollDelta
 
QPointer< KisCanvas2 > canvas
 
CanvasSwitcher canvasSwitcher
 
QScopedPointer< QEvent > compressedMoveEvent
 
KisToolInvocationAction * defaultInputAction = 0
 
KisInputEventsEater eventEater
 
QObject * eventsReceiver = 0
 
bool forwardAllEventsToTool = false
 
KisShortcutMatcher matcher
 
KisSignalCompressor moveEventCompressor
 
bool popupWasActive = false
 
KisPopupWidgetInterface * popupWidget
 
PriorityList priorityEventFilter
 
int priorityEventFilterSeqNo
 
KisInputManager * q
 
bool shouldSynchronizeOnNextKeyPress = false
 
KisSharedPtr< TabletLatencyTracker > tabletLatencyTracker
 
bool testingAcceptCompressedTabletEvents = false
 
bool testingCompressBrushEvents = false
 
QPointer< KoToolManager > toolManager
 
QPointer< KisToolProxy > toolProxy
 
bool useUnbalancedKeyPressEventWorkaround = false
 

Detailed Description

Definition at line 28 of file kis_input_manager_p.h.

Member Typedef Documentation

◆ PriorityList

◆ PriorityPair

typedef QPair<int, QPointer<QObject> > KisInputManager::Private::PriorityPair

Definition at line 61 of file kis_input_manager_p.h.

Constructor & Destructor Documentation

◆ Private()

KisInputManager::Private::Private ( KisInputManager * qq,
KoToolManager * toolManagerArg )

On Windows and Linux we have a proper fix for this bug patched into our local version of Qt. We don't have a fix for macOS

In Linux distributions Qt is not patched, so we should use workaround for them

Definition at line 38 of file kis_input_manager_p.cpp.

39 : q(qq)
40 , toolManager(toolManagerArg)
41 , moveEventCompressor(10 /* ms */,
45 , popupWidget(nullptr)
46 , canvasSwitcher(this, qq)
47{
48 KisConfig cfg(true);
49
50 moveEventCompressor.setDelay(cfg.tabletEventsDelay());
51 testingAcceptCompressedTabletEvents = cfg.testingAcceptCompressedTabletEvents();
52 testingCompressBrushEvents = cfg.testingCompressBrushEvents();
53
54 if (cfg.trackTabletEventLatency()) {
55 tabletLatencyTracker = new TabletLatencyTracker();
56 }
57
59 [this] () {
60 return this->canvas ? this->canvas->inputActionGroupsMaskInterface()->inputActionGroupsMask() : AllActionGroup;
61 });
62
63#ifdef Q_OS_ANDROID
64 // a workaround for Xiaomi tablets
66#endif
67
73#ifdef Q_OS_MACOS
75#endif
76
81#if defined Q_OS_LINUX && !KRITA_QT_HAS_UNBALANCED_KEY_PRESS_RELEASE_PATCH
83#endif
84
85 if (qEnvironmentVariableIsSet("KRITA_FIX_UNBALANCED_KEY_EVENTS")) {
86 useUnbalancedKeyPressEventWorkaround = qEnvironmentVariableIntValue("KRITA_FIX_UNBALANCED_KEY_EVENTS");
87 }
88}
@ AllActionGroup
KisSignalCompressor moveEventCompressor
QPointer< KoToolManager > toolManager
QPointer< KisCanvas2 > canvas
KisSharedPtr< TabletLatencyTracker > tabletLatencyTracker
KisPopupWidgetInterface * popupWidget
void setInputActionGroupsMaskCallback(std::function< KisInputActionGroupsMask()> func)
void setIgnoreMultiFingerCancelWorkaroundEnalbed(bool value)
void setDelay(std::function< bool()> idleCallback, int idleDelay, int timeout)

References AllActionGroup, canvas, matcher, moveEventCompressor, KisSignalCompressor::setDelay(), KisShortcutMatcher::setIgnoreMultiFingerCancelWorkaroundEnalbed(), KisShortcutMatcher::setInputActionGroupsMaskCallback(), KisConfig::tabletEventsDelay(), tabletLatencyTracker, testingAcceptCompressedTabletEvents, KisConfig::testingAcceptCompressedTabletEvents(), testingCompressBrushEvents, KisConfig::testingCompressBrushEvents(), KisConfig::trackTabletEventLatency(), and useUnbalancedKeyPressEventWorkaround.

Member Function Documentation

◆ addKeyShortcut()

void KisInputManager::Private::addKeyShortcut ( KisAbstractInputAction * action,
int index,
const QList< Qt::Key > & keys )

Definition at line 340 of file kis_input_manager_p.cpp.

342{
343 if (keys.size() == 0) return;
344
345 KisSingleActionShortcut *keyShortcut =
346 new KisSingleActionShortcut(action, index);
347
348 //Note: Ordering is important here, Shift + V is different from V + Shift,
349 //which is the reason we use the last key here since most users will enter
350 //shortcuts as "Shift + V". Ideally this should not happen, but this is
351 //the way the shortcut matcher is currently implemented.
352 QList<Qt::Key> allKeys = keys;
353 Qt::Key key = allKeys.takeLast();
354 QSet<Qt::Key> modifiers = QSet<Qt::Key>(allKeys.begin(), allKeys.end());
355 keyShortcut->setKey(modifiers, key);
356 matcher.addShortcut(keyShortcut);
357}
void addShortcut(KisSingleActionShortcut *shortcut)
void setKey(const QSet< Qt::Key > &modifiers, Qt::Key key)

References KisShortcutMatcher::addShortcut(), matcher, and KisSingleActionShortcut::setKey().

◆ addNativeGestureShortcut()

bool KisInputManager::Private::addNativeGestureShortcut ( KisAbstractInputAction * action,
int index,
KisShortcutConfiguration::NativeGestureAction gesture )

Definition at line 431 of file kis_input_manager_p.cpp.

432{
433 auto addNativeGesture = [&] (KisNativeGestureShortcut::Type type) {
434 KisNativeGestureShortcut *shortcut = new KisNativeGestureShortcut(action, index, type);
435 matcher.addShortcut(shortcut);
436 };
437
438 // Native gestures:
439 // Qt5 only implements QNativeGestureEvent for macOS
440 // Qt6 implements QNativeGestureEvent for macOS and Wayland
441 //
442 // Touchpad pixel scrolling:
443 // Qt5 only implements touchpad pixel scrolling for macOS
444 // Qt6 implements touchpad pixel scrolling for macOS and Wayland
445
446 switch (gesture) {
449 break;
452 break;
455 break;
456 default:
457 return false;
458 }
459
460 return true;
461}
@ TouchpadScroll
Two-dimensional pixel scrolling on a touchpad, supported on MacOS and Wayland only.
@ SmartZoomGesture
Smart zoom gesture, typically a double tap that is a boolean zoom/unzoom.
@ PinchGesture
Pinch gesture, a two finger gesture used for navigating the canvas.

References KisShortcutMatcher::addShortcut(), matcher, KisShortcutConfiguration::PinchGesture, KisNativeGestureShortcut::PinchNavigation, KisShortcutConfiguration::SmartZoomGesture, KisNativeGestureShortcut::SmartZoomNativeGesture, and KisShortcutConfiguration::TouchpadScroll.

◆ addStrokeShortcut()

void KisInputManager::Private::addStrokeShortcut ( KisAbstractInputAction * action,
int index,
const QList< Qt::Key > & modifiers,
Qt::MouseButtons buttons )

Definition at line 311 of file kis_input_manager_p.cpp.

314{
315 KisStrokeShortcut *strokeShortcut =
316 new KisStrokeShortcut(action, index);
317
318 QSet<Qt::MouseButton> buttonSet;
319 if(buttons & Qt::LeftButton) {
320 buttonSet << Qt::LeftButton;
321 }
322 if(buttons & Qt::RightButton) {
323 buttonSet << Qt::RightButton;
324 }
325 if(buttons & Qt::MiddleButton) {
326 buttonSet << Qt::MiddleButton;
327 }
328
329BOOST_PP_REPEAT_FROM_TO(1, 25, EXTRA_BUTTON, _)
330
331 if (!buttonSet.empty()) {
332 strokeShortcut->setButtons(QSet<Qt::Key>(modifiers.cbegin(), modifiers.cend()), buttonSet);
333 matcher.addShortcut(strokeShortcut);
334 }
335 else {
336 delete strokeShortcut;
337 }
338}
void setButtons(const QSet< Qt::Key > &modifiers, const QSet< Qt::MouseButton > &buttons)
#define EXTRA_BUTTON(z, n, _)
QString buttons(const T &ev)

References KisShortcutMatcher::addShortcut(), buttons(), EXTRA_BUTTON, matcher, and KisStrokeShortcut::setButtons().

◆ addTouchShortcut()

void KisInputManager::Private::addTouchShortcut ( KisAbstractInputAction * action,
int index,
KisShortcutConfiguration::TouchGestureAction gesture,
bool isTouchPainting = false )

Definition at line 391 of file kis_input_manager_p.cpp.

392{
393 KisTouchShortcut *shortcut = new KisTouchShortcut(action, index, gesture);
394 if (isTouchPainting) {
395 shortcut->setIsTouchPainting(true);
396 shortcut->setMinDragThreshold(1.5); // min threshold for touch painting is 1.5 px
397 }
398 dbgKrita << "TouchAction:" << action->name() << (isTouchPainting ? "touch-painting" : "");
399 switch(gesture) {
403 shortcut->setMinimumTouchPoints(1);
404 shortcut->setMaximumTouchPoints(1);
405 break;
408 shortcut->setMinimumTouchPoints(2);
409 shortcut->setMaximumTouchPoints(2);
410 break;
413 shortcut->setMinimumTouchPoints(3);
414 shortcut->setMaximumTouchPoints(3);
415 break;
418 shortcut->setMinimumTouchPoints(4);
419 shortcut->setMaximumTouchPoints(4);
420 break;
423 shortcut->setMinimumTouchPoints(5);
424 shortcut->setMaximumTouchPoints(5);
425 default:
426 break;
427 }
428 matcher.addShortcut(shortcut);
429}
The KisTouchShortcut class only handles touch gestures it does not handle tool invocation i....
void setIsTouchPainting(bool value)
void setMinDragThreshold(qreal value)
void setMaximumTouchPoints(int max)
void setMinimumTouchPoints(int min)
#define dbgKrita
Definition kis_debug.h:49

References KisShortcutMatcher::addShortcut(), dbgKrita, KisShortcutConfiguration::FiveFingerDrag, KisShortcutConfiguration::FiveFingerTap, KisShortcutConfiguration::FourFingerDrag, KisShortcutConfiguration::FourFingerTap, matcher, KisAbstractInputAction::name, KisShortcutConfiguration::OneFingerDrag, KisShortcutConfiguration::OneFingerHold, KisShortcutConfiguration::OneFingerTap, KisTouchShortcut::setIsTouchPainting(), KisTouchShortcut::setMaximumTouchPoints(), KisTouchShortcut::setMinDragThreshold(), KisTouchShortcut::setMinimumTouchPoints(), KisShortcutConfiguration::ThreeFingerDrag, KisShortcutConfiguration::ThreeFingerTap, KisShortcutConfiguration::TwoFingerDrag, and KisShortcutConfiguration::TwoFingerTap.

◆ addWheelShortcut()

void KisInputManager::Private::addWheelShortcut ( KisAbstractInputAction * action,
int index,
const QList< Qt::Key > & modifiers,
KisShortcutConfiguration::MouseWheelMovement wheelAction )

Definition at line 359 of file kis_input_manager_p.cpp.

362{
363
364
365 auto addSingleActionShortcut = [&] (KisSingleActionShortcut::WheelAction a) {
366 std::unique_ptr<KisSingleActionShortcut> keyShortcut(
367 new KisSingleActionShortcut(action, index));
368 keyShortcut->setWheel(QSet<Qt::Key>(modifiers.begin(), modifiers.end()), a);
369 matcher.addShortcut(keyShortcut.release());
370 };
371
372 switch(wheelAction) {
374 addSingleActionShortcut(KisSingleActionShortcut::WheelUp);
375 break;
377 addSingleActionShortcut(KisSingleActionShortcut::WheelDown);
378 break;
380 addSingleActionShortcut(KisSingleActionShortcut::WheelLeft);
381 break;
383 addSingleActionShortcut(KisSingleActionShortcut::WheelRight);
384 break;
387 break;
388 }
389}
@ WheelDown
Downwards movement, toward the user.
@ WheelUp
Upwards movement, away from the user.
@ WheelReserved_0
Do not use! Previously was used for TouchpadScroll shortcut.
@ WheelDown
Mouse wheel moves down.
@ WheelRight
Mouse wheel moves right.
@ WheelLeft
Mouse wheel moves left.

References KisShortcutMatcher::addShortcut(), matcher, KisShortcutConfiguration::NoMovement, KisShortcutConfiguration::WheelDown, KisSingleActionShortcut::WheelDown, KisShortcutConfiguration::WheelLeft, KisSingleActionShortcut::WheelLeft, KisShortcutConfiguration::WheelReserved_0, KisShortcutConfiguration::WheelRight, KisSingleActionShortcut::WheelRight, KisShortcutConfiguration::WheelUp, and KisSingleActionShortcut::WheelUp.

◆ fixShortcutMatcherModifiersState() [1/2]

void KisInputManager::Private::fixShortcutMatcherModifiersState ( )

Definition at line 514 of file kis_input_manager_p.cpp.

515{
517
518 QVector<Qt::Key> newKeys;
519 Qt::KeyboardModifiers modifiers = mapper.queryStandardModifiers();
520 Q_FOREACH (Qt::Key key, mapper.queryExtendedModifiers()) {
521 QKeyEvent kevent(QEvent::ShortcutOverride, key, modifiers);
523 }
524
525 fixShortcutMatcherModifiersState(newKeys, modifiers);
526}
static Qt::Key workaroundShiftAltMetaHell(const QKeyEvent *keyEvent)

References fixShortcutMatcherModifiersState(), KisExtendedModifiersMapper::queryExtendedModifiers(), KisExtendedModifiersMapper::queryStandardModifiers(), and KisExtendedModifiersMapper::workaroundShiftAltMetaHell().

◆ fixShortcutMatcherModifiersState() [2/2]

void KisInputManager::Private::fixShortcutMatcherModifiersState ( QVector< Qt::Key > newKeys,
Qt::KeyboardModifiers modifiers )

This function may be called from slotConfigChanged() from the constructor of KisInputManager. It may theoretically happen that we haven't recieved any sensible events to set up the link to the input manager.

Definition at line 528 of file kis_input_manager_p.cpp.

529{
531
532 matcher.handlePolledKeys(newKeys);
533
534 for (auto it = danglingKeys.begin(); it != danglingKeys.end();) {
535 if (newKeys.contains(*it)) {
536 newKeys.removeOne(*it);
537 it = danglingKeys.erase(it);
538 } else {
539 ++it;
540 }
541 }
542
550
551 Q_FOREACH (Qt::Key key, danglingKeys) {
552 QKeyEvent kevent(QEvent::KeyRelease, key, modifiers);
553 processUnhandledEvent(&kevent);
554 }
555
556 Q_FOREACH (Qt::Key key, newKeys) {
557 // just replay the whole sequence
558 {
559 QKeyEvent kevent(QEvent::ShortcutOverride, key, modifiers);
560 processUnhandledEvent(&kevent);
561 }
562 {
563 QKeyEvent kevent(QEvent::KeyPress, key, modifiers);
564 processUnhandledEvent(&kevent);
565 }
566 }
567}
static void setInputManager(KisInputManager *manager)
bool processUnhandledEvent(QEvent *event)
QVector< Qt::Key > debugPressedKeys() const
void handlePolledKeys(const QVector< Qt::Key > &keys)

References KisShortcutMatcher::debugPressedKeys(), KisShortcutMatcher::handlePolledKeys(), matcher, processUnhandledEvent(), q, and KisAbstractInputAction::setInputManager().

◆ handleCompressedTabletEvent()

bool KisInputManager::Private::handleCompressedTabletEvent ( QEvent * event)

Definition at line 501 of file kis_input_manager_p.cpp.

502{
503 bool retval = false;
504
505 if (!matcher.pointerMoved(event) && toolProxy) {
506 toolProxy->forwardHoverEvent(event);
507 }
508 retval = true;
509 event->setAccepted(true);
510
511 return retval;
512}
QPointer< KisToolProxy > toolProxy
bool pointerMoved(QEvent *event)

References matcher, KisShortcutMatcher::pointerMoved(), and toolProxy.

◆ processUnhandledEvent()

bool KisInputManager::Private::processUnhandledEvent ( QEvent * event)

Definition at line 481 of file kis_input_manager_p.cpp.

482{
483 bool retval = false;
484
486 event->type() == QEvent::KeyPress ||
487 event->type() == QEvent::KeyRelease) {
488
490 retval = true;
491 }
492
493 return retval && !forwardAllEventsToTool;
494}
KisToolInvocationAction * defaultInputAction

References defaultInputAction, forwardAllEventsToTool, and KisToolInvocationAction::processUnhandledEvent().

◆ resetCompressor()

void KisInputManager::Private::resetCompressor ( )

◆ setMaskSyntheticEvents()

void KisInputManager::Private::setMaskSyntheticEvents ( bool value)

Definition at line 32 of file kis_input_manager_p.cpp.

33{
34 Q_UNUSED(value)
35 // TODO: remove
36}
float value(const T *src, size_t ch)

References value().

◆ setupActions()

void KisInputManager::Private::setupActions ( )

Definition at line 463 of file kis_input_manager_p.cpp.

464{
466 Q_FOREACH (KisAbstractInputAction *action, actions) {
467 KisToolInvocationAction *toolAction =
468 dynamic_cast<KisToolInvocationAction*>(action);
469
470 if(toolAction) {
471 defaultInputAction = toolAction;
472 }
473 }
474
475 connect(KisInputProfileManager::instance(), SIGNAL(currentProfileChanged()), q, SLOT(profileChanged()));
476 if(KisInputProfileManager::instance()->currentProfile()) {
477 q->profileChanged();
478 }
479}
Abstract base class for input actions.
QList< KisAbstractInputAction * > actions
static KisInputProfileManager * instance()
Tool Invocation action of KisAbstractInputAction.

References KisInputProfileManager::actions, defaultInputAction, KisInputProfileManager::instance(), KisInputManager::profileChanged(), and q.

Member Data Documentation

◆ accumulatedScrollDelta

QPoint KisInputManager::Private::accumulatedScrollDelta

Definition at line 107 of file kis_input_manager_p.h.

◆ canvas

QPointer<KisCanvas2> KisInputManager::Private::canvas

Definition at line 45 of file kis_input_manager_p.h.

◆ canvasSwitcher

CanvasSwitcher KisInputManager::Private::canvasSwitcher

Definition at line 103 of file kis_input_manager_p.h.

◆ compressedMoveEvent

QScopedPointer<QEvent> KisInputManager::Private::compressedMoveEvent

Definition at line 57 of file kis_input_manager_p.h.

◆ defaultInputAction

KisToolInvocationAction* KisInputManager::Private::defaultInputAction = 0

Definition at line 53 of file kis_input_manager_p.h.

◆ eventEater

KisInputEventsEater KisInputManager::Private::eventEater

Definition at line 105 of file kis_input_manager_p.h.

◆ eventsReceiver

QObject* KisInputManager::Private::eventsReceiver = 0

Definition at line 55 of file kis_input_manager_p.h.

◆ forwardAllEventsToTool

bool KisInputManager::Private::forwardAllEventsToTool = false

Definition at line 49 of file kis_input_manager_p.h.

◆ matcher

KisShortcutMatcher KisInputManager::Private::matcher

Definition at line 51 of file kis_input_manager_p.h.

◆ moveEventCompressor

KisSignalCompressor KisInputManager::Private::moveEventCompressor

Definition at line 56 of file kis_input_manager_p.h.

◆ popupWasActive

bool KisInputManager::Private::popupWasActive = false

Definition at line 66 of file kis_input_manager_p.h.

◆ popupWidget

KisPopupWidgetInterface* KisInputManager::Private::popupWidget

Definition at line 71 of file kis_input_manager_p.h.

◆ priorityEventFilter

PriorityList KisInputManager::Private::priorityEventFilter

Definition at line 63 of file kis_input_manager_p.h.

◆ priorityEventFilterSeqNo

int KisInputManager::Private::priorityEventFilterSeqNo

Definition at line 64 of file kis_input_manager_p.h.

◆ q

KisInputManager* KisInputManager::Private::q

Definition at line 43 of file kis_input_manager_p.h.

◆ shouldSynchronizeOnNextKeyPress

bool KisInputManager::Private::shouldSynchronizeOnNextKeyPress = false

Definition at line 69 of file kis_input_manager_p.h.

◆ tabletLatencyTracker

KisSharedPtr<TabletLatencyTracker> KisInputManager::Private::tabletLatencyTracker

Definition at line 115 of file kis_input_manager_p.h.

◆ testingAcceptCompressedTabletEvents

bool KisInputManager::Private::testingAcceptCompressedTabletEvents = false

Definition at line 58 of file kis_input_manager_p.h.

◆ testingCompressBrushEvents

bool KisInputManager::Private::testingCompressBrushEvents = false

Definition at line 59 of file kis_input_manager_p.h.

◆ toolManager

QPointer<KoToolManager> KisInputManager::Private::toolManager

Definition at line 46 of file kis_input_manager_p.h.

◆ toolProxy

QPointer<KisToolProxy> KisInputManager::Private::toolProxy

Definition at line 47 of file kis_input_manager_p.h.

◆ useUnbalancedKeyPressEventWorkaround

bool KisInputManager::Private::useUnbalancedKeyPressEventWorkaround = false

Definition at line 68 of file kis_input_manager_p.h.


The documentation for this class was generated from the following files: