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 <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 468 of file kis_input_manager_p.cpp.

468#define EXTRA_BUTTON(z, n, _) \
469 if(buttons & Qt::ExtraButton##n) { \
470 buttonSet << Qt::ExtraButton##n; \
471 }

Function Documentation

◆ isInputWidget()

bool isInputWidget ( QWidget * w)

Definition at line 307 of file kis_input_manager_p.cpp.

308{
309 if (!w) return false;
310
311
313 types << QLatin1String("QAbstractSlider");
314 types << QLatin1String("QAbstractSpinBox");
315 types << QLatin1String("QLineEdit");
316 types << QLatin1String("QTextEdit");
317 types << QLatin1String("QPlainTextEdit");
318 types << QLatin1String("QComboBox");
319 types << QLatin1String("QKeySequenceEdit");
320
321 Q_FOREACH (const QLatin1String &type, types) {
322 if (w->inherits(type.data())) {
323 return true;
324 }
325 }
326
327 return false;
328}

◆ 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 60 of file kis_input_manager_p.cpp.

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

Variable Documentation

◆ InputWidgetsThreshold

const int InputWidgetsThreshold = 2000
static

Definition at line 243 of file kis_input_manager_p.cpp.

◆ OtherWidgetsThreshold

const int OtherWidgetsThreshold = 400
static

Definition at line 244 of file kis_input_manager_p.cpp.