13#include <klocalizedstring.h>
14#include <QApplication>
55#include "config-qt-patches-present.h"
60 return reinterpret_cast<quintptr
>(
value.data());
64 : QObject(parent), d(new
Private(this))
77 QApplication::instance()->
83 KisExtendedModifiersMapper::setLocalMonitor(
true, &
d->
matcher);
90 KisExtendedModifiersMapper::setLocalMonitor(
false);
110 auto popupObject =
dynamic_cast<QObject*
>(
d->
popupWidget);
122 auto popupObject =
dynamic_cast<QObject*
>(
d->
popupWidget);
124 disconnect(popupObject,
nullptr,
this,
nullptr);
156 Private::PriorityList::iterator it = begin;
159 it = std::find_if(begin, end,
162 if (it != end)
return;
164 it = std::find_if(begin, end,
176 it = std::find_if(it, end,
197#if defined (__clang__)
198#pragma GCC diagnostic ignored "-Wswitch"
214 if (filter.isNull()) {
218 savedPriorityEventFilterSeqNo++;
222 if (filter->eventFilter(
object, event))
return true;
248template <
class Event>
255 static_assert(std::is_same<Event, QMouseEvent>::value ||
256 std::is_same<Event, QTabletEvent>::value ||
257 std::is_same<Event, QTouchEvent>::value,
258 "event should be a mouse or a tablet event");
266 if ((event->type() == QEvent::MouseMove ||
267 event->type() == QEvent::TabletMove ||
268 event->type() == QEvent::TouchUpdate) &&
271#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
285 event->setAccepted(
true);
300 event->type() == QEvent::FocusIn ||
301 event->type() == QEvent::FocusOut ||
302 event->type() == QEvent::MouseButtonPress ||
303 event->type() == QEvent::MouseButtonRelease ||
304 event->type() == QEvent::MouseButtonDblClick ||
305 event->type() == QEvent::TabletPress ||
306 event->type() == QEvent::TabletRelease ||
307 event->type() == QEvent::Enter ||
308 event->type() == QEvent::Leave ||
309 event->type() == QEvent::TouchBegin ||
310 event->type() == QEvent::TouchEnd ||
311 event->type() == QEvent::TouchCancel ||
312 event->type() == QEvent::NativeGesture;
323 QEvent::Type type =
event->type();
325 if (type == QEvent::MouseButtonPress
326 || type == QEvent::MouseButtonDblClick
327 || type == QEvent::TabletPress
328 || type == QEvent::TouchBegin
329 || type == QEvent::NativeGesture) {
335 event->setAccepted(
true);
345 if (event->type() == QEvent::MouseMove ||
346 event->type() == QEvent::MouseButtonPress ||
347 event->type() == QEvent::MouseButtonRelease ||
348 event->type() == QEvent::TabletMove ||
349 event->type() == QEvent::TabletPress ||
350 event->type() == QEvent::TabletRelease ||
351 event->type() == QEvent::Wheel) {
363 if (receivingWidget && !receivingWidget->hasFocus()) {
373 QInputEvent *inputEvent =
static_cast<QInputEvent*
>(event);
374 if (event->type() != QEvent::ShortcutOverride &&
391 switch (event->type()) {
392 case QEvent::MouseButtonPress:
393 case QEvent::MouseButtonDblClick: {
397 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
408 event->setAccepted(retval);
411 case QEvent::MouseButtonRelease: {
415 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
417 event->setAccepted(retval);
420 case QEvent::ShortcutOverride: {
422 QKeyEvent *keyEvent =
static_cast<QKeyEvent*
>(event);
438 QKeyEvent kevent(QEvent::ShortcutOverride, key, modifiers);
443 guessedKeys.removeOne(key);
450 if (!keyEvent->isAutoRepeat()) {
460 keyEvent->setAccepted(
true);
465 case QEvent::KeyRelease: {
467 QKeyEvent *keyEvent =
static_cast<QKeyEvent*
>(event);
469 if (!keyEvent->isAutoRepeat()) {
501 (key == Qt::Key_Shift || key == Qt::Key_Alt ||
502 key == Qt::Key_Control || key == Qt::Key_Meta)) {
509 case QEvent::MouseMove: {
512 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
517 case QEvent::Wheel: {
519 QWheelEvent *wheelEvent =
static_cast<QWheelEvent*
>(event);
528 if (wheelEvent->source() == Qt::MouseEventSource::MouseEventSynthesizedBySystem) {
543 if (wheelEvent->angleDelta().isNull()) {
549 if (wheelEvent->angleDelta().x() < 0) {
551 }
else if (wheelEvent->angleDelta().x() >0) {
555 if (wheelEvent->angleDelta().y() < 0) {
557 }
else if (wheelEvent->angleDelta().y() > 0) {
561 bool wasScrolled =
false;
569 QWheelEvent::DefaultDeltasPerStep;
577 retval = !wasScrolled;
607 case QEvent::FocusIn:
617 case QEvent::FocusOut: {
621 QPointF currentLocalPos =
628 case QEvent::TabletPress: {
630 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
642 event->setAccepted(
true);
650#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH
653 event->setAccepted(
false);
655#elif defined Q_OS_WIN32
665 case QEvent::TabletMove: {
668 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
684#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH
687 event->setAccepted(
false);
692 case QEvent::TabletRelease: {
693#if defined(Q_OS_MAC) || defined(Q_OS_ANDROID)
699 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
702 event->setAccepted(
true);
704#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH
707 event->setAccepted(
false);
713 case QEvent::TouchBegin:
719 QTouchEvent *touchEvent =
static_cast<QTouchEvent *
>(event);
725#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
754 case QEvent::TouchUpdate:
757 event->setAccepted(
true);
760 QTouchEvent *touchEvent =
static_cast<QTouchEvent*
>(event);
763 int eventPointCount = touchEvent->touchPoints().size();
768 Q_FOREACH (
const QTouchEvent::TouchPoint &point, touchEvent->touchPoints()) {
769 if (point.state() != Qt::TouchPointReleased) {
774 if (count < 2 && eventPointCount > count) {
790 if (!
KisConfig(
true).disableTouchOnCanvas())
797 case QEvent::TouchEnd:
803 event->setAccepted(
true);
807 QTouchEvent *touchEvent =
static_cast<QTouchEvent*
>(event);
816 && touchEvent->touchPoints().count() == 1) {
829 if (!
KisConfig(
true).disableTouchOnCanvas())
835 case QEvent::TouchCancel:
846 bool ignoreCancel =
false;
857 event->setAccepted(
true);
863 QTouchEvent *touchEvent =
static_cast<QTouchEvent*
>(event);
879 case QEvent::NativeGesture:
881 QNativeGestureEvent *gevent =
static_cast<QNativeGestureEvent*
>(event);
882 switch (gevent->gestureType()) {
883 case Qt::BeginNativeGesture:
892 case Qt::EndNativeGesture:
922 if (
KisConfig(
true).disableTouchOnCanvas()) {
955 QPointF currentPos = touchEvent->touchPoints().at(0).pos();
958 && touchEvent->touchPoints().count() == 1 && touchEvent->touchPointStates() != Qt::TouchPointStationary
1006 QPointF currentLocalPos;
1065 dbgUI <<
"Adding shortcut" << shortcut->keys() <<
"for action" << shortcut->action()->name();
1066 switch(shortcut->type()) {
1068 d->
addKeyShortcut(shortcut->action(), shortcut->mode(), shortcut->keys());
1071 d->
addStrokeShortcut(shortcut->action(), shortcut->mode(), shortcut->keys(), shortcut->buttons());
1074 d->
addWheelShortcut(shortcut->action(), shortcut->mode(), shortcut->keys(), shortcut->wheel());
1087 dbgInput <<
"No Input Profile Found: canvas interaction will be impossible";
float value(const T *src, size_t ch)
KisAbstractCanvasWidget * canvasWidget
static KisConfigNotifier * instance()
bool disableTouchOnCanvas() const
bool ignoreHighFunctionKeys(bool defaultValue=false) const
static Qt::Key workaroundShiftAltMetaHell(const QKeyEvent *keyEvent)
Qt::KeyboardModifiers queryStandardModifiers()
ExtendedModifiers queryExtendedModifiers()
A class encapsulating all settings for a single shortcut.
@ MouseButtonType
A mouse button, possibly with key modifiers.
@ MouseWheelType
Mouse wheel movement, possibly with key modifiers.
@ KeyCombinationType
A list of keys that should be pressed.
@ GestureType
A touch gesture.
void lostFocusEvent(const QPointF &localPos)
bool hasRunningShortcut() const
bool autoRepeatedKeyPressed(Qt::Key key)
bool buttonReleased(Qt::MouseButton button, QEvent *event)
void toolHasBeenActivated()
bool nativeGestureEndEvent(QNativeGestureEvent *event)
bool keyPressed(Qt::Key key)
bool touchBeginEvent(QTouchEvent *event)
bool suppressAllKeyboardActions
void reinitializeButtons()
QVector< Qt::Key > debugPressedKeys() const
bool touchEndEvent(QTouchEvent *event)
bool touchUpdateEvent(QTouchEvent *event)
bool nativeGestureEvent(QNativeGestureEvent *event)
bool buttonPressed(Qt::MouseButton button, QEvent *event)
bool hasTouchHoldShortcut() const
bool sanityCheckModifiersCorrectness(Qt::KeyboardModifiers modifiers) const
bool supportsHiResInputEvents()
bool nativeGestureBeginEvent(QNativeGestureEvent *event)
void suppressConflictingKeyActions(const QVector< QKeySequence > &shortcuts)
bool keyReleased(Qt::Key key)
void touchCancelEvent(QTouchEvent *event, const QPointF &localPos)
bool wheelEvent(KisSingleActionShortcut::WheelAction wheelAction, QWheelEvent *event)
bool touchHoldBeginEvent(QTouchEvent *event)
@ WheelDown
Mouse wheel moves down.
@ WheelTrackpad
A pan movement on a trackpad.
@ WheelUp
Mouse wheel moves up.
@ WheelRight
Mouse wheel moves right.
@ WheelLeft
Mouse wheel moves left.
static KisTabletDebugger * instance()
#define KIS_SAFE_ASSERT_RECOVER(cond)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)
auto mem_equal_to(MemTypeNoRef Class::*ptr, MemType &&value)
mem_equal_to is an unary functor that compares a member of the object to a given value
auto mem_greater(MemTypeNoRef Class::*ptr, MemType &&value)
mem_greater is an unary functor that compares a member of the object to a given value