Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_input_manager_p.cpp File Reference
#include "kis_input_manager_p.h"
#include <QMap>
#include <QApplication>
#include <QScopedPointer>
#include <QTimer>
#include <QtGlobal>
#include <boost/preprocessor/repeat_from_to.hpp>
#include "kis_input_manager.h"
#include "kis_config.h"
#include "kis_abstract_input_action.h"
#include "kis_tool_invocation_action.h"
#include "kis_stroke_shortcut.h"
#include "kis_touch_shortcut.h"
#include "kis_native_gesture_shortcut.h"
#include "kis_input_profile_manager.h"
#include "kis_extended_modifiers_mapper.h"
#include "kis_zoom_and_rotate_action.h"
#include "kis_popup_palette.h"
#include "config-qt-patches-present.h"

Go to the source code of this file.

Macros

#define EXTRA_BUTTON(z, n, _)
 

Functions

bool isInputWidget (QWidget *w)
 
static bool isMouseEventType (QEvent::Type t)
 

Variables

static const int InputWidgetsThreshold = 2000
 
static const int OtherWidgetsThreshold = 400
 

Macro Definition Documentation

◆ EXTRA_BUTTON

#define EXTRA_BUTTON ( z,
n,
_ )
Value:
if(buttons & Qt::ExtraButton##n) { \
buttonSet << Qt::ExtraButton##n; \
}
QString buttons(const T &ev)

Definition at line 475 of file kis_input_manager_p.cpp.

475#define EXTRA_BUTTON(z, n, _) \
476 if(buttons & Qt::ExtraButton##n) { \
477 buttonSet << Qt::ExtraButton##n; \
478 }

Function Documentation

◆ isInputWidget()

bool isInputWidget ( QWidget * w)

Definition at line 314 of file kis_input_manager_p.cpp.

315{
316 if (!w) return false;
317
318
320 types << QLatin1String("QAbstractSlider");
321 types << QLatin1String("QAbstractSpinBox");
322 types << QLatin1String("QLineEdit");
323 types << QLatin1String("QTextEdit");
324 types << QLatin1String("QPlainTextEdit");
325 types << QLatin1String("QComboBox");
326 types << QLatin1String("QKeySequenceEdit");
327
328 Q_FOREACH (const QLatin1String &type, types) {
329 if (w->inherits(type.data())) {
330 return true;
331 }
332 }
333
334 return false;
335}

◆ isMouseEventType()

static bool isMouseEventType ( QEvent::Type t)
static

This hungry class EventEater encapsulates event masking logic.

Its basic role is to kill synthetic mouseMove events sent by Xorg or Qt after tablet events. Those events are sent in order to allow widgets that haven't implemented tablet specific functionality to seamlessly behave as if one were using a mouse. These synthetic events are supposed to be optional, or at least come with a flag saying "This is a fake event!!" but neither of those methods is trustworthy. (This is correct as of Qt 5.4 + Xorg.)

Qt 5.4 provides no reliable way to see if a user's tablet is being hovered over the pad, since it converts all tablethover events into mousemove, with no option to turn this off. Moreover, sometimes the MouseButtonPress event from the tapping their tablet happens BEFORE the TabletPress event. This means we have to resort to a somewhat complicated logic. What makes this truly a joke is that we are not guaranteed to observe TabletProximityEnter events when we're using a tablet, either, you may only see an Enter event.

Once we see tablet events heading our way, we can say pretty confidently that every mouse event is fake. There are two painful cases to consider - a mousePress event could arrive before the tabletPress event, or it could arrive much later, e.g. after tabletRelease. The first was only seen on Linux with Qt's XInput2 code, the solution was to hold onto mousePress events temporarily and wait for tabletPress later, this is contained in git history but is now removed. The second case is currently handled by the eatOneMousePress function, which waits as long as necessary to detect and block a single mouse press event.

Definition at line 61 of file kis_input_manager_p.cpp.

62{
63 return (t == QEvent::MouseMove ||
64 t == QEvent::MouseButtonPress ||
65 t == QEvent::MouseButtonRelease ||
66 t == QEvent::MouseButtonDblClick);
67}

Variable Documentation

◆ InputWidgetsThreshold

const int InputWidgetsThreshold = 2000
static

Definition at line 250 of file kis_input_manager_p.cpp.

◆ OtherWidgetsThreshold

const int OtherWidgetsThreshold = 400
static

Definition at line 251 of file kis_input_manager_p.cpp.