Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_input_manager_p.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Michael Abrahams <miabraha@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7
8#include <QList>
9#include <QPointer>
10#include <QEvent>
11#include <QTouchEvent>
12#include <QScopedPointer>
13#include <QQueue>
14
15#include "kis_input_manager.h"
18#include "kis_canvas2.h"
19#include "kis_tool_proxy.h"
24#include "kis_latency_tracker.h"
25
27
28
30{
31public:
33 void addStrokeShortcut(KisAbstractInputAction* action, int index, const QList< Qt::Key >& modifiers, Qt::MouseButtons buttons);
34 void addKeyShortcut(KisAbstractInputAction* action, int index,const QList<Qt::Key> &keys);
38 bool processUnhandledEvent(QEvent *event);
39 void setupActions();
40 bool handleCompressedTabletEvent(QEvent *event);
42 void fixShortcutMatcherModifiersState(QVector<Qt::Key> newKeys, Qt::KeyboardModifiers modifiers);
43
45
48
51
53
55
57
58 QObject *eventsReceiver = 0;
60 QScopedPointer<QEvent> compressedMoveEvent;
63
64 typedef QPair<int, QPointer<QObject> > PriorityPair;
68
69 bool touchStrokeStarted = false;
70 bool popupWasActive = false;
71
72 QPointF previousPos;
73 QScopedPointer<QEvent> originatingTouchBeginEvent;
74
77
79
80 void blockMouseEvents();
81 void allowMouseEvents();
82 void eatOneMousePress();
84 void resetCompressor();
85 void startBlockingTouch();
86 void stopBlockingTouch();
87
88 template <class Event, bool useBlocking>
89 void debugEvent(QEvent *event)
90 {
92
93 QString msg1 = useBlocking && ignoringQtCursorEvents() ? "[BLOCKED] " : "[ ]";
94 Event *specificEvent = static_cast<Event*>(event);
95 dbgTablet << KisTabletDebugger::instance()->eventToString(*specificEvent, msg1);
96 }
97
98 class ProximityNotifier : public QObject
99 {
100 public:
101 ProximityNotifier(Private *_d, QObject *p);
102 bool eventFilter(QObject* object, QEvent* event ) override;
103 private:
105 };
106
107 class CanvasSwitcher : public QObject
108 {
109 public:
110 CanvasSwitcher(Private *_d, QObject *p);
113 bool eventFilter(QObject* object, QEvent* event ) override;
114
115 private:
116 void setupFocusThreshold(QObject *object);
117
118 private:
120 QMap<QObject*, QPointer<KisCanvas2>> canvasResolver;
124 };
126
128 {
129 EventEater();
130
131 bool eventFilter(QObject* target, QEvent* event);
132
133 // This should be called after we're certain a tablet stroke has started.
134 void activate();
135 // This should be called after a tablet stroke has ended.
136 void deactivate();
137
138 // On Windows, we sometimes receive mouse events very late, so watch & wait.
139 void eatOneMousePress();
140
141 // This should be called after the tablet is pressed,
142 void startBlockingTouch();
143 // This should be called after the tablet is released.
144 void stopBlockingTouch();
145
146 bool hungry{false}; // Continue eating mouse strokes
147 bool peckish{false}; // Eat a single mouse press event
148 bool eatSyntheticEvents{false}; // Mask all synthetic events
149 bool activateSecondaryButtonsWorkaround{false}; // Use mouse events for right- and middle-clicks
150 bool eatTouchEvents{false}; // Eat touch interactions
151 };
153
154 bool containsPointer = false;
155
157
159 protected:
160 virtual qint64 currentTimestamp() const override;
161 virtual void print(const QString &message) override;
162 };
163
165#ifdef Q_OS_WIN
166 bool ignoreHighFunctionKeys = false;
167#endif
168};
float value(const T *src, size_t ch)
const Params2D p
KisMagneticGraph::vertex_descriptor target(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
static bool debugEnabled()
Linethickness.
Abstract base class for input actions.
QMap< QObject *, QPointer< KisCanvas2 > > canvasResolver
KisSignalAutoConnectionsStore thresholdConnections
bool eventFilter(QObject *object, QEvent *event) override
bool eventFilter(QObject *object, QEvent *event) override
virtual void print(const QString &message) override
void debugEvent(QEvent *event)
void setMaskSyntheticEvents(bool value)
bool addNativeGestureShortcut(KisAbstractInputAction *action, int index, KisShortcutConfiguration::GestureAction gesture)
bool handleCompressedTabletEvent(QEvent *event)
void addKeyShortcut(KisAbstractInputAction *action, int index, const QList< Qt::Key > &keys)
void addWheelShortcut(KisAbstractInputAction *action, int index, const QList< Qt::Key > &modifiers, KisShortcutConfiguration::MouseWheelMovement wheelAction)
QPair< int, QPointer< QObject > > PriorityPair
KisToolInvocationAction * defaultInputAction
QScopedPointer< QEvent > originatingTouchBeginEvent
QPointer< KisToolProxy > toolProxy
KisSignalCompressor moveEventCompressor
void addStrokeShortcut(KisAbstractInputAction *action, int index, const QList< Qt::Key > &modifiers, Qt::MouseButtons buttons)
QList< PriorityPair > PriorityList
QScopedPointer< QEvent > compressedMoveEvent
QPointer< KisCanvas2 > canvas
bool processUnhandledEvent(QEvent *event)
KisSharedPtr< TabletLatencyTracker > tabletLatencyTracker
void addTouchShortcut(KisAbstractInputAction *action, int index, KisShortcutConfiguration::GestureAction gesture)
KisPopupWidgetInterface * popupWidget
Central object to manage canvas input.
The PopupWidgetInterface abstract class defines the basic interface that will be used by all popup wi...
QString eventToString(const QMouseEvent &ev, const QString &prefix)
static KisTabletDebugger * instance()
Tool Invocation action of KisAbstractInputAction.
#define dbgTablet
Definition kis_debug.h:59
QString buttons(const T &ev)
bool eventFilter(QObject *target, QEvent *event)