Changeset View
Changeset View
Standalone View
Standalone View
pointer_input.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
54 | // Wayland | 54 | // Wayland | ||
55 | #include <wayland-cursor.h> | 55 | #include <wayland-cursor.h> | ||
56 | 56 | | |||
57 | #include <linux/input.h> | 57 | #include <linux/input.h> | ||
58 | 58 | | |||
59 | namespace KWin | 59 | namespace KWin | ||
60 | { | 60 | { | ||
61 | 61 | | |||
62 | static Qt::MouseButton buttonToQtMouseButton(uint32_t button) | 62 | static const QHash<uint32_t, Qt::MouseButton> s_buttonToQtMouseButton = { | ||
63 | { | 63 | { BTN_LEFT , Qt::LeftButton }, | ||
64 | switch (button) { | 64 | { BTN_MIDDLE , Qt::MiddleButton }, | ||
65 | case BTN_LEFT: | 65 | { BTN_RIGHT , Qt::RightButton }, | ||
66 | return Qt::LeftButton; | | |||
67 | case BTN_MIDDLE: | | |||
68 | return Qt::MiddleButton; | | |||
69 | case BTN_RIGHT: | | |||
70 | return Qt::RightButton; | | |||
71 | case BTN_SIDE: | | |||
72 | // in QtWayland mapped like that | 66 | // in QtWayland mapped like that | ||
73 | return Qt::ExtraButton1; | 67 | { BTN_SIDE , Qt::ExtraButton1 }, | ||
74 | case BTN_EXTRA: | | |||
75 | // in QtWayland mapped like that | 68 | // in QtWayland mapped like that | ||
76 | return Qt::ExtraButton2; | 69 | { BTN_EXTRA , Qt::ExtraButton2 }, | ||
77 | case BTN_BACK: | 70 | { BTN_BACK , Qt::BackButton }, | ||
78 | return Qt::BackButton; | 71 | { BTN_FORWARD , Qt::ForwardButton }, | ||
79 | case BTN_FORWARD: | 72 | { BTN_TASK , Qt::TaskButton }, | ||
80 | return Qt::ForwardButton; | | |||
81 | case BTN_TASK: | | |||
82 | return Qt::TaskButton; | | |||
83 | // mapped like that in QtWayland | 73 | // mapped like that in QtWayland | ||
84 | case 0x118: | 74 | { 0x118 , Qt::ExtraButton6 }, | ||
85 | return Qt::ExtraButton6; | 75 | { 0x119 , Qt::ExtraButton7 }, | ||
86 | case 0x119: | 76 | { 0x11a , Qt::ExtraButton8 }, | ||
87 | return Qt::ExtraButton7; | 77 | { 0x11b , Qt::ExtraButton9 }, | ||
88 | case 0x11a: | 78 | { 0x11c , Qt::ExtraButton10 }, | ||
89 | return Qt::ExtraButton8; | 79 | { 0x11d , Qt::ExtraButton11 }, | ||
90 | case 0x11b: | 80 | { 0x11e , Qt::ExtraButton12 }, | ||
91 | return Qt::ExtraButton9; | 81 | { 0x11f , Qt::ExtraButton13 }, | ||
92 | case 0x11c: | 82 | }; | ||
93 | return Qt::ExtraButton10; | 83 | | ||
94 | case 0x11d: | 84 | static Qt::MouseButton buttonToQtMouseButton(uint32_t button) | ||
95 | return Qt::ExtraButton11; | 85 | { | ||
96 | case 0x11e: | | |||
97 | return Qt::ExtraButton12; | | |||
98 | case 0x11f: | | |||
99 | return Qt::ExtraButton13; | | |||
100 | } | | |||
101 | // all other values get mapped to ExtraButton24 | 86 | // all other values get mapped to ExtraButton24 | ||
102 | // this is actually incorrect but doesn't matter in our usage | 87 | // this is actually incorrect but doesn't matter in our usage | ||
103 | // KWin internally doesn't use these high extra buttons anyway | 88 | // KWin internally doesn't use these high extra buttons anyway | ||
104 | // it's only needed for recognizing whether buttons are pressed | 89 | // it's only needed for recognizing whether buttons are pressed | ||
105 | // if multiple buttons are mapped to the value the evaluation whether | 90 | // if multiple buttons are mapped to the value the evaluation whether | ||
106 | // buttons are pressed is correct and that's all we care about. | 91 | // buttons are pressed is correct and that's all we care about. | ||
107 | return Qt::ExtraButton24; | 92 | return s_buttonToQtMouseButton.value(button, Qt::ExtraButton24); | ||
93 | } | ||||
108 | } | 94 | } | ||
109 | 95 | | |||
110 | static bool screenContainsPos(const QPointF &pos) | 96 | static bool screenContainsPos(const QPointF &pos) | ||
111 | { | 97 | { | ||
112 | for (int i = 0; i < screens()->count(); ++i) { | 98 | for (int i = 0; i < screens()->count(); ++i) { | ||
113 | if (screens()->geometry(i).contains(pos.toPoint())) { | 99 | if (screens()->geometry(i).contains(pos.toPoint())) { | ||
114 | return true; | 100 | return true; | ||
115 | } | 101 | } | ||
▲ Show 20 Lines • Show All 1295 Lines • Show Last 20 Lines |