13#include <klocalizedstring.h>
14#include <QApplication>
50#include "config-qt-patches-present.h"
55 return reinterpret_cast<quintptr
>(
value.data());
59 : QObject(parent), d(new
Private(this))
72 QApplication::instance()->
78 KisExtendedModifiersMapper::setLocalMonitor(
true, &
d->
matcher);
85 KisExtendedModifiersMapper::setLocalMonitor(
false);
105 auto popupObject =
dynamic_cast<QObject*
>(
d->
popupWidget);
117 auto popupObject =
dynamic_cast<QObject*
>(
d->
popupWidget);
119 disconnect(popupObject,
nullptr,
this,
nullptr);
140 Private::PriorityList::iterator it = begin;
143 it = std::find_if(begin, end,
146 if (it != end)
return;
148 it = std::find_if(begin, end,
160 it = std::find_if(it, end,
181#if defined (__clang__)
182#pragma GCC diagnostic ignored "-Wswitch"
198 if (filter.isNull()) {
202 savedPriorityEventFilterSeqNo++;
206 if (filter->eventFilter(
object, event))
return true;
232template <
class Event>
239 static_assert(std::is_same<Event, QMouseEvent>::value ||
240 std::is_same<Event, QTabletEvent>::value,
241 "event should be a mouse or a tablet event");
249 if ((event->type() == QEvent::MouseMove ||
250 event->type() == QEvent::TabletMove) &&
253#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
267 event->setAccepted(
true);
282 event->type() == QEvent::FocusIn ||
283 event->type() == QEvent::FocusOut ||
284 event->type() == QEvent::MouseButtonPress ||
285 event->type() == QEvent::MouseButtonRelease ||
286 event->type() == QEvent::MouseButtonDblClick ||
287 event->type() == QEvent::TabletPress ||
288 event->type() == QEvent::TabletRelease ||
289 event->type() == QEvent::Enter ||
290 event->type() == QEvent::Leave ||
291 event->type() == QEvent::TouchBegin ||
292 event->type() == QEvent::TouchEnd ||
293 event->type() == QEvent::TouchCancel ||
294 event->type() == QEvent::NativeGesture;
305 QEvent::Type type =
event->type();
307 if (type == QEvent::MouseButtonPress
308 || type == QEvent::MouseButtonDblClick
309 || type == QEvent::TabletPress
310 || type == QEvent::TouchBegin
311 || type == QEvent::NativeGesture) {
317 event->setAccepted(
true);
327 if (event->type() == QEvent::MouseMove ||
328 event->type() == QEvent::MouseButtonPress ||
329 event->type() == QEvent::MouseButtonRelease ||
330 event->type() == QEvent::TabletMove ||
331 event->type() == QEvent::TabletPress ||
332 event->type() == QEvent::TabletRelease ||
333 event->type() == QEvent::Wheel) {
345 if (receivingWidget && !receivingWidget->hasFocus()) {
355 QInputEvent *inputEvent =
static_cast<QInputEvent*
>(event);
356 if (event->type() != QEvent::ShortcutOverride &&
373 switch (event->type()) {
374 case QEvent::MouseButtonPress:
375 case QEvent::MouseButtonDblClick: {
376 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
387 event->setAccepted(retval);
390 case QEvent::MouseButtonRelease: {
391 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
393 event->setAccepted(retval);
396 case QEvent::ShortcutOverride: {
397 KisInputEventsEater::debugEvent<QKeyEvent>(event);
398 QKeyEvent *keyEvent =
static_cast<QKeyEvent*
>(event);
414 QKeyEvent kevent(QEvent::ShortcutOverride, key, modifiers);
419 guessedKeys.removeOne(key);
426 if (!keyEvent->isAutoRepeat()) {
436 keyEvent->setAccepted(
true);
441 case QEvent::KeyRelease: {
442 KisInputEventsEater::debugEvent<QKeyEvent>(event);
443 QKeyEvent *keyEvent =
static_cast<QKeyEvent*
>(event);
445 if (!keyEvent->isAutoRepeat()) {
477 (key == Qt::Key_Shift || key == Qt::Key_Alt ||
478 key == Qt::Key_Control || key == Qt::Key_Meta)) {
485 case QEvent::MouseMove: {
486 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
491 case QEvent::Wheel: {
492 KisInputEventsEater::debugEvent<QWheelEvent>(event);
493 QWheelEvent *wheelEvent =
static_cast<QWheelEvent*
>(event);
503 if (wheelEvent->phase() == Qt::ScrollBegin) {
505 }
else if (wheelEvent->phase() == Qt::ScrollEnd) {
520 if (wheelEvent->angleDelta().isNull()) {
525 bool wasScrolled =
false;
530 if (wheelEvent->angleDelta().y() < 0) {
532 }
else if (wheelEvent->angleDelta().y() > 0) {
549 if (wheelEvent->angleDelta().x() < 0) {
551 }
else if (wheelEvent->angleDelta().x() > 0) {
565 retval = !wasScrolled;
570 KisInputEventsEater::debugEvent<QEvent>(event);
576 KisInputEventsEater::debugEvent<QEvent>(event);
580 case QEvent::FocusIn:
581 KisInputEventsEater::debugEvent<QEvent>(event);
588 case QEvent::FocusOut: {
589 KisInputEventsEater::debugEvent<QEvent>(event);
592 QPointF currentLocalPos =
599 case QEvent::TabletPress: {
600 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
608 event->setAccepted(
true);
614#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH
617 event->setAccepted(
false);
619#elif defined Q_OS_WIN32
629 case QEvent::TabletMove: {
630 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
637#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH
640 event->setAccepted(
false);
645 case QEvent::TabletRelease: {
646 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
649 event->setAccepted(
true);
651#if defined Q_OS_LINUX && !KRITA_QT_HAS_ENTER_LEAVE_PATCH
654 event->setAccepted(
false);
660 case QEvent::TouchBegin:
664 QTouchEvent *touchEvent =
static_cast<QTouchEvent *
>(event);
676 case QEvent::TouchUpdate:
679 event->setAccepted(
true);
682 QTouchEvent *touchEvent =
static_cast<QTouchEvent*
>(event);
688 if (pressedCount < 2 && totalPointCount > pressedCount) {
728 case QEvent::TouchEnd:
731 event->setAccepted(
true);
734 QTouchEvent *touchEvent =
static_cast<QTouchEvent*
>(event);
743 case QEvent::TouchCancel:
746 event->setAccepted(
true);
749 QTouchEvent *touchEvent =
static_cast<QTouchEvent*
>(event);
760 case QEvent::NativeGesture:
762 QNativeGestureEvent *gevent =
static_cast<QNativeGestureEvent*
>(event);
763 switch (gevent->gestureType()) {
764 case Qt::BeginNativeGesture:
771 case Qt::EndNativeGesture:
822 QPointF currentLocalPos;
880 dbgUI <<
"Adding shortcut" << shortcut->keys() <<
"for action" << shortcut->action()->name();
881 switch(shortcut->type()) {
883 d->
addKeyShortcut(shortcut->action(), shortcut->mode(), shortcut->keys());
886 d->
addStrokeShortcut(shortcut->action(), shortcut->mode(), shortcut->keys(), shortcut->buttons());
889 d->
addWheelShortcut(shortcut->action(), shortcut->mode(), shortcut->keys(), shortcut->wheel());
892 d->
addTouchShortcut(shortcut->action(), shortcut->mode(), shortcut->touchGesture());
912 warnUI <<
"No Input Profile Found: canvas interaction will be impossible";
float value(const T *src, size_t ch)
KisAbstractCanvasWidget * canvasWidget
static KisConfigNotifier * instance()
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.
@ NativeGestureType
A macOS gesture.
@ MouseButtonType
A mouse button, possibly with key modifiers.
@ MouseWheelType
Mouse wheel movement, possibly with key modifiers.
@ TouchGestureType
A touch gesture.
@ KeyCombinationType
A list of keys that should be pressed.
void lostFocusEvent(const QPointF &localPos)
bool hasRunningShortcut() const
bool autoRepeatedKeyPressed(Qt::Key key)
bool buttonReleased(Qt::MouseButton button, QEvent *event)
bool touchpadScrollEndEvent(QWheelEvent *event)
bool hasTouchpadScrollShortcuts() const
void toolHasBeenActivated()
bool nativeGestureEndEvent(QNativeGestureEvent *event)
bool keyPressed(Qt::Key key)
bool touchBeginEvent(QTouchEvent *event)
bool suppressAllKeyboardActions
bool touchpadScrollBeginEvent(QWheelEvent *event)
bool touchpadScrollEvent(QWheelEvent *event)
void reinitializeButtons()
void touchCancelEvent(QTouchEvent *event)
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 sanityCheckModifiersCorrectness(Qt::KeyboardModifiers modifiers) const
bool supportsHiResInputEvents()
bool nativeGestureBeginEvent(QNativeGestureEvent *event)
void suppressConflictingKeyActions(const QVector< QKeySequence > &shortcuts)
bool keyReleased(Qt::Key key)
bool wheelEvent(KisSingleActionShortcut::WheelAction wheelAction, QWheelEvent *event)
@ WheelDown
Mouse wheel moves down.
@ WheelUp
Mouse wheel moves up.
@ WheelRight
Mouse wheel moves right.
@ WheelLeft
Mouse wheel moves left.
static KisTabletDebugger * instance()
static Qt::TouchPointStates pressedOnlyTouchStates()
static int countTouchPoints(const QTouchEvent *event, Qt::TouchPointStates allowedStates)
static Qt::TouchPointStates allTouchStates()
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