Changeset View
Changeset View
Standalone View
Standalone View
input.cpp
Show First 20 Lines • Show All 753 Lines • ▼ Show 20 Line(s) | 745 | bool wheelEvent(QWheelEvent *event) override { | |||
---|---|---|---|---|---|
754 | } else if (event->angleDelta().y() < 0) { | 754 | } else if (event->angleDelta().y() < 0) { | ||
755 | direction = PointerAxisDown; | 755 | direction = PointerAxisDown; | ||
756 | } else if (event->angleDelta().y() > 0) { | 756 | } else if (event->angleDelta().y() > 0) { | ||
757 | direction = PointerAxisUp; | 757 | direction = PointerAxisUp; | ||
758 | } | 758 | } | ||
759 | return input()->shortcuts()->processAxis(event->modifiers(), direction); | 759 | return input()->shortcuts()->processAxis(event->modifiers(), direction); | ||
760 | } | 760 | } | ||
761 | bool keyEvent(QKeyEvent *event) override { | 761 | bool keyEvent(QKeyEvent *event) override { | ||
762 | if (event->key() == Qt::Key_PowerOff) { | ||||
762 | if (event->type() == QEvent::KeyPress) { | 763 | if (event->type() == QEvent::KeyPress) { | ||
764 | m_powerOffPress = event->timestamp(); | ||||
765 | } else if (event->type() == QEvent::KeyRelease) { | ||||
766 | const uint duration = (event->timestamp() - m_powerOffPress); | ||||
767 | const Qt::Key key = duration > 1000 ? Qt::Key_PowerDown : Qt::Key_PowerOff; | ||||
768 | const auto shortcuts = static_cast<KeyEvent*>(event)->modifiersRelevantForGlobalShortcuts(); | ||||
769 | return input()->shortcuts()->processKey(shortcuts, key | (event->key() & ~Qt::KeyboardModifierMask)); | ||||
770 | } | ||||
771 | } else if (event->type() == QEvent::KeyPress) { | ||||
763 | return input()->shortcuts()->processKey(static_cast<KeyEvent*>(event)->modifiersRelevantForGlobalShortcuts(), event->key()); | 772 | return input()->shortcuts()->processKey(static_cast<KeyEvent*>(event)->modifiersRelevantForGlobalShortcuts(), event->key()); | ||
764 | } | 773 | } | ||
765 | return false; | 774 | return false; | ||
766 | } | 775 | } | ||
767 | bool swipeGestureBegin(int fingerCount, quint32 time) override { | 776 | bool swipeGestureBegin(int fingerCount, quint32 time) override { | ||
768 | Q_UNUSED(time) | 777 | Q_UNUSED(time) | ||
769 | input()->shortcuts()->processSwipeStart(fingerCount); | 778 | input()->shortcuts()->processSwipeStart(fingerCount); | ||
770 | return false; | 779 | return false; | ||
771 | } | 780 | } | ||
772 | bool swipeGestureUpdate(const QSizeF &delta, quint32 time) override { | 781 | bool swipeGestureUpdate(const QSizeF &delta, quint32 time) override { | ||
773 | Q_UNUSED(time) | 782 | Q_UNUSED(time) | ||
774 | input()->shortcuts()->processSwipeUpdate(delta); | 783 | input()->shortcuts()->processSwipeUpdate(delta); | ||
775 | return false; | 784 | return false; | ||
776 | } | 785 | } | ||
777 | bool swipeGestureCancelled(quint32 time) override { | 786 | bool swipeGestureCancelled(quint32 time) override { | ||
778 | Q_UNUSED(time) | 787 | Q_UNUSED(time) | ||
779 | input()->shortcuts()->processSwipeCancel(); | 788 | input()->shortcuts()->processSwipeCancel(); | ||
780 | return false; | 789 | return false; | ||
781 | } | 790 | } | ||
782 | bool swipeGestureEnd(quint32 time) override { | 791 | bool swipeGestureEnd(quint32 time) override { | ||
783 | Q_UNUSED(time) | 792 | Q_UNUSED(time) | ||
784 | input()->shortcuts()->processSwipeEnd(); | 793 | input()->shortcuts()->processSwipeEnd(); | ||
785 | return false; | 794 | return false; | ||
786 | } | 795 | } | ||
796 | | ||||
797 | private: | ||||
798 | uint m_powerOffPress; | ||||
787 | }; | 799 | }; | ||
788 | 800 | | |||
789 | 801 | | |||
790 | namespace { | 802 | namespace { | ||
791 | 803 | | |||
792 | enum class MouseAction { | 804 | enum class MouseAction { | ||
793 | ModifierOnly, | 805 | ModifierOnly, | ||
794 | ModifierAndWindow | 806 | ModifierAndWindow | ||
▲ Show 20 Lines • Show All 1745 Lines • Show Last 20 Lines |