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:
32 static constexpr int TOUCH_HOLD_DELAY_MS = 400;
33
35 void addStrokeShortcut(KisAbstractInputAction* action, int index, const QList< Qt::Key >& modifiers, Qt::MouseButtons buttons);
36 void addKeyShortcut(KisAbstractInputAction* action, int index,const QList<Qt::Key> &keys);
40 bool processUnhandledEvent(QEvent *event);
41 void setupActions();
42 bool handleCompressedTabletEvent(QEvent *event);
44 void fixShortcutMatcherModifiersState(QVector<Qt::Key> newKeys, Qt::KeyboardModifiers modifiers);
45
47
50
53
55
57
59
60 QObject *eventsReceiver = 0;
62 QScopedPointer<QEvent> compressedMoveEvent;
65
66 typedef QPair<int, QPointer<QObject> > PriorityPair;
70
71 bool touchStrokeStarted = false;
72 bool touchStrokeBlocked = false;
73 bool popupWasActive = false;
75
76 QPointF startingPos;
77 QPointF previousPos;
78 QScopedPointer<QEvent> originatingTouchBeginEvent;
79
82
84
87
88 void blockMouseEvents();
89 void allowMouseEvents();
90 void eatOneMousePress();
92 void resetCompressor();
93 void startBlockingTouch();
94 void stopBlockingTouch();
97 bool isPendingTouchHold() const;
98 bool isWithinTouchHoldSlopRange(const QPointF &currentPos) const;
99 void bufferTouchEvent(QTouchEvent *event);
102
103 template <class Event, bool useBlocking>
104 void debugEvent(QEvent *event)
105 {
107
108 QString msg1 = useBlocking && ignoringQtCursorEvents() ? "[BLOCKED] " : "[ ]";
109 Event *specificEvent = static_cast<Event*>(event);
110 dbgTablet << KisTabletDebugger::instance()->eventToString(*specificEvent, msg1);
111 }
112
113 class ProximityNotifier : public QObject
114 {
115 public:
116 ProximityNotifier(Private *_d, QObject *p);
117 bool eventFilter(QObject* object, QEvent* event ) override;
118 private:
120 };
121
122 class CanvasSwitcher : public QObject
123 {
124 public:
125 CanvasSwitcher(Private *_d, QObject *p);
128 bool eventFilter(QObject* object, QEvent* event ) override;
129
130 private:
131 void setupFocusThreshold(QObject *object);
132
133 private:
135 QMap<QObject*, QPointer<KisCanvas2>> canvasResolver;
139 };
141
143 {
144 EventEater();
145
146 bool eventFilter(QObject* target, QEvent* event);
147
148 // This should be called after we're certain a tablet stroke has started.
149 void activate();
150 // This should be called after a tablet stroke has ended.
151 void deactivate();
152
153 // On Windows, we sometimes receive mouse events very late, so watch & wait.
154 void eatOneMousePress();
155
156 // This should be called after the tablet is pressed,
157 void startBlockingTouch();
158 // This should be called after the tablet is released.
159 void stopBlockingTouch();
160
161 bool hungry{false}; // Continue eating mouse strokes
162 bool peckish{false}; // Eat a single mouse press event
163 bool eatSyntheticEvents{false}; // Mask all synthetic events
164 bool activateSecondaryButtonsWorkaround{false}; // Use mouse events for right- and middle-clicks
165 bool eatTouchEvents{false}; // Eat touch interactions
166 };
168
169 bool containsPointer = false;
170
172
174 protected:
175 virtual qint64 currentTimestamp() const override;
176 virtual void print(const QString &message) override;
177 };
178
180#ifdef Q_OS_WIN
181 bool ignoreHighFunctionKeys = false;
182#endif
183};
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)
static constexpr int TOUCH_HOLD_DELAY_MS
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
QVector< QTouchEvent * > bufferedTouchEvents
QScopedPointer< QEvent > originatingTouchBeginEvent
bool isWithinTouchHoldSlopRange(const QPointF &currentPos) const
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
void bufferTouchEvent(QTouchEvent *event)
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)