Changeset View
Changeset View
Standalone View
Standalone View
globalshortcuts.h
Show All 26 Lines | |||||
27 | class QAction; | 27 | class QAction; | ||
28 | class KGlobalAccelD; | 28 | class KGlobalAccelD; | ||
29 | class KGlobalAccelInterface; | 29 | class KGlobalAccelInterface; | ||
30 | 30 | | |||
31 | namespace KWin | 31 | namespace KWin | ||
32 | { | 32 | { | ||
33 | 33 | | |||
34 | class GlobalShortcut; | 34 | class GlobalShortcut; | ||
35 | class SwipeGesture; | ||||
36 | class GestureRecognizer; | ||||
35 | 37 | | |||
36 | /** | 38 | /** | ||
37 | * @brief Manager for the global shortcut system inside KWin. | 39 | * @brief Manager for the global shortcut system inside KWin. | ||
38 | * | 40 | * | ||
39 | * This class is responsible for holding all the global shortcuts and to process a key press event. | 41 | * This class is responsible for holding all the global shortcuts and to process a key press event. | ||
40 | * That is trigger a shortcut if there is a match. | 42 | * That is trigger a shortcut if there is a match. | ||
41 | * | 43 | * | ||
42 | * For internal shortcut handling (those which are delivered inside KWin) QActions are used and | 44 | * For internal shortcut handling (those which are delivered inside KWin) QActions are used and | ||
Show All 19 Lines | 50 | public: | |||
62 | * @brief Registers an internal global axis shortcut | 64 | * @brief Registers an internal global axis shortcut | ||
63 | * | 65 | * | ||
64 | * @param action The action to trigger if the shortcut is triggered | 66 | * @param action The action to trigger if the shortcut is triggered | ||
65 | * @param modifiers The modifiers which need to be hold to trigger the action | 67 | * @param modifiers The modifiers which need to be hold to trigger the action | ||
66 | * @param pointerButtons The pointer axis | 68 | * @param pointerButtons The pointer axis | ||
67 | */ | 69 | */ | ||
68 | void registerAxisShortcut(QAction *action, Qt::KeyboardModifiers modifiers, PointerAxisDirection axis); | 70 | void registerAxisShortcut(QAction *action, Qt::KeyboardModifiers modifiers, PointerAxisDirection axis); | ||
69 | 71 | | |||
72 | void registerTouchpadSwipe(QAction *action, SwipeDirection direction); | ||||
73 | | ||||
70 | /** | 74 | /** | ||
71 | * @brief Processes a key event to decide whether a shortcut needs to be triggered. | 75 | * @brief Processes a key event to decide whether a shortcut needs to be triggered. | ||
72 | * | 76 | * | ||
73 | * If a shortcut triggered this method returns @c true to indicate to the caller that the event | 77 | * If a shortcut triggered this method returns @c true to indicate to the caller that the event | ||
74 | * should not be further processed. If there is no shortcut which triggered for the key, then | 78 | * should not be further processed. If there is no shortcut which triggered for the key, then | ||
75 | * @c false is returned. | 79 | * @c false is returned. | ||
76 | * | 80 | * | ||
77 | * @param modifiers The current hold modifiers | 81 | * @param modifiers The current hold modifiers | ||
Show All 11 Lines | |||||
89 | * @c false is returned. | 93 | * @c false is returned. | ||
90 | * | 94 | * | ||
91 | * @param modifiers The current hold modifiers | 95 | * @param modifiers The current hold modifiers | ||
92 | * @param axis The axis direction which has triggered this event | 96 | * @param axis The axis direction which has triggered this event | ||
93 | * @return @c true if a shortcut triggered, @c false otherwise | 97 | * @return @c true if a shortcut triggered, @c false otherwise | ||
94 | */ | 98 | */ | ||
95 | bool processAxis(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis); | 99 | bool processAxis(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis); | ||
96 | 100 | | |||
101 | void processSwipeStart(uint fingerCount); | ||||
102 | void processSwipeUpdate(const QSizeF &delta); | ||||
103 | void processSwipeCancel(); | ||||
104 | void processSwipeEnd(); | ||||
105 | | ||||
97 | void setKGlobalAccelInterface(KGlobalAccelInterface *interface) { | 106 | void setKGlobalAccelInterface(KGlobalAccelInterface *interface) { | ||
98 | m_kglobalAccelInterface = interface; | 107 | m_kglobalAccelInterface = interface; | ||
99 | } | 108 | } | ||
100 | 109 | | |||
101 | private: | 110 | private: | ||
102 | void objectDeleted(QObject *object); | 111 | void objectDeleted(QObject *object); | ||
103 | QHash<Qt::KeyboardModifiers, QHash<Qt::MouseButtons, GlobalShortcut*> > m_pointerShortcuts; | 112 | QHash<Qt::KeyboardModifiers, QHash<Qt::MouseButtons, GlobalShortcut*> > m_pointerShortcuts; | ||
104 | QHash<Qt::KeyboardModifiers, QHash<PointerAxisDirection, GlobalShortcut*> > m_axisShortcuts; | 113 | QHash<Qt::KeyboardModifiers, QHash<PointerAxisDirection, GlobalShortcut*> > m_axisShortcuts; | ||
114 | QHash<Qt::KeyboardModifiers, QHash<SwipeDirection, GlobalShortcut*> > m_swipeShortcuts; | ||||
105 | KGlobalAccelD *m_kglobalAccel = nullptr; | 115 | KGlobalAccelD *m_kglobalAccel = nullptr; | ||
106 | KGlobalAccelInterface *m_kglobalAccelInterface = nullptr; | 116 | KGlobalAccelInterface *m_kglobalAccelInterface = nullptr; | ||
117 | GestureRecognizer *m_gestureRecognizer; | ||||
107 | }; | 118 | }; | ||
108 | 119 | | |||
109 | class GlobalShortcut | 120 | class GlobalShortcut | ||
110 | { | 121 | { | ||
111 | public: | 122 | public: | ||
112 | virtual ~GlobalShortcut(); | 123 | virtual ~GlobalShortcut(); | ||
113 | 124 | | |||
114 | const QKeySequence &shortcut() const; | 125 | const QKeySequence &shortcut() const; | ||
115 | Qt::KeyboardModifiers pointerButtonModifiers() const; | 126 | Qt::KeyboardModifiers pointerButtonModifiers() const; | ||
116 | Qt::MouseButtons pointerButtons() const; | 127 | Qt::MouseButtons pointerButtons() const; | ||
128 | SwipeDirection swipeDirection() const { | ||||
129 | return m_swipeDirection; | ||||
130 | } | ||||
117 | virtual void invoke() = 0; | 131 | virtual void invoke() = 0; | ||
118 | 132 | | |||
119 | protected: | 133 | protected: | ||
120 | GlobalShortcut(const QKeySequence &shortcut); | 134 | GlobalShortcut(const QKeySequence &shortcut); | ||
121 | GlobalShortcut(Qt::KeyboardModifiers pointerButtonModifiers, Qt::MouseButtons pointerButtons); | 135 | GlobalShortcut(Qt::KeyboardModifiers pointerButtonModifiers, Qt::MouseButtons pointerButtons); | ||
122 | GlobalShortcut(Qt::KeyboardModifiers axisModifiers, PointerAxisDirection axis); | 136 | GlobalShortcut(Qt::KeyboardModifiers axisModifiers, PointerAxisDirection axis); | ||
137 | GlobalShortcut(SwipeDirection direction); | ||||
123 | 138 | | |||
124 | private: | 139 | private: | ||
125 | QKeySequence m_shortcut; | 140 | QKeySequence m_shortcut; | ||
126 | Qt::KeyboardModifiers m_pointerModifiers; | 141 | Qt::KeyboardModifiers m_pointerModifiers; | ||
127 | Qt::MouseButtons m_pointerButtons; | 142 | Qt::MouseButtons m_pointerButtons; | ||
128 | PointerAxisDirection m_axis; | 143 | PointerAxisDirection m_axis; | ||
144 | SwipeDirection m_swipeDirection = SwipeDirection::Invalid;; | ||||
129 | }; | 145 | }; | ||
130 | 146 | | |||
131 | class InternalGlobalShortcut : public GlobalShortcut | 147 | class InternalGlobalShortcut : public GlobalShortcut | ||
132 | { | 148 | { | ||
133 | public: | 149 | public: | ||
134 | InternalGlobalShortcut(Qt::KeyboardModifiers modifiers, const QKeySequence &shortcut, QAction *action); | 150 | InternalGlobalShortcut(Qt::KeyboardModifiers modifiers, const QKeySequence &shortcut, QAction *action); | ||
135 | InternalGlobalShortcut(Qt::KeyboardModifiers pointerButtonModifiers, Qt::MouseButtons pointerButtons, QAction *action); | 151 | InternalGlobalShortcut(Qt::KeyboardModifiers pointerButtonModifiers, Qt::MouseButtons pointerButtons, QAction *action); | ||
136 | InternalGlobalShortcut(Qt::KeyboardModifiers axisModifiers, PointerAxisDirection axis, QAction *action); | 152 | InternalGlobalShortcut(Qt::KeyboardModifiers axisModifiers, PointerAxisDirection axis, QAction *action); | ||
153 | InternalGlobalShortcut(Qt::KeyboardModifiers swipeModifier, SwipeDirection direction, QAction *action); | ||||
137 | virtual ~InternalGlobalShortcut(); | 154 | virtual ~InternalGlobalShortcut(); | ||
138 | 155 | | |||
139 | void invoke() override; | 156 | void invoke() override; | ||
140 | 157 | | |||
141 | QAction *action() const; | 158 | QAction *action() const; | ||
159 | | ||||
160 | SwipeGesture *swipeGesture() const { | ||||
161 | return m_swipe.data(); | ||||
162 | } | ||||
142 | private: | 163 | private: | ||
143 | QAction *m_action; | 164 | QAction *m_action; | ||
165 | QScopedPointer<SwipeGesture> m_swipe; | ||||
144 | }; | 166 | }; | ||
145 | 167 | | |||
146 | inline | 168 | inline | ||
147 | QAction *InternalGlobalShortcut::action() const | 169 | QAction *InternalGlobalShortcut::action() const | ||
148 | { | 170 | { | ||
149 | return m_action; | 171 | return m_action; | ||
150 | } | 172 | } | ||
151 | 173 | | |||
Show All 21 Lines |