Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/x11/standalone/xinputintegration.cpp
Show All 18 Lines | |||||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "xinputintegration.h" | 20 | #include "xinputintegration.h" | ||
21 | #include "main.h" | 21 | #include "main.h" | ||
22 | #include "logging.h" | 22 | #include "logging.h" | ||
23 | #include "gestures.h" | 23 | #include "gestures.h" | ||
24 | #include "platform.h" | 24 | #include "platform.h" | ||
25 | #include "screenedge.h" | 25 | #include "screenedge.h" | ||
26 | #include "x11cursor.h" | 26 | #include "x11cursor.h" | ||
27 | #include "ge_event_mem_mover.h" | ||||
27 | 28 | | |||
28 | #include "input.h" | 29 | #include "input.h" | ||
29 | #include "x11eventfilter.h" | 30 | #include "x11eventfilter.h" | ||
30 | #include "modifier_only_shortcuts.h" | 31 | #include "modifier_only_shortcuts.h" | ||
31 | #include <kwinglobals.h> | 32 | #include <kwinglobals.h> | ||
32 | 33 | | |||
33 | #include <X11/extensions/XInput2.h> | 34 | #include <X11/extensions/XInput2.h> | ||
34 | #include <X11/extensions/XI2proto.h> | 35 | #include <X11/extensions/XI2proto.h> | ||
35 | 36 | | |||
36 | #include <linux/input.h> | 37 | #include <linux/input.h> | ||
37 | 38 | | |||
38 | namespace KWin | 39 | namespace KWin | ||
39 | { | 40 | { | ||
40 | 41 | | |||
41 | static inline qreal fixed1616ToReal(FP1616 val) | 42 | static inline qreal fixed1616ToReal(FP1616 val) | ||
42 | { | 43 | { | ||
43 | return (val) * 1.0 / (1 << 16); | 44 | return (val) * 1.0 / (1 << 16); | ||
44 | } | 45 | } | ||
45 | 46 | | |||
46 | class GeEventMemMover | | |||
47 | { | | |||
48 | public: | | |||
49 | GeEventMemMover(xcb_generic_event_t *event) | | |||
50 | : m_event(reinterpret_cast<xcb_ge_generic_event_t *>(event)) | | |||
51 | { | | |||
52 | // xcb event structs contain stuff that wasn't on the wire, the full_sequence field | | |||
53 | // adds an extra 4 bytes and generic events cookie data is on the wire right after the standard 32 bytes. | | |||
54 | // Move this data back to have the same layout in memory as it was on the wire | | |||
55 | // and allow casting, overwriting the full_sequence field. | | |||
56 | memmove((char*) m_event + 32, (char*) m_event + 36, m_event->length * 4); | | |||
57 | } | | |||
58 | ~GeEventMemMover() | | |||
59 | { | | |||
60 | // move memory layout back, so that Qt can do the same without breaking | | |||
61 | memmove((char*) m_event + 36, (char *) m_event + 32, m_event->length * 4); | | |||
62 | } | | |||
63 | | ||||
64 | xcb_ge_generic_event_t *operator->() const { | | |||
65 | return m_event; | | |||
66 | } | | |||
67 | | ||||
68 | private: | | |||
69 | xcb_ge_generic_event_t *m_event; | | |||
70 | }; | | |||
71 | | ||||
72 | class XInputEventFilter : public X11EventFilter | 47 | class XInputEventFilter : public X11EventFilter | ||
73 | { | 48 | { | ||
74 | public: | 49 | public: | ||
75 | XInputEventFilter(int xi_opcode) | 50 | XInputEventFilter(int xi_opcode) | ||
76 | : X11EventFilter(XCB_GE_GENERIC, xi_opcode, QVector<int>{XI_RawMotion, XI_RawButtonPress, XI_RawButtonRelease, XI_RawKeyPress, XI_RawKeyRelease, XI_TouchBegin, XI_TouchUpdate, XI_TouchOwnership, XI_TouchEnd}) | 51 | : X11EventFilter(XCB_GE_GENERIC, xi_opcode, QVector<int>{XI_RawMotion, XI_RawButtonPress, XI_RawButtonRelease, XI_RawKeyPress, XI_RawKeyRelease, XI_TouchBegin, XI_TouchUpdate, XI_TouchOwnership, XI_TouchEnd}) | ||
77 | {} | 52 | {} | ||
78 | virtual ~XInputEventFilter() = default; | 53 | virtual ~XInputEventFilter() = default; | ||
79 | 54 | | |||
▲ Show 20 Lines • Show All 233 Lines • Show Last 20 Lines |