Changeset View
Changeset View
Standalone View
Standalone View
input.h
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | |||||
61 | 61 | | |||
62 | /** | 62 | /** | ||
63 | * @brief This class is responsible for redirecting incoming input to the surface which currently | 63 | * @brief This class is responsible for redirecting incoming input to the surface which currently | ||
64 | * has input or send enter/leave events. | 64 | * has input or send enter/leave events. | ||
65 | * | 65 | * | ||
66 | * In addition input is intercepted before passed to the surfaces to have KWin internal areas | 66 | * In addition input is intercepted before passed to the surfaces to have KWin internal areas | ||
67 | * getting input first (e.g. screen edges) and filter the input event out if we currently have | 67 | * getting input first (e.g. screen edges) and filter the input event out if we currently have | ||
68 | * a full input grab. | 68 | * a full input grab. | ||
69 | * | 69 | **/ | ||
70 | */ | | |||
71 | class KWIN_EXPORT InputRedirection : public QObject | 70 | class KWIN_EXPORT InputRedirection : public QObject | ||
72 | { | 71 | { | ||
73 | Q_OBJECT | 72 | Q_OBJECT | ||
74 | public: | 73 | public: | ||
75 | enum PointerButtonState { | 74 | enum PointerButtonState { | ||
76 | PointerButtonReleased, | 75 | PointerButtonReleased, | ||
77 | PointerButtonPressed | 76 | PointerButtonPressed | ||
78 | }; | 77 | }; | ||
79 | enum PointerAxis { | 78 | enum PointerAxis { | ||
80 | PointerAxisVertical, | 79 | PointerAxisVertical, | ||
81 | PointerAxisHorizontal | 80 | PointerAxisHorizontal | ||
82 | }; | 81 | }; | ||
83 | enum KeyboardKeyState { | 82 | enum KeyboardKeyState { | ||
84 | KeyboardKeyReleased, | 83 | KeyboardKeyReleased, | ||
85 | KeyboardKeyPressed, | 84 | KeyboardKeyPressed, | ||
86 | KeyboardKeyAutoRepeat | 85 | KeyboardKeyAutoRepeat | ||
87 | }; | 86 | }; | ||
88 | virtual ~InputRedirection(); | 87 | virtual ~InputRedirection(); | ||
89 | void init(); | 88 | void init(); | ||
90 | 89 | | |||
91 | /** | 90 | /** | ||
92 | * @return const QPointF& The current global pointer position | 91 | * @return const QPointF& The current global pointer position | ||
93 | */ | 92 | **/ | ||
94 | QPointF globalPointer() const; | 93 | QPointF globalPointer() const; | ||
95 | Qt::MouseButtons qtButtonStates() const; | 94 | Qt::MouseButtons qtButtonStates() const; | ||
96 | Qt::KeyboardModifiers keyboardModifiers() const; | 95 | Qt::KeyboardModifiers keyboardModifiers() const; | ||
97 | Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const; | 96 | Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const; | ||
98 | 97 | | |||
99 | void registerShortcut(const QKeySequence &shortcut, QAction *action); | 98 | void registerShortcut(const QKeySequence &shortcut, QAction *action); | ||
100 | /** | 99 | /** | ||
101 | * @overload | 100 | * @overload | ||
102 | * | 101 | * | ||
103 | * Like registerShortcut, but also connects QAction::triggered to the @p slot on @p receiver. | 102 | * Like registerShortcut, but also connects QAction::triggered to the @p slot on @p receiver. | ||
104 | * It's recommended to use this method as it ensures that the X11 timestamp is updated prior | 103 | * It's recommended to use this method as it ensures that the X11 timestamp is updated prior | ||
105 | * to the @p slot being invoked. If not using this overload it's required to ensure that | 104 | * to the @p slot being invoked. If not using this overload it's required to ensure that | ||
106 | * registerShortcut is called before connecting to QAction's triggered signal. | 105 | * registerShortcut is called before connecting to QAction's triggered signal. | ||
107 | **/ | 106 | **/ | ||
108 | template <typename T, typename Slot> | 107 | template <typename T, typename Slot> | ||
109 | void registerShortcut(const QKeySequence &shortcut, QAction *action, T *receiver, Slot slot); | 108 | void registerShortcut(const QKeySequence &shortcut, QAction *action, T *receiver, Slot slot); | ||
110 | void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action); | 109 | void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action); | ||
111 | void registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action); | 110 | void registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action); | ||
112 | void registerTouchpadSwipeShortcut(SwipeDirection direction, QAction *action); | 111 | void registerTouchpadSwipeShortcut(SwipeDirection direction, QAction *action); | ||
113 | void registerGlobalAccel(KGlobalAccelInterface *interface); | 112 | void registerGlobalAccel(KGlobalAccelInterface *interface); | ||
114 | 113 | | |||
115 | /** | 114 | /** | ||
116 | * @internal | 115 | * @internal | ||
117 | */ | 116 | **/ | ||
118 | void processPointerMotion(const QPointF &pos, uint32_t time); | 117 | void processPointerMotion(const QPointF &pos, uint32_t time); | ||
119 | /** | 118 | /** | ||
120 | * @internal | 119 | * @internal | ||
121 | */ | 120 | **/ | ||
122 | void processPointerButton(uint32_t button, PointerButtonState state, uint32_t time); | 121 | void processPointerButton(uint32_t button, PointerButtonState state, uint32_t time); | ||
123 | /** | 122 | /** | ||
124 | * @internal | 123 | * @internal | ||
125 | */ | 124 | **/ | ||
126 | void processPointerAxis(PointerAxis axis, qreal delta, uint32_t time); | 125 | void processPointerAxis(PointerAxis axis, qreal delta, uint32_t time); | ||
127 | /** | 126 | /** | ||
128 | * @internal | 127 | * @internal | ||
129 | */ | 128 | **/ | ||
130 | void processKeyboardKey(uint32_t key, KeyboardKeyState state, uint32_t time); | 129 | void processKeyboardKey(uint32_t key, KeyboardKeyState state, uint32_t time); | ||
131 | /** | 130 | /** | ||
132 | * @internal | 131 | * @internal | ||
133 | */ | 132 | **/ | ||
134 | void processKeyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group); | 133 | void processKeyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group); | ||
135 | /** | 134 | /** | ||
136 | * @internal | 135 | * @internal | ||
137 | **/ | 136 | **/ | ||
138 | void processKeymapChange(int fd, uint32_t size); | 137 | void processKeymapChange(int fd, uint32_t size); | ||
139 | void processTouchDown(qint32 id, const QPointF &pos, quint32 time); | 138 | void processTouchDown(qint32 id, const QPointF &pos, quint32 time); | ||
140 | void processTouchUp(qint32 id, quint32 time); | 139 | void processTouchUp(qint32 id, quint32 time); | ||
141 | void processTouchMotion(qint32 id, const QPointF &pos, quint32 time); | 140 | void processTouchMotion(qint32 id, const QPointF &pos, quint32 time); | ||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | |||||
224 | void startInteractivePositionSelection(std::function<void(const QPoint &)> callback); | 223 | void startInteractivePositionSelection(std::function<void(const QPoint &)> callback); | ||
225 | bool isSelectingWindow() const; | 224 | bool isSelectingWindow() const; | ||
226 | 225 | | |||
227 | Q_SIGNALS: | 226 | Q_SIGNALS: | ||
228 | /** | 227 | /** | ||
229 | * @brief Emitted when the global pointer position changed | 228 | * @brief Emitted when the global pointer position changed | ||
230 | * | 229 | * | ||
231 | * @param pos The new global pointer position. | 230 | * @param pos The new global pointer position. | ||
232 | */ | 231 | **/ | ||
233 | void globalPointerChanged(const QPointF &pos); | 232 | void globalPointerChanged(const QPointF &pos); | ||
234 | /** | 233 | /** | ||
235 | * @brief Emitted when the state of a pointer button changed. | 234 | * @brief Emitted when the state of a pointer button changed. | ||
236 | * | 235 | * | ||
237 | * @param button The button which changed | 236 | * @param button The button which changed | ||
238 | * @param state The new button state | 237 | * @param state The new button state | ||
239 | */ | 238 | **/ | ||
240 | void pointerButtonStateChanged(uint32_t button, InputRedirection::PointerButtonState state); | 239 | void pointerButtonStateChanged(uint32_t button, InputRedirection::PointerButtonState state); | ||
241 | /** | 240 | /** | ||
242 | * @brief Emitted when a pointer axis changed | 241 | * @brief Emitted when a pointer axis changed | ||
243 | * | 242 | * | ||
244 | * @param axis The axis on which the even occurred | 243 | * @param axis The axis on which the even occurred | ||
245 | * @param delta The delta of the event. | 244 | * @param delta The delta of the event. | ||
246 | */ | 245 | **/ | ||
247 | void pointerAxisChanged(InputRedirection::PointerAxis axis, qreal delta); | 246 | void pointerAxisChanged(InputRedirection::PointerAxis axis, qreal delta); | ||
248 | /** | 247 | /** | ||
249 | * @brief Emitted when the modifiers changes. | 248 | * @brief Emitted when the modifiers changes. | ||
250 | * | 249 | * | ||
251 | * Only emitted for the mask which is provided by Qt::KeyboardModifiers, if other modifiers | 250 | * Only emitted for the mask which is provided by Qt::KeyboardModifiers, if other modifiers | ||
252 | * change signal is not emitted | 251 | * change signal is not emitted | ||
253 | * | 252 | * | ||
254 | * @param newMods The new modifiers state | 253 | * @param newMods The new modifiers state | ||
255 | * @param oldMods The previous modifiers state | 254 | * @param oldMods The previous modifiers state | ||
256 | */ | 255 | **/ | ||
257 | void keyboardModifiersChanged(Qt::KeyboardModifiers newMods, Qt::KeyboardModifiers oldMods); | 256 | void keyboardModifiersChanged(Qt::KeyboardModifiers newMods, Qt::KeyboardModifiers oldMods); | ||
258 | /** | 257 | /** | ||
259 | * @brief Emitted when the state of a key changed. | 258 | * @brief Emitted when the state of a key changed. | ||
260 | * | 259 | * | ||
261 | * @param keyCode The keycode of the key which changed | 260 | * @param keyCode The keycode of the key which changed | ||
262 | * @param state The new key state | 261 | * @param state The new key state | ||
263 | */ | 262 | **/ | ||
264 | void keyStateChanged(quint32 keyCode, InputRedirection::KeyboardKeyState state); | 263 | void keyStateChanged(quint32 keyCode, InputRedirection::KeyboardKeyState state); | ||
265 | 264 | | |||
266 | void hasAlphaNumericKeyboardChanged(bool set); | 265 | void hasAlphaNumericKeyboardChanged(bool set); | ||
267 | void hasTabletModeSwitchChanged(bool set); | 266 | void hasTabletModeSwitchChanged(bool set); | ||
268 | 267 | | |||
269 | private: | 268 | private: | ||
270 | void setupLibInput(); | 269 | void setupLibInput(); | ||
271 | void setupTouchpadShortcuts(); | 270 | void setupTouchpadShortcuts(); | ||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 371 | public: | |||
374 | virtual void init(); | 373 | virtual void init(); | ||
375 | 374 | | |||
376 | void update(); | 375 | void update(); | ||
377 | 376 | | |||
378 | /** | 377 | /** | ||
379 | * @brief First Toplevel currently at the position of the input device | 378 | * @brief First Toplevel currently at the position of the input device | ||
380 | * according to the stacking order. | 379 | * according to the stacking order. | ||
381 | * @return Toplevel* at device position. | 380 | * @return Toplevel* at device position. | ||
382 | */ | 381 | **/ | ||
383 | QPointer<Toplevel> at() const { | 382 | QPointer<Toplevel> at() const { | ||
384 | return m_at; | 383 | return m_at; | ||
385 | } | 384 | } | ||
386 | /** | 385 | /** | ||
387 | * @brief Toplevel currently having pointer input focus (this might | 386 | * @brief Toplevel currently having pointer input focus (this might | ||
388 | * be different from the Toplevel at the position of the pointer). | 387 | * be different from the Toplevel at the position of the pointer). | ||
389 | * @return Toplevel* with pointer focus. | 388 | * @return Toplevel* with pointer focus. | ||
390 | */ | 389 | **/ | ||
391 | QPointer<Toplevel> focus() const { | 390 | QPointer<Toplevel> focus() const { | ||
392 | return m_focus.focus; | 391 | return m_focus.focus; | ||
393 | } | 392 | } | ||
394 | /** | 393 | /** | ||
395 | * @brief The Decoration currently receiving events. | 394 | * @brief The Decoration currently receiving events. | ||
396 | * @return decoration with pointer focus. | 395 | * @return decoration with pointer focus. | ||
397 | **/ | 396 | **/ | ||
398 | QPointer<Decoration::DecoratedClientImpl> decoration() const { | 397 | QPointer<Decoration::DecoratedClientImpl> decoration() const { | ||
Show All 20 Lines | |||||
419 | protected: | 418 | protected: | ||
420 | explicit InputDeviceHandler(InputRedirection *parent); | 419 | explicit InputDeviceHandler(InputRedirection *parent); | ||
421 | 420 | | |||
422 | virtual void cleanupInternalWindow(QWindow *old, QWindow *now) = 0; | 421 | virtual void cleanupInternalWindow(QWindow *old, QWindow *now) = 0; | ||
423 | virtual void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) = 0; | 422 | virtual void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) = 0; | ||
424 | 423 | | |||
425 | virtual void focusUpdate(Toplevel *old, Toplevel *now) = 0; | 424 | virtual void focusUpdate(Toplevel *old, Toplevel *now) = 0; | ||
426 | 425 | | |||
427 | /* Certain input devices can be in a state of having no valid | 426 | /** | ||
427 | * Certain input devices can be in a state of having no valid | ||||
428 | * position. An example are touch screens when no finger/pen | 428 | * position. An example are touch screens when no finger/pen | ||
429 | * is resting on the surface (no touch point). | 429 | * is resting on the surface (no touch point). | ||
430 | */ | 430 | **/ | ||
431 | virtual bool positionValid() const { | 431 | virtual bool positionValid() const { | ||
432 | return false; | 432 | return false; | ||
433 | } | 433 | } | ||
434 | virtual bool focusUpdatesBlocked() { | 434 | virtual bool focusUpdatesBlocked() { | ||
435 | return false; | 435 | return false; | ||
436 | } | 436 | } | ||
437 | 437 | | |||
438 | inline bool inited() const { | 438 | inline bool inited() const { | ||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |