Changeset View
Changeset View
Standalone View
Standalone View
input.cpp
Show First 20 Lines • Show All 424 Lines • ▼ Show 20 Line(s) | 416 | if (event->type() == QEvent::KeyPress) { | |||
---|---|---|---|---|---|
425 | } | 425 | } | ||
426 | } else { | 426 | } else { | ||
427 | cancel(); | 427 | cancel(); | ||
428 | return false; | 428 | return false; | ||
429 | } | 429 | } | ||
430 | } else if (input()->pointer()->isConstrained()) { | 430 | } else if (input()->pointer()->isConstrained()) { | ||
431 | if (event->type() == QEvent::KeyPress && | 431 | if (event->type() == QEvent::KeyPress && | ||
432 | event->key() == Qt::Key_Escape && | 432 | event->key() == Qt::Key_Escape && | ||
433 | input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts() == Qt::KeyboardModifiers()) { | 433 | static_cast<KeyEvent*>(event)->modifiersRelevantForGlobalShortcuts() == Qt::KeyboardModifiers()) { | ||
434 | // TODO: don't hard code | 434 | // TODO: don't hard code | ||
435 | m_timer->start(3000); | 435 | m_timer->start(3000); | ||
436 | input()->keyboard()->update(); | 436 | input()->keyboard()->update(); | ||
437 | m_keyCode = event->nativeScanCode(); | 437 | m_keyCode = event->nativeScanCode(); | ||
438 | passToWaylandServer(event); | 438 | passToWaylandServer(event); | ||
439 | return true; | 439 | return true; | ||
440 | } | 440 | } | ||
441 | } | 441 | } | ||
▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Line(s) | 680 | } else if (event->angleDelta().y() < 0) { | |||
681 | direction = PointerAxisDown; | 681 | direction = PointerAxisDown; | ||
682 | } else if (event->angleDelta().y() > 0) { | 682 | } else if (event->angleDelta().y() > 0) { | ||
683 | direction = PointerAxisUp; | 683 | direction = PointerAxisUp; | ||
684 | } | 684 | } | ||
685 | return input()->shortcuts()->processAxis(event->modifiers(), direction); | 685 | return input()->shortcuts()->processAxis(event->modifiers(), direction); | ||
686 | } | 686 | } | ||
687 | bool keyEvent(QKeyEvent *event) override { | 687 | bool keyEvent(QKeyEvent *event) override { | ||
688 | if (event->type() == QEvent::KeyPress) { | 688 | if (event->type() == QEvent::KeyPress) { | ||
689 | return input()->shortcuts()->processKey(input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts(), event->nativeVirtualKey(), event->key()); | 689 | return input()->shortcuts()->processKey(static_cast<KeyEvent*>(event)->modifiersRelevantForGlobalShortcuts(), event->nativeVirtualKey(), event->key()); | ||
690 | } | 690 | } | ||
691 | return false; | 691 | return false; | ||
692 | } | 692 | } | ||
693 | }; | 693 | }; | ||
694 | 694 | | |||
695 | class InternalWindowEventFilter : public InputEventFilter { | 695 | class InternalWindowEventFilter : public InputEventFilter { | ||
696 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | 696 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | ||
697 | Q_UNUSED(nativeButton) | 697 | Q_UNUSED(nativeButton) | ||
▲ Show 20 Lines • Show All 300 Lines • ▼ Show 20 Line(s) | 994 | bool keyEvent(QKeyEvent *event) override { | |||
998 | auto seat = waylandServer()->seat(); | 998 | auto seat = waylandServer()->seat(); | ||
999 | seat->setFocusedKeyboardSurface(nullptr); | 999 | seat->setFocusedKeyboardSurface(nullptr); | ||
1000 | // pass the key event to the seat, so that it has a proper model of the currently hold keys | 1000 | // pass the key event to the seat, so that it has a proper model of the currently hold keys | ||
1001 | // this is important for combinations like alt+shift to ensure that shift is not considered pressed | 1001 | // this is important for combinations like alt+shift to ensure that shift is not considered pressed | ||
1002 | passToWaylandServer(event); | 1002 | passToWaylandServer(event); | ||
1003 | 1003 | | |||
1004 | if (event->type() == QEvent::KeyPress) { | 1004 | if (event->type() == QEvent::KeyPress) { | ||
1005 | TabBox::TabBox::self()->keyPress(event->modifiers() | event->key()); | 1005 | TabBox::TabBox::self()->keyPress(event->modifiers() | event->key()); | ||
1006 | } else if (input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts() == Qt::NoModifier) { | 1006 | } else if (static_cast<KeyEvent*>(event)->modifiersRelevantForGlobalShortcuts() == Qt::NoModifier) { | ||
1007 | TabBox::TabBox::self()->modifiersReleased(); | 1007 | TabBox::TabBox::self()->modifiersReleased(); | ||
1008 | } | 1008 | } | ||
1009 | return true; | 1009 | return true; | ||
1010 | } | 1010 | } | ||
1011 | bool wheelEvent(QWheelEvent *event) override { | 1011 | bool wheelEvent(QWheelEvent *event) override { | ||
1012 | if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) { | 1012 | if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) { | ||
1013 | return false; | 1013 | return false; | ||
1014 | } | 1014 | } | ||
Show All 26 Lines | 1040 | if (event->type() != QEvent::MouseButtonPress) { | |||
1041 | return false; | 1041 | return false; | ||
1042 | } | 1042 | } | ||
1043 | AbstractClient *c = dynamic_cast<AbstractClient*>(input()->pointer()->window().data()); | 1043 | AbstractClient *c = dynamic_cast<AbstractClient*>(input()->pointer()->window().data()); | ||
1044 | if (!c) { | 1044 | if (!c) { | ||
1045 | return false; | 1045 | return false; | ||
1046 | } | 1046 | } | ||
1047 | bool wasAction = false; | 1047 | bool wasAction = false; | ||
1048 | Options::MouseCommand command = Options::MouseNothing; | 1048 | Options::MouseCommand command = Options::MouseNothing; | ||
1049 | if (input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts() == options->commandAllModifier()) { | 1049 | if (static_cast<MouseEvent*>(event)->modifiersRelevantForGlobalShortcuts() == options->commandAllModifier()) { | ||
1050 | wasAction = true; | 1050 | wasAction = true; | ||
1051 | switch (event->button()) { | 1051 | switch (event->button()) { | ||
1052 | case Qt::LeftButton: | 1052 | case Qt::LeftButton: | ||
1053 | command = options->commandAll1(); | 1053 | command = options->commandAll1(); | ||
1054 | break; | 1054 | break; | ||
1055 | case Qt::MiddleButton: | 1055 | case Qt::MiddleButton: | ||
1056 | command = options->commandAll2(); | 1056 | command = options->commandAll2(); | ||
1057 | break; | 1057 | break; | ||
Show All 18 Lines | 1074 | if (event->angleDelta().y() == 0) { | |||
1076 | return false; | 1076 | return false; | ||
1077 | } | 1077 | } | ||
1078 | AbstractClient *c = dynamic_cast<AbstractClient*>(input()->pointer()->window().data()); | 1078 | AbstractClient *c = dynamic_cast<AbstractClient*>(input()->pointer()->window().data()); | ||
1079 | if (!c) { | 1079 | if (!c) { | ||
1080 | return false; | 1080 | return false; | ||
1081 | } | 1081 | } | ||
1082 | bool wasAction = false; | 1082 | bool wasAction = false; | ||
1083 | Options::MouseCommand command = Options::MouseNothing; | 1083 | Options::MouseCommand command = Options::MouseNothing; | ||
1084 | if (input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts() == options->commandAllModifier()) { | 1084 | if (static_cast<WheelEvent*>(event)->modifiersRelevantForGlobalShortcuts() == options->commandAllModifier()) { | ||
1085 | wasAction = true; | 1085 | wasAction = true; | ||
1086 | command = options->operationWindowMouseWheel(-1 * event->angleDelta().y()); | 1086 | command = options->operationWindowMouseWheel(-1 * event->angleDelta().y()); | ||
1087 | } else { | 1087 | } else { | ||
1088 | command = c->getWheelCommand(Qt::Vertical, &wasAction); | 1088 | command = c->getWheelCommand(Qt::Vertical, &wasAction); | ||
1089 | } | 1089 | } | ||
1090 | if (wasAction) { | 1090 | if (wasAction) { | ||
1091 | return !c->performMouseCommand(command, event->globalPos()); | 1091 | return !c->performMouseCommand(command, event->globalPos()); | ||
1092 | } | 1092 | } | ||
▲ Show 20 Lines • Show All 687 Lines • ▼ Show 20 Line(s) | 1733 | { | |||
1780 | return NULL; | 1780 | return NULL; | ||
1781 | } | 1781 | } | ||
1782 | 1782 | | |||
1783 | Qt::KeyboardModifiers InputRedirection::keyboardModifiers() const | 1783 | Qt::KeyboardModifiers InputRedirection::keyboardModifiers() const | ||
1784 | { | 1784 | { | ||
1785 | return m_keyboard->modifiers(); | 1785 | return m_keyboard->modifiers(); | ||
1786 | } | 1786 | } | ||
1787 | 1787 | | |||
1788 | Qt::KeyboardModifiers InputRedirection::modifiersRelevantForGlobalShortcuts() const | ||||
1789 | { | ||||
1790 | return m_keyboard->modifiersRelevantForGlobalShortcuts(); | ||||
1791 | } | ||||
1792 | | ||||
1788 | void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *action) | 1793 | void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *action) | ||
1789 | { | 1794 | { | ||
1790 | m_shortcuts->registerShortcut(action, shortcut); | 1795 | m_shortcuts->registerShortcut(action, shortcut); | ||
1791 | registerShortcutForGlobalAccelTimestamp(action); | 1796 | registerShortcutForGlobalAccelTimestamp(action); | ||
1792 | } | 1797 | } | ||
1793 | 1798 | | |||
1794 | void InputRedirection::registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) | 1799 | void InputRedirection::registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) | ||
1795 | { | 1800 | { | ||
▲ Show 20 Lines • Show All 186 Lines • Show Last 20 Lines |