Changeset View
Changeset View
Standalone View
Standalone View
modifier_only_shortcuts.cpp
Show All 39 Lines | |||||
40 | ModifierOnlyShortcuts::~ModifierOnlyShortcuts() = default; | 40 | ModifierOnlyShortcuts::~ModifierOnlyShortcuts() = default; | ||
41 | 41 | | |||
42 | void ModifierOnlyShortcuts::keyEvent(KeyEvent *event) | 42 | void ModifierOnlyShortcuts::keyEvent(KeyEvent *event) | ||
43 | { | 43 | { | ||
44 | if (event->isAutoRepeat()) { | 44 | if (event->isAutoRepeat()) { | ||
45 | return; | 45 | return; | ||
46 | } | 46 | } | ||
47 | if (event->type() == QEvent::KeyPress) { | 47 | if (event->type() == QEvent::KeyPress) { | ||
48 | m_pressCount++; | 48 | const bool wasEmpty = m_pressedKeys.isEmpty(); | ||
49 | if (m_pressCount == 1 && | 49 | m_pressedKeys.insert(event->nativeScanCode()); | ||
50 | if (wasEmpty && m_pressedKeys.size() == 1 && | ||||
50 | !ScreenLockerWatcher::self()->isLocked() && | 51 | !ScreenLockerWatcher::self()->isLocked() && | ||
51 | m_buttonPressCount == 0 && | 52 | m_buttonPressCount == 0 && | ||
52 | m_cachedMods == Qt::NoModifier) { | 53 | m_cachedMods == Qt::NoModifier) { | ||
53 | m_modifier = Qt::KeyboardModifier(int(event->modifiersRelevantForGlobalShortcuts())); | 54 | m_modifier = Qt::KeyboardModifier(int(event->modifiersRelevantForGlobalShortcuts())); | ||
54 | } else { | 55 | } else { | ||
55 | m_modifier = Qt::NoModifier; | 56 | m_modifier = Qt::NoModifier; | ||
56 | } | 57 | } | ||
57 | } else { | 58 | } else if (!m_pressedKeys.isEmpty()) { | ||
58 | m_pressCount--; | 59 | m_pressedKeys.remove(event->nativeScanCode()); | ||
59 | if (m_pressCount == 0 && | 60 | if (m_pressedKeys.isEmpty() && | ||
60 | event->modifiersRelevantForGlobalShortcuts() == Qt::NoModifier && | 61 | event->modifiersRelevantForGlobalShortcuts() == Qt::NoModifier && | ||
61 | !workspace()->globalShortcutsDisabled()) { | 62 | !workspace()->globalShortcutsDisabled()) { | ||
62 | if (m_modifier != Qt::NoModifier) { | 63 | if (m_modifier != Qt::NoModifier) { | ||
63 | const auto list = options->modifierOnlyDBusShortcut(m_modifier); | 64 | const auto list = options->modifierOnlyDBusShortcut(m_modifier); | ||
64 | if (list.size() >= 4) { | 65 | if (list.size() >= 4) { | ||
65 | auto call = QDBusMessage::createMethodCall(list.at(0), list.at(1), list.at(2), list.at(3)); | 66 | auto call = QDBusMessage::createMethodCall(list.at(0), list.at(1), list.at(2), list.at(3)); | ||
66 | QVariantList args; | 67 | QVariantList args; | ||
67 | for (int i = 4; i < list.size(); ++i) { | 68 | for (int i = 4; i < list.size(); ++i) { | ||
68 | args << list.at(i); | 69 | args << list.at(i); | ||
69 | } | 70 | } | ||
70 | call.setArguments(args); | 71 | call.setArguments(args); | ||
71 | QDBusConnection::sessionBus().asyncCall(call); | 72 | QDBusConnection::sessionBus().asyncCall(call); | ||
72 | } | 73 | } | ||
73 | } | 74 | } | ||
74 | } | 75 | } | ||
75 | m_modifier = Qt::NoModifier; | 76 | m_modifier = Qt::NoModifier; | ||
77 | } else { | ||||
78 | m_modifier = Qt::NoModifier; | ||||
76 | } | 79 | } | ||
77 | m_cachedMods = event->modifiersRelevantForGlobalShortcuts(); | 80 | m_cachedMods = event->modifiersRelevantForGlobalShortcuts(); | ||
78 | } | 81 | } | ||
79 | 82 | | |||
80 | void ModifierOnlyShortcuts::pointerEvent(MouseEvent *event) | 83 | void ModifierOnlyShortcuts::pointerEvent(MouseEvent *event) | ||
81 | { | 84 | { | ||
82 | if (event->type() == QEvent::MouseMove) { | 85 | if (event->type() == QEvent::MouseMove) { | ||
83 | return; | 86 | return; | ||
Show All 16 Lines |