Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | struct XInput2TouchDeviceData { | - | ||||||||||||||||||
6 | XInput2TouchDeviceData() | - | ||||||||||||||||||
7 | : xiDeviceInfo(0) | - | ||||||||||||||||||
8 | , qtTouchDevice(0) | - | ||||||||||||||||||
9 | , providesTouchOrientation(false) | - | ||||||||||||||||||
10 | { | - | ||||||||||||||||||
11 | } | - | ||||||||||||||||||
12 | XIDeviceInfo *xiDeviceInfo; | - | ||||||||||||||||||
13 | QTouchDevice *qtTouchDevice; | - | ||||||||||||||||||
14 | QHash<int, QWindowSystemInterface::TouchPoint> touchPoints; | - | ||||||||||||||||||
15 | - | |||||||||||||||||||
16 | - | |||||||||||||||||||
17 | QHash<int, QPointF> pointPressedPosition; | - | ||||||||||||||||||
18 | QPointF firstPressedPosition; | - | ||||||||||||||||||
19 | QPointF firstPressedNormalPosition; | - | ||||||||||||||||||
20 | QSizeF size; | - | ||||||||||||||||||
21 | bool providesTouchOrientation; | - | ||||||||||||||||||
22 | }; | - | ||||||||||||||||||
23 | - | |||||||||||||||||||
24 | void QXcbConnection::initializeXInput2() | - | ||||||||||||||||||
25 | { | - | ||||||||||||||||||
26 | - | |||||||||||||||||||
27 | if (qEnvironmentVariableIsSet("QT_XCB_DEBUG_XINPUT")) | - | ||||||||||||||||||
28 | const_cast<QLoggingCategory&>(lcQpaXInput()).setEnabled(QtDebugMsg, true); | - | ||||||||||||||||||
29 | if (qEnvironmentVariableIsSet("QT_XCB_DEBUG_XINPUT_DEVICES")) | - | ||||||||||||||||||
30 | const_cast<QLoggingCategory&>(lcQpaXInputDevices()).setEnabled(QtDebugMsg, true); | - | ||||||||||||||||||
31 | Display *xDisplay = static_cast<Display *>(m_xlib_display); | - | ||||||||||||||||||
32 | if (XQueryExtension(xDisplay, "XInputExtension", &m_xiOpCode, &m_xiEventBase, &m_xiErrorBase)) { | - | ||||||||||||||||||
33 | int xiMajor = 2; | - | ||||||||||||||||||
34 | m_xi2Minor = 2; | - | ||||||||||||||||||
35 | if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == 1) { | - | ||||||||||||||||||
36 | m_xi2Minor = 1; | - | ||||||||||||||||||
37 | if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == 1) { | - | ||||||||||||||||||
38 | m_xi2Minor = 0; | - | ||||||||||||||||||
39 | m_xi2Enabled = XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) != 1; | - | ||||||||||||||||||
40 | } else | - | ||||||||||||||||||
41 | m_xi2Enabled = true; | - | ||||||||||||||||||
42 | } else | - | ||||||||||||||||||
43 | m_xi2Enabled = true; | - | ||||||||||||||||||
44 | if (m_xi2Enabled) { | - | ||||||||||||||||||
45 | - | |||||||||||||||||||
46 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 8995, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug("XInput version %d.%d is available and Qt supports 2.2 or greater", xiMajor, m_xi2Minor); | - | ||||||||||||||||||
47 | - | |||||||||||||||||||
48 | - | |||||||||||||||||||
49 | - | |||||||||||||||||||
50 | } | - | ||||||||||||||||||
51 | - | |||||||||||||||||||
52 | xi2SetupDevices(); | - | ||||||||||||||||||
53 | } | - | ||||||||||||||||||
54 | } | - | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | void QXcbConnection::xi2SetupDevices() | - | ||||||||||||||||||
57 | { | - | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | m_tabletData.clear(); | - | ||||||||||||||||||
60 | - | |||||||||||||||||||
61 | m_scrollingDevices.clear(); | - | ||||||||||||||||||
62 | - | |||||||||||||||||||
63 | if (!m_xi2Enabled) | - | ||||||||||||||||||
64 | return; | - | ||||||||||||||||||
65 | - | |||||||||||||||||||
66 | Display *xDisplay = static_cast<Display *>(m_xlib_display); | - | ||||||||||||||||||
67 | int deviceCount = 0; | - | ||||||||||||||||||
68 | XIDeviceInfo *devices = XIQueryDevice(xDisplay, 0, &deviceCount); | - | ||||||||||||||||||
69 | for (int i = 0; i < deviceCount; ++i) { | - | ||||||||||||||||||
70 | - | |||||||||||||||||||
71 | if (devices[i].use != 3) | - | ||||||||||||||||||
72 | continue; | - | ||||||||||||||||||
73 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 116122, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug() << "input device " << devices[i].name << "ID" << devices[i].deviceid; | - | ||||||||||||||||||
74 | - | |||||||||||||||||||
75 | TabletData tabletData; | - | ||||||||||||||||||
76 | - | |||||||||||||||||||
77 | ScrollingDevice scrollingDevice; | - | ||||||||||||||||||
78 | for (int c = 0; c < devices[i].num_classes; ++c) { | - | ||||||||||||||||||
79 | switch (devices[i].classes[c]->type) { | - | ||||||||||||||||||
80 | case 2: { | - | ||||||||||||||||||
81 | XIValuatorClassInfo *vci = reinterpret_cast<XIValuatorClassInfo *>(devices[i].classes[c]); | - | ||||||||||||||||||
82 | const int valuatorAtom = qatom(vci->label); | - | ||||||||||||||||||
83 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 126132, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug() << " has valuator" << atomName(vci->label) << "recognized?" << (valuatorAtom < QXcbAtom::NAtoms); | - | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | if (valuatorAtom < QXcbAtom::NAtoms) { | - | ||||||||||||||||||
86 | TabletData::ValuatorClassInfo info; | - | ||||||||||||||||||
87 | info.minVal = vci->min; | - | ||||||||||||||||||
88 | info.maxVal = vci->max; | - | ||||||||||||||||||
89 | info.number = vci->number; | - | ||||||||||||||||||
90 | tabletData.valuatorInfo[valuatorAtom] = info; | - | ||||||||||||||||||
91 | } | - | ||||||||||||||||||
92 | - | |||||||||||||||||||
93 | if (valuatorAtom == QXcbAtom::RelHorizScroll || valuatorAtom == QXcbAtom::RelHorizWheel) | - | ||||||||||||||||||
94 | scrollingDevice.lastScrollPosition.setX(vci->value); | - | ||||||||||||||||||
95 | else if (valuatorAtom == QXcbAtom::RelVertScroll || valuatorAtom == QXcbAtom::RelVertWheel) | - | ||||||||||||||||||
96 | scrollingDevice.lastScrollPosition.setY(vci->value); | - | ||||||||||||||||||
97 | break; | - | ||||||||||||||||||
98 | } | - | ||||||||||||||||||
99 | - | |||||||||||||||||||
100 | case 3: { | - | ||||||||||||||||||
101 | XIScrollClassInfo *sci = reinterpret_cast<XIScrollClassInfo *>(devices[i].classes[c]); | - | ||||||||||||||||||
102 | if (sci->scroll_type == 1) { | - | ||||||||||||||||||
103 | scrollingDevice.orientations |= Qt::Vertical; | - | ||||||||||||||||||
104 | scrollingDevice.verticalIndex = sci->number; | - | ||||||||||||||||||
105 | scrollingDevice.verticalIncrement = sci->increment; | - | ||||||||||||||||||
106 | } | - | ||||||||||||||||||
107 | else if (sci->scroll_type == 2) { | - | ||||||||||||||||||
108 | scrollingDevice.orientations |= Qt::Horizontal; | - | ||||||||||||||||||
109 | scrollingDevice.horizontalIndex = sci->number; | - | ||||||||||||||||||
110 | scrollingDevice.horizontalIncrement = sci->increment; | - | ||||||||||||||||||
111 | } | - | ||||||||||||||||||
112 | break; | - | ||||||||||||||||||
113 | } | - | ||||||||||||||||||
114 | case 1: { | - | ||||||||||||||||||
115 | XIButtonClassInfo *bci = reinterpret_cast<XIButtonClassInfo *>(devices[i].classes[c]); | - | ||||||||||||||||||
116 | if (bci->num_buttons >= 5) { | - | ||||||||||||||||||
117 | Atom label4 = bci->labels[3]; | - | ||||||||||||||||||
118 | Atom label5 = bci->labels[4]; | - | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | - | |||||||||||||||||||
121 | if ((!label4 || qatom(label4) == QXcbAtom::ButtonWheelUp || qatom(label4) == QXcbAtom::ButtonWheelDown) && | - | ||||||||||||||||||
122 | (!label5 || qatom(label5) == QXcbAtom::ButtonWheelUp || qatom(label5) == QXcbAtom::ButtonWheelDown)) | - | ||||||||||||||||||
123 | scrollingDevice.legacyOrientations |= Qt::Vertical; | - | ||||||||||||||||||
124 | } | - | ||||||||||||||||||
125 | if (bci->num_buttons >= 7) { | - | ||||||||||||||||||
126 | Atom label6 = bci->labels[5]; | - | ||||||||||||||||||
127 | Atom label7 = bci->labels[6]; | - | ||||||||||||||||||
128 | if ((!label6 || qatom(label6) == QXcbAtom::ButtonHorizWheelLeft) && (!label7 || qatom(label7) == QXcbAtom::ButtonHorizWheelRight)) | - | ||||||||||||||||||
129 | scrollingDevice.legacyOrientations |= Qt::Horizontal; | - | ||||||||||||||||||
130 | } | - | ||||||||||||||||||
131 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 174180, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug(" has %d buttons", bci->num_buttons); | - | ||||||||||||||||||
132 | break; | - | ||||||||||||||||||
133 | } | - | ||||||||||||||||||
134 | - | |||||||||||||||||||
135 | case 0: | - | ||||||||||||||||||
136 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 179185, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug() << " it's a keyboard"; | - | ||||||||||||||||||
137 | break; | - | ||||||||||||||||||
138 | - | |||||||||||||||||||
139 | case 8: | - | ||||||||||||||||||
140 | - | |||||||||||||||||||
141 | break; | - | ||||||||||||||||||
142 | - | |||||||||||||||||||
143 | default: | - | ||||||||||||||||||
144 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 187193, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug() << " has class" << devices[i].classes[c]->type; | - | ||||||||||||||||||
145 | break; | - | ||||||||||||||||||
146 | } | - | ||||||||||||||||||
147 | } | - | ||||||||||||||||||
148 | bool isTablet = false; | - | ||||||||||||||||||
149 | - | |||||||||||||||||||
150 | - | |||||||||||||||||||
151 | if (tabletData.valuatorInfo.contains(QXcbAtom::AbsX) && | - | ||||||||||||||||||
152 | tabletData.valuatorInfo.contains(QXcbAtom::AbsY) && | - | ||||||||||||||||||
153 | tabletData.valuatorInfo.contains(QXcbAtom::AbsPressure)) | - | ||||||||||||||||||
154 | isTablet = true; | - | ||||||||||||||||||
155 | - | |||||||||||||||||||
156 | - | |||||||||||||||||||
157 | QByteArray name = QByteArray(devices[i].name).toLower(); | - | ||||||||||||||||||
158 | QString dbgType = QLatin1String("UNKNOWN"); | - | ||||||||||||||||||
159 | if (name.contains("eraser")) { | - | ||||||||||||||||||
160 | isTablet = true; | - | ||||||||||||||||||
161 | tabletData.pointerType = QTabletEvent::Eraser; | - | ||||||||||||||||||
162 | dbgType = QLatin1String("eraser"); | - | ||||||||||||||||||
163 | } else if (name.contains("cursor")) { | - | ||||||||||||||||||
164 | isTablet = true; | - | ||||||||||||||||||
165 | tabletData.pointerType = QTabletEvent::Cursor; | - | ||||||||||||||||||
166 | dbgType = QLatin1String("cursor"); | - | ||||||||||||||||||
167 | } else if ((name.contains("pen") || name.contains("stylus")) && isTablet) { | - | ||||||||||||||||||
168 | tabletData.pointerType = QTabletEvent::Pen; | - | ||||||||||||||||||
169 | dbgType = QLatin1String("pen"); | - | ||||||||||||||||||
170 | } else if (name.contains("wacom") && isTablet && !name.contains("touch")) { | - | ||||||||||||||||||
171 | - | |||||||||||||||||||
172 | tabletData.pointerType = QTabletEvent::Pen; | - | ||||||||||||||||||
173 | dbgType = QLatin1String("pen"); | - | ||||||||||||||||||
174 | } else if (name.contains("aiptek") ) { | - | ||||||||||||||||||
175 | - | |||||||||||||||||||
176 | isTablet = true; | - | ||||||||||||||||||
177 | tabletData.pointerType = QTabletEvent::Pen; | - | ||||||||||||||||||
178 | dbgType = QLatin1String("pen"); | - | ||||||||||||||||||
179 | } else if (name.contains("waltop") && name.contains("tablet")) { | - | ||||||||||||||||||
180 | - | |||||||||||||||||||
181 | - | |||||||||||||||||||
182 | isTablet = true; | - | ||||||||||||||||||
183 | tabletData.pointerType = QTabletEvent::Pen; | - | ||||||||||||||||||
184 | dbgType = QLatin1String("pen"); | - | ||||||||||||||||||
185 | } else { | - | ||||||||||||||||||
186 | isTablet = false; | - | ||||||||||||||||||
187 | } | - | ||||||||||||||||||
188 | - | |||||||||||||||||||
189 | if (isTablet) { | - | ||||||||||||||||||
190 | tabletData.deviceId = devices[i].deviceid; | - | ||||||||||||||||||
191 | m_tabletData.append(tabletData); | - | ||||||||||||||||||
192 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 235241, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug() << " it's a tablet with pointer type" << dbgType; | - | ||||||||||||||||||
193 | } | - | ||||||||||||||||||
194 | - | |||||||||||||||||||
195 | - | |||||||||||||||||||
196 | - | |||||||||||||||||||
197 | if (scrollingDevice.orientations || scrollingDevice.legacyOrientations) { | - | ||||||||||||||||||
198 | scrollingDevice.deviceId = devices[i].deviceid; | - | ||||||||||||||||||
199 | - | |||||||||||||||||||
200 | scrollingDevice.legacyOrientations &= ~scrollingDevice.orientations; | - | ||||||||||||||||||
201 | m_scrollingDevices.insert(scrollingDevice.deviceId, scrollingDevice); | - | ||||||||||||||||||
202 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 245251, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug() << " it's a scrolling device"; | - | ||||||||||||||||||
203 | } | - | ||||||||||||||||||
204 | - | |||||||||||||||||||
205 | - | |||||||||||||||||||
206 | if (!isTablet) { | - | ||||||||||||||||||
207 | - | |||||||||||||||||||
208 | - | |||||||||||||||||||
209 | XInput2TouchDeviceData *dev = touchDeviceForId(devices[i].deviceid); | - | ||||||||||||||||||
210 | if (dev && lcQpaXInputDevices().isDebugEnabled()) { | - | ||||||||||||||||||
211 | if (dev->qtTouchDevice->type() == QTouchDevice::TouchScreen) | - | ||||||||||||||||||
212 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger( | - | ||||||||||||||||||
213 | - | |||||||||||||||||||
214 | __FILE__ | - | ||||||||||||||||||
215 | , | - | ||||||||||||||||||
216 | - | |||||||||||||||||||
217 | 257263 | - | ||||||||||||||||||
218 | , __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug(" it's a touchscreen with type %d capabilities 0x%X max touch points %d", dev->qtTouchDevice->type(), (unsigned int)dev->qtTouchDevice->capabilities(), dev->qtTouchDevice->maximumTouchPoints()) | - | ||||||||||||||||||
219 | - | |||||||||||||||||||
220 | ; | - | ||||||||||||||||||
221 | else if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad) | - | ||||||||||||||||||
222 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger( | - | ||||||||||||||||||
223 | - | |||||||||||||||||||
224 | - | |||||||||||||||||||
225 | __FILE__ | - | ||||||||||||||||||
226 | , | - | ||||||||||||||||||
227 | - | |||||||||||||||||||
228 | - | |||||||||||||||||||
229 | 262268 | - | ||||||||||||||||||
230 | , __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug(" it's a touchpad with type %d capabilities 0x%X max touch points %d size %f x %f", dev->qtTouchDevice->type(), (unsigned int)dev->qtTouchDevice->capabilities(), dev->qtTouchDevice->maximumTouchPoints(), dev->size.width(), dev->size.height()) | - | ||||||||||||||||||
231 | - | |||||||||||||||||||
232 | - | |||||||||||||||||||
233 | ; | - | ||||||||||||||||||
234 | } | - | ||||||||||||||||||
235 | } | - | ||||||||||||||||||
236 | } | - | ||||||||||||||||||
237 | XIFreeDeviceInfo(devices); | - | ||||||||||||||||||
238 | } | - | ||||||||||||||||||
239 | - | |||||||||||||||||||
240 | void QXcbConnection::finalizeXInput2() | - | ||||||||||||||||||
241 | { | - | ||||||||||||||||||
242 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_touchDevices)>::type> _container_((m_touchDevices)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (XInput2TouchDeviceData *dev = *_container_.i; _container_.control; _container_.control = 0): qAsConst(m_touchDevices)) { | - | ||||||||||||||||||
243 | if (dev->xiDeviceInfo
| 0 | ||||||||||||||||||
244 | XIFreeDeviceInfo(dev->xiDeviceInfo); never executed: XIFreeDeviceInfo(dev->xiDeviceInfo); | 0 | ||||||||||||||||||
245 | delete dev; | - | ||||||||||||||||||
246 | } never executed: end of block | 0 | ||||||||||||||||||
247 | } executed 347 times by 219 tests: end of block Executed by:
| 347 | ||||||||||||||||||
248 | - | |||||||||||||||||||
249 | void QXcbConnection::xi2Select(xcb_window_t window) | - | ||||||||||||||||||
250 | { | - | ||||||||||||||||||
251 | if (!m_xi2Enabled
| 0-4107 | ||||||||||||||||||
252 | return; never executed: return; | 0 | ||||||||||||||||||
253 | - | |||||||||||||||||||
254 | Display *xDisplay = static_cast<Display *>(m_xlib_display); | - | ||||||||||||||||||
255 | unsigned int bitMask = 0; | - | ||||||||||||||||||
256 | unsigned char *xiBitMask = reinterpret_cast<unsigned char *>(&bitMask); | - | ||||||||||||||||||
257 | - | |||||||||||||||||||
258 | - | |||||||||||||||||||
259 | if (isAtLeastXI22()
| 0-4107 | ||||||||||||||||||
260 | bitMask |= (1 << 18); | - | ||||||||||||||||||
261 | bitMask |= (1 << 19); | - | ||||||||||||||||||
262 | bitMask |= (1 << 20); | - | ||||||||||||||||||
263 | bitMask |= (1 << 12); | - | ||||||||||||||||||
264 | if (xi2MouseEvents()
| 0-4107 | ||||||||||||||||||
265 | - | |||||||||||||||||||
266 | - | |||||||||||||||||||
267 | bitMask |= (1 << 4); | - | ||||||||||||||||||
268 | bitMask |= (1 << 5); | - | ||||||||||||||||||
269 | bitMask |= (1 << 6); | - | ||||||||||||||||||
270 | - | |||||||||||||||||||
271 | - | |||||||||||||||||||
272 | bitMask |= (1 << 7); | - | ||||||||||||||||||
273 | bitMask |= (1 << 8); | - | ||||||||||||||||||
274 | - | |||||||||||||||||||
275 | for (bool qt_category_enabled = lcQpaXInput().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 310, __PRETTY_FUNCTION__, lcQpaXInput().categoryName()).debug("XInput 2.2: Selecting press/release/motion events in addition to touch"); | 0-4107 | ||||||||||||||||||
276 | } executed 4107 times by 125 tests: end of block Executed by:
| 4107 | ||||||||||||||||||
277 | XIEventMask mask; | - | ||||||||||||||||||
278 | mask.mask_len = sizeof(bitMask); | - | ||||||||||||||||||
279 | mask.mask = xiBitMask; | - | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | - | |||||||||||||||||||
282 | - | |||||||||||||||||||
283 | mask.deviceid = 1; | - | ||||||||||||||||||
284 | int result = XISelectEvents(xDisplay, window, &mask, 1); | - | ||||||||||||||||||
285 | if (result !=== 0
| 0-4107 | ||||||||||||||||||
286 | QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false); executed 4107 times by 125 tests: QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false); Executed by:
| 4107 | ||||||||||||||||||
287 | else | - | ||||||||||||||||||
288 | for (bool qt_category_enabled = lcQpaXInput().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 323, __PRETTY_FUNCTION__, lcQpaXInput().categoryName()).debug("XInput 2.2: failed to select pointer/touch events, window %x, result %d", window, result); | 0 | ||||||||||||||||||
289 | } executed 4107 times by 125 tests: end of block Executed by:
| 4107 | ||||||||||||||||||
290 | - | |||||||||||||||||||
291 | const bool pointerSelected = isAtLeastXI22()
| 0-4107 | ||||||||||||||||||
292 | - | |||||||||||||||||||
293 | - | |||||||||||||||||||
294 | - | |||||||||||||||||||
295 | - | |||||||||||||||||||
296 | QSet<int> tabletDevices; | - | ||||||||||||||||||
297 | - | |||||||||||||||||||
298 | if (!m_tabletData.isEmpty()
| 0-4107 | ||||||||||||||||||
299 | unsigned int tabletBitMask; | - | ||||||||||||||||||
300 | unsigned char *xiTabletBitMask = reinterpret_cast<unsigned char *>(&tabletBitMask); | - | ||||||||||||||||||
301 | QVector<XIEventMask> xiEventMask(m_tabletData.count()); | - | ||||||||||||||||||
302 | tabletBitMask = (1 << 12); | - | ||||||||||||||||||
303 | if (!pointerSelected
| 0 | ||||||||||||||||||
304 | tabletBitMask |= (1 << 4) | (1 << 5) | (1 << 6); never executed: tabletBitMask |= (1 << 4) | (1 << 5) | (1 << 6); | 0 | ||||||||||||||||||
305 | for (int i = 0; i < m_tabletData.count()
| 0 | ||||||||||||||||||
306 | int deviceId = m_tabletData.at(i).deviceId; | - | ||||||||||||||||||
307 | tabletDevices.insert(deviceId); | - | ||||||||||||||||||
308 | xiEventMask[i].deviceid = deviceId; | - | ||||||||||||||||||
309 | xiEventMask[i].mask_len = sizeof(tabletBitMask); | - | ||||||||||||||||||
310 | xiEventMask[i].mask = xiTabletBitMask; | - | ||||||||||||||||||
311 | } never executed: end of block | 0 | ||||||||||||||||||
312 | XISelectEvents(xDisplay, window, xiEventMask.data(), m_tabletData.count()); | - | ||||||||||||||||||
313 | } never executed: end of block | 0 | ||||||||||||||||||
314 | - | |||||||||||||||||||
315 | - | |||||||||||||||||||
316 | - | |||||||||||||||||||
317 | - | |||||||||||||||||||
318 | if (!m_scrollingDevices.isEmpty()
| 0-4107 | ||||||||||||||||||
319 | - | |||||||||||||||||||
320 | QVector<XIEventMask> xiEventMask(m_scrollingDevices.size()); | - | ||||||||||||||||||
321 | unsigned int scrollBitMask; | - | ||||||||||||||||||
322 | unsigned char *xiScrollBitMask = reinterpret_cast<unsigned char *>(&scrollBitMask); | - | ||||||||||||||||||
323 | - | |||||||||||||||||||
324 | scrollBitMask = (1 << 6); | - | ||||||||||||||||||
325 | scrollBitMask |= (1 << 5); | - | ||||||||||||||||||
326 | int i=0; | - | ||||||||||||||||||
for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_scrollingDevices)>::type> _container_((m_scrollingDevices)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||
327 | ++_container_.i, _container_.control ^= 1)for (const ScrollingDevice& scrollingDevice = *_container_.i; _container_.control; _container_.control = 0): qAsConst(m_scrollingDevices)) { | - | ||||||||||||||||||
328 | if (tabletDevices.contains(scrollingDevice.deviceId)
| 0 | ||||||||||||||||||
329 | continue; never executed: continue; | 0 | ||||||||||||||||||
330 | xiEventMask[i].deviceid = scrollingDevice.deviceId; | - | ||||||||||||||||||
331 | xiEventMask[i].mask_len = sizeof(scrollBitMask); | - | ||||||||||||||||||
332 | xiEventMask[i].mask = xiScrollBitMask; | - | ||||||||||||||||||
333 | i++; | - | ||||||||||||||||||
334 | } never executed: end of block | 0 | ||||||||||||||||||
335 | XISelectEvents(xDisplay, window, xiEventMask.data(), i); | - | ||||||||||||||||||
336 | } never executed: end of block | 0 | ||||||||||||||||||
337 | - | |||||||||||||||||||
338 | - | |||||||||||||||||||
339 | - | |||||||||||||||||||
340 | - | |||||||||||||||||||
341 | { | - | ||||||||||||||||||
342 | - | |||||||||||||||||||
343 | XIEventMask xiEventMask; | - | ||||||||||||||||||
344 | bitMask = (1 << 11); | - | ||||||||||||||||||
345 | bitMask |= (1 << 1); | - | ||||||||||||||||||
346 | xiEventMask.deviceid = 0; | - | ||||||||||||||||||
347 | xiEventMask.mask_len = sizeof(bitMask); | - | ||||||||||||||||||
348 | xiEventMask.mask = xiBitMask; | - | ||||||||||||||||||
349 | XISelectEvents(xDisplay, window, &xiEventMask, 1); | - | ||||||||||||||||||
350 | } | - | ||||||||||||||||||
351 | } executed 4107 times by 125 tests: end of block Executed by:
| 4107 | ||||||||||||||||||
352 | - | |||||||||||||||||||
353 | XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id) | - | ||||||||||||||||||
354 | { | - | ||||||||||||||||||
355 | XInput2TouchDeviceData *dev = nullptr; | - | ||||||||||||||||||
356 | QHash<int, XInput2TouchDeviceData*>::const_iterator devIt = m_touchDevices.constFind(id); | - | ||||||||||||||||||
357 | if (devIt != m_touchDevices.cend()) { | - | ||||||||||||||||||
358 | dev = devIt.value(); | - | ||||||||||||||||||
359 | } else { | - | ||||||||||||||||||
360 | int nrDevices = 0; | - | ||||||||||||||||||
361 | QTouchDevice::Capabilities caps = 0; | - | ||||||||||||||||||
362 | dev = new XInput2TouchDeviceData; | - | ||||||||||||||||||
363 | dev->xiDeviceInfo = XIQueryDevice(static_cast<Display *>(m_xlib_display), id, &nrDevices); | - | ||||||||||||||||||
364 | if (nrDevices <= 0) { | - | ||||||||||||||||||
365 | delete dev; | - | ||||||||||||||||||
366 | return 0; | - | ||||||||||||||||||
367 | } | - | ||||||||||||||||||
368 | int type = -1; | - | ||||||||||||||||||
369 | int maxTouchPoints = 1; | - | ||||||||||||||||||
370 | bool hasRelativeCoords = false; | - | ||||||||||||||||||
371 | for (int i = 0; i < dev->xiDeviceInfo->num_classes; ++i) { | - | ||||||||||||||||||
372 | XIAnyClassInfo *classinfo = dev->xiDeviceInfo->classes[i]; | - | ||||||||||||||||||
373 | switch (classinfo->type) { | - | ||||||||||||||||||
374 | - | |||||||||||||||||||
375 | case 8: { | - | ||||||||||||||||||
376 | XITouchClassInfo *tci = reinterpret_cast<XITouchClassInfo *>(classinfo); | - | ||||||||||||||||||
377 | maxTouchPoints = tci->num_touches; | - | ||||||||||||||||||
378 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 406413, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug(" has touch class with mode %d", tci->mode); | - | ||||||||||||||||||
379 | switch (tci->mode) { | - | ||||||||||||||||||
380 | case 2: | - | ||||||||||||||||||
381 | type = QTouchDevice::TouchPad; | - | ||||||||||||||||||
382 | break; | - | ||||||||||||||||||
383 | case 1: | - | ||||||||||||||||||
384 | type = QTouchDevice::TouchScreen; | - | ||||||||||||||||||
385 | break; | - | ||||||||||||||||||
386 | } | - | ||||||||||||||||||
387 | break; | - | ||||||||||||||||||
388 | } | - | ||||||||||||||||||
389 | - | |||||||||||||||||||
390 | case 2: { | - | ||||||||||||||||||
391 | XIValuatorClassInfo *vci = reinterpret_cast<XIValuatorClassInfo *>(classinfo); | - | ||||||||||||||||||
392 | - | |||||||||||||||||||
393 | - | |||||||||||||||||||
394 | const int vciResolution = vci->resolution ? vci->resolution : 1; | - | ||||||||||||||||||
395 | if (vci->label == atom(QXcbAtom::AbsMTPositionX)) | - | ||||||||||||||||||
396 | caps |= QTouchDevice::Position | QTouchDevice::NormalizedPosition; | - | ||||||||||||||||||
397 | else if (vci->label == atom(QXcbAtom::AbsMTTouchMajor)) | - | ||||||||||||||||||
398 | caps |= QTouchDevice::Area; | - | ||||||||||||||||||
399 | else if (vci->label == atom(QXcbAtom::AbsMTOrientation)) | - | ||||||||||||||||||
400 | dev->providesTouchOrientation = true; | - | ||||||||||||||||||
401 | else if (vci->label == atom(QXcbAtom::AbsMTPressure) || vci->label == atom(QXcbAtom::AbsPressure)) | - | ||||||||||||||||||
402 | caps |= QTouchDevice::Pressure; | - | ||||||||||||||||||
403 | else if (vci->label == atom(QXcbAtom::RelX)) { | - | ||||||||||||||||||
404 | hasRelativeCoords = true; | - | ||||||||||||||||||
405 | dev->size.setWidth((vci->max - vci->min) * 1000.0 / vciResolution); | - | ||||||||||||||||||
406 | } else if (vci->label == atom(QXcbAtom::RelY)) { | - | ||||||||||||||||||
407 | hasRelativeCoords = true; | - | ||||||||||||||||||
408 | dev->size.setHeight((vci->max - vci->min) * 1000.0 / vciResolution); | - | ||||||||||||||||||
409 | } else if (vci->label == atom(QXcbAtom::AbsX)) { | - | ||||||||||||||||||
410 | caps |= QTouchDevice::Position; | - | ||||||||||||||||||
411 | dev->size.setHeight((vci->max - vci->min) * 1000.0 / vciResolution); | - | ||||||||||||||||||
412 | } else if (vci->label == atom(QXcbAtom::AbsY)) { | - | ||||||||||||||||||
413 | caps |= QTouchDevice::Position; | - | ||||||||||||||||||
414 | dev->size.setWidth((vci->max - vci->min) * 1000.0 / vciResolution); | - | ||||||||||||||||||
415 | } | - | ||||||||||||||||||
416 | break; | - | ||||||||||||||||||
417 | } | - | ||||||||||||||||||
418 | default: | - | ||||||||||||||||||
419 | break; | - | ||||||||||||||||||
420 | } | - | ||||||||||||||||||
421 | } | - | ||||||||||||||||||
422 | if (type < 0 && caps && hasRelativeCoords) { | - | ||||||||||||||||||
423 | type = QTouchDevice::TouchPad; | - | ||||||||||||||||||
424 | if (dev->size.width() < 10 || dev->size.height() < 10 || | - | ||||||||||||||||||
425 | dev->size.width() > 10000 || dev->size.height() > 10000) | - | ||||||||||||||||||
426 | dev->size = QSizeF(130, 110); | - | ||||||||||||||||||
427 | } | - | ||||||||||||||||||
428 | if (!isAtLeastXI22() || type == QTouchDevice::TouchPad) | - | ||||||||||||||||||
429 | caps |= QTouchDevice::MouseEmulation; | - | ||||||||||||||||||
430 | - | |||||||||||||||||||
431 | if (type >= QTouchDevice::TouchScreen && type <= QTouchDevice::TouchPad) { | - | ||||||||||||||||||
432 | dev->qtTouchDevice = new QTouchDevice; | - | ||||||||||||||||||
433 | dev->qtTouchDevice->setName(QString::fromUtf8(dev->xiDeviceInfo->name)); | - | ||||||||||||||||||
434 | dev->qtTouchDevice->setType((QTouchDevice::DeviceType)type); | - | ||||||||||||||||||
435 | dev->qtTouchDevice->setCapabilities(caps); | - | ||||||||||||||||||
436 | dev->qtTouchDevice->setMaximumTouchPoints(maxTouchPoints); | - | ||||||||||||||||||
437 | if (caps != 0) | - | ||||||||||||||||||
438 | QWindowSystemInterface::registerTouchDevice(dev->qtTouchDevice); | - | ||||||||||||||||||
439 | m_touchDevices[id] = dev; | - | ||||||||||||||||||
440 | } else { | - | ||||||||||||||||||
441 | XIFreeDeviceInfo(dev->xiDeviceInfo); | - | ||||||||||||||||||
442 | delete dev; | - | ||||||||||||||||||
443 | dev = 0; | - | ||||||||||||||||||
444 | } | - | ||||||||||||||||||
445 | } | - | ||||||||||||||||||
446 | return dev; | - | ||||||||||||||||||
447 | } | - | ||||||||||||||||||
448 | - | |||||||||||||||||||
449 | - | |||||||||||||||||||
450 | static inline qreal fixed1616ToReal(FP1616 val) | - | ||||||||||||||||||
451 | { | - | ||||||||||||||||||
452 | return qreal(val) / 0x10000; | - | ||||||||||||||||||
453 | } | - | ||||||||||||||||||
454 | - | |||||||||||||||||||
455 | - | |||||||||||||||||||
456 | void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) | - | ||||||||||||||||||
457 | { | - | ||||||||||||||||||
458 | xi2PrepareXIGenericDeviceEvent(event); | - | ||||||||||||||||||
459 | xXIGenericDeviceEvent *xiEvent = reinterpret_cast<xXIGenericDeviceEvent *>(event); | - | ||||||||||||||||||
460 | int sourceDeviceId = xiEvent->deviceid; | - | ||||||||||||||||||
461 | xXIDeviceEvent *xiDeviceEvent = 0; | - | ||||||||||||||||||
462 | xXIEnterEvent *xiEnterEvent = 0; | - | ||||||||||||||||||
463 | QXcbWindowEventListener *eventListener = 0; | - | ||||||||||||||||||
464 | - | |||||||||||||||||||
465 | switch (xiEvent->evtype) { | - | ||||||||||||||||||
466 | case never executed: 4:case 4: never executed: case 4: | 0 | ||||||||||||||||||
467 | case never executed: 5:case 5: never executed: case 5: | 0 | ||||||||||||||||||
468 | case executed 464 times by 18 tests: 6:case 6: Executed by:
executed 464 times by 18 tests: case 6: Executed by:
| 464 | ||||||||||||||||||
469 | - | |||||||||||||||||||
470 | case never executed: 18:case 18: never executed: case 18: | 0 | ||||||||||||||||||
471 | case never executed: 19:case 19: never executed: case 19: | 0 | ||||||||||||||||||
472 | case never executed: 20:case 20: never executed: case 20: | 0 | ||||||||||||||||||
473 | - | |||||||||||||||||||
474 | { | - | ||||||||||||||||||
475 | xiDeviceEvent = reinterpret_cast<xXIDeviceEvent *>(event); | - | ||||||||||||||||||
476 | eventListener = windowEventListenerFromId(xiDeviceEvent->event); | - | ||||||||||||||||||
477 | sourceDeviceId = xiDeviceEvent->sourceid; | - | ||||||||||||||||||
478 | break; executed 464 times by 18 tests: break; Executed by:
| 464 | ||||||||||||||||||
479 | } | - | ||||||||||||||||||
480 | case executed 889 times by 70 tests: 7:case 7: Executed by:
executed 889 times by 70 tests: case 7: Executed by:
| 889 | ||||||||||||||||||
481 | case executed 832 times by 58 tests: 8:case 8: Executed by:
executed 832 times by 58 tests: {case 8: Executed by:
| 832 | ||||||||||||||||||
482 | xiEnterEvent = reinterpret_cast<xXIEnterEvent *>(event); | - | ||||||||||||||||||
483 | eventListener = windowEventListenerFromId(xiEnterEvent->event); | - | ||||||||||||||||||
484 | sourceDeviceId = xiEnterEvent->sourceid; | - | ||||||||||||||||||
485 | break; executed 1721 times by 70 tests: break; Executed by:
| 1721 | ||||||||||||||||||
486 | } | - | ||||||||||||||||||
487 | case never executed: 11:case 11: never executed: case 11: | 0 | ||||||||||||||||||
488 | xi2HandleHierachyEvent(xiEvent); | - | ||||||||||||||||||
489 | return; never executed: return; | 0 | ||||||||||||||||||
490 | case never executed: 1:case 1: never executed: case 1: | 0 | ||||||||||||||||||
491 | xi2HandleDeviceChangedEvent(xiEvent); | - | ||||||||||||||||||
492 | return; never executed: return; | 0 | ||||||||||||||||||
493 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
494 | break; never executed: break; | 0 | ||||||||||||||||||
495 | } | - | ||||||||||||||||||
496 | - | |||||||||||||||||||
497 | if (eventListener
| 866-1319 | ||||||||||||||||||
498 | long result = 0; | - | ||||||||||||||||||
499 | if (eventListener->handleGenericEvent(reinterpret_cast<xcb_generic_event_t *>(event), &result)
| 0-1319 | ||||||||||||||||||
500 | return; never executed: return; | 0 | ||||||||||||||||||
501 | } executed 1319 times by 70 tests: end of block Executed by:
| 1319 | ||||||||||||||||||
502 | - | |||||||||||||||||||
503 | - | |||||||||||||||||||
504 | if (!xiEnterEvent
| 464-1721 | ||||||||||||||||||
505 | QXcbConnection::TabletData *tablet = tabletDataForDevice(sourceDeviceId); | - | ||||||||||||||||||
506 | if (tablet
| 0-464 | ||||||||||||||||||
507 | return; never executed: return; | 0 | ||||||||||||||||||
508 | } executed 464 times by 18 tests: end of block Executed by:
| 464 | ||||||||||||||||||
509 | - | |||||||||||||||||||
510 | - | |||||||||||||||||||
511 | - | |||||||||||||||||||
512 | QHash<int, ScrollingDevice>::iterator device = m_scrollingDevices.find(sourceDeviceId); | - | ||||||||||||||||||
513 | if (device != m_scrollingDevices.end()
| 0-2185 | ||||||||||||||||||
514 | xi2HandleScrollEvent(xiEvent, device.value()); never executed: xi2HandleScrollEvent(xiEvent, device.value()); | 0 | ||||||||||||||||||
515 | - | |||||||||||||||||||
516 | - | |||||||||||||||||||
517 | - | |||||||||||||||||||
518 | if (xiDeviceEvent
| 464-1721 | ||||||||||||||||||
519 | switch (xiDeviceEvent->evtype) { | - | ||||||||||||||||||
520 | case never executed: 4:case 4: never executed: case 4: | 0 | ||||||||||||||||||
521 | case never executed: 5:case 5: never executed: case 5: | 0 | ||||||||||||||||||
522 | case executed 464 times by 18 tests: 6:case 6: Executed by:
executed 464 times by 18 tests: case 6: Executed by:
| 464 | ||||||||||||||||||
523 | if (xi2MouseEvents()
| 0-464 | ||||||||||||||||||
524 | eventListener->handleXIMouseEvent(event); executed 453 times by 17 tests: eventListener->handleXIMouseEvent(event); Executed by:
| 453 | ||||||||||||||||||
525 | break; executed 464 times by 18 tests: break; Executed by:
| 464 | ||||||||||||||||||
526 | - | |||||||||||||||||||
527 | case never executed: 18:case 18: never executed: case 18: | 0 | ||||||||||||||||||
528 | case never executed: 19:case 19: never executed: case 19: | 0 | ||||||||||||||||||
529 | case never executed: 20:case 20: never executed: case 20: | 0 | ||||||||||||||||||
530 | if (__builtin_expect(!!(lcQpaXInputEvents().isDebugEnabled()), false)
| 0 | ||||||||||||||||||
531 | for (bool qt_category_enabled = lcQpaXInputEvents().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 569 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x", event->event_type, xiDeviceEvent->sequenceNumber, xiDeviceEvent->detail, fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y), fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event) ; | 0 | ||||||||||||||||||
532 | 0 | |||||||||||||||||||
533 | 0 | |||||||||||||||||||
534 | __FILE__ never executed: QMessageLogger( __FILE__ , 569 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x", event->event_type, xiDeviceEvent->sequenceNumber, xiDeviceEvent->detail, fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y), fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event) ; | 0 | ||||||||||||||||||
535 | , never executed: QMessageLogger( __FILE__ , 569 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x", event->event_type, xiDeviceEvent->sequenceNumber, xiDeviceEvent->detail, fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y), fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event) ; | 0 | ||||||||||||||||||
536 | 0 | |||||||||||||||||||
537 | 0 | |||||||||||||||||||
538 | 562569 never executed: QMessageLogger( __FILE__ , 569 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x", event->event_type, xiDeviceEvent->sequenceNumber, xiDeviceEvent->detail, fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y), fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event) ; | 0 | ||||||||||||||||||
539 | , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x", event->event_type, xiDeviceEvent->sequenceNumber, xiDeviceEvent->detail, fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y), fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event) never executed: QMessageLogger( __FILE__ , 569 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x", event->event_type, xiDeviceEvent->sequenceNumber, xiDeviceEvent->detail, fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y), fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event) ; | 0 | ||||||||||||||||||
540 | 0 | |||||||||||||||||||
541 | 0 | |||||||||||||||||||
542 | ; never executed: QMessageLogger( __FILE__ , 569 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x", event->event_type, xiDeviceEvent->sequenceNumber, xiDeviceEvent->detail, fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y), fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event) ; | 0 | ||||||||||||||||||
543 | if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)
| 0 | ||||||||||||||||||
544 | xi2ProcessTouch(xiDeviceEvent, platformWindow); never executed: xi2ProcessTouch(xiDeviceEvent, platformWindow); | 0 | ||||||||||||||||||
545 | break; never executed: break; | 0 | ||||||||||||||||||
546 | } | - | ||||||||||||||||||
547 | } executed 464 times by 18 tests: else if (xiEnterEventend of block Executed by:
| 0-1721 | ||||||||||||||||||
548 | switch (xiEnterEvent->evtype) { | - | ||||||||||||||||||
549 | case executed 719 times by 70 tests: 7:case 7: Executed by:
executed 719 times by 70 tests: case 7: Executed by:
| 719 | ||||||||||||||||||
550 | case executed 147 times by 27 tests: 8:case 8: Executed by:
executed 147 times by 27 tests: case 8: Executed by:
| 147 | ||||||||||||||||||
551 | eventListener->handleXIEnterLeave(event); | - | ||||||||||||||||||
552 | break; executed 866 times by 70 tests: break; Executed by:
| 866 | ||||||||||||||||||
553 | } | - | ||||||||||||||||||
554 | } executed 866 times by 70 tests: end of block Executed by:
| 866 | ||||||||||||||||||
555 | - | |||||||||||||||||||
556 | } executed 2185 times by 70 tests: end of block Executed by:
| 2185 | ||||||||||||||||||
557 | - | |||||||||||||||||||
558 | - | |||||||||||||||||||
559 | static qreal valuatorNormalized(double value, XIValuatorClassInfo *vci) | - | ||||||||||||||||||
560 | { | - | ||||||||||||||||||
561 | if (value > vci->max) | - | ||||||||||||||||||
562 | value = vci->max; | - | ||||||||||||||||||
563 | if (value < vci->min) | - | ||||||||||||||||||
564 | value = vci->min; | - | ||||||||||||||||||
565 | return (value - vci->min) / (vci->max - vci->min); | - | ||||||||||||||||||
566 | } | - | ||||||||||||||||||
567 | - | |||||||||||||||||||
568 | void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindow) | - | ||||||||||||||||||
569 | { | - | ||||||||||||||||||
570 | xXIDeviceEvent *xiDeviceEvent = static_cast<xXIDeviceEvent *>(xiDevEvent); | - | ||||||||||||||||||
571 | XInput2TouchDeviceData *dev = touchDeviceForId(xiDeviceEvent->sourceid); | - | ||||||||||||||||||
572 | ((!(dev)) ? qt_assert("dev",__FILE__,592599) : qt_noop()); | - | ||||||||||||||||||
573 | const bool firstTouch = dev->touchPoints.isEmpty(); | - | ||||||||||||||||||
574 | if (xiDeviceEvent->evtype == 18) { | - | ||||||||||||||||||
575 | QWindowSystemInterface::TouchPoint tp; | - | ||||||||||||||||||
576 | tp.id = xiDeviceEvent->detail % 2147483647; | - | ||||||||||||||||||
577 | tp.state = Qt::TouchPointPressed; | - | ||||||||||||||||||
578 | tp.pressure = -1.0; | - | ||||||||||||||||||
579 | dev->touchPoints[tp.id] = tp; | - | ||||||||||||||||||
580 | } | - | ||||||||||||||||||
581 | QWindowSystemInterface::TouchPoint &touchPoint = dev->touchPoints[xiDeviceEvent->detail]; | - | ||||||||||||||||||
582 | QXcbScreen* screen = platformWindow->xcbScreen(); | - | ||||||||||||||||||
583 | qreal x = fixed1616ToReal(xiDeviceEvent->root_x); | - | ||||||||||||||||||
584 | qreal y = fixed1616ToReal(xiDeviceEvent->root_y); | - | ||||||||||||||||||
585 | qreal nx = -1.0, ny = -1.0; | - | ||||||||||||||||||
586 | qreal w = 0.0, h = 0.0; | - | ||||||||||||||||||
587 | bool majorAxisIsY = touchPoint.area.height() > touchPoint.area.width(); | - | ||||||||||||||||||
588 | for (int i = 0; i < dev->xiDeviceInfo->num_classes; ++i) { | - | ||||||||||||||||||
589 | XIAnyClassInfo *classinfo = dev->xiDeviceInfo->classes[i]; | - | ||||||||||||||||||
590 | if (classinfo->type == 2) { | - | ||||||||||||||||||
591 | XIValuatorClassInfo *vci = reinterpret_cast<XIValuatorClassInfo *>(classinfo); | - | ||||||||||||||||||
592 | int n = vci->number; | - | ||||||||||||||||||
593 | double value; | - | ||||||||||||||||||
594 | if (!xi2GetValuatorValueIfSet(xiDeviceEvent, n, &value)) | - | ||||||||||||||||||
595 | continue; | - | ||||||||||||||||||
596 | if (__builtin_expect(!!(lcQpaXInputEvents().isDebugEnabled()), false)) | - | ||||||||||||||||||
597 | for (bool qt_category_enabled = lcQpaXInputEvents().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger( | - | ||||||||||||||||||
598 | __FILE__ | - | ||||||||||||||||||
599 | , | - | ||||||||||||||||||
600 | 618625 | - | ||||||||||||||||||
601 | , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug(" valuator %20s value %lf from range %lf -> %lf", atomName(vci->label).constData(), value, vci->min, vci->max) | - | ||||||||||||||||||
602 | ; | - | ||||||||||||||||||
603 | if (vci->label == atom(QXcbAtom::RelX)) { | - | ||||||||||||||||||
604 | nx = valuatorNormalized(value, vci); | - | ||||||||||||||||||
605 | } else if (vci->label == atom(QXcbAtom::RelY)) { | - | ||||||||||||||||||
606 | ny = valuatorNormalized(value, vci); | - | ||||||||||||||||||
607 | } else if (vci->label == atom(QXcbAtom::AbsX)) { | - | ||||||||||||||||||
608 | nx = valuatorNormalized(value, vci); | - | ||||||||||||||||||
609 | } else if (vci->label == atom(QXcbAtom::AbsY)) { | - | ||||||||||||||||||
610 | ny = valuatorNormalized(value, vci); | - | ||||||||||||||||||
611 | } else if (vci->label == atom(QXcbAtom::AbsMTPositionX)) { | - | ||||||||||||||||||
612 | nx = valuatorNormalized(value, vci); | - | ||||||||||||||||||
613 | } else if (vci->label == atom(QXcbAtom::AbsMTPositionY)) { | - | ||||||||||||||||||
614 | ny = valuatorNormalized(value, vci); | - | ||||||||||||||||||
615 | } else if (vci->label == atom(QXcbAtom::AbsMTTouchMajor)) { | - | ||||||||||||||||||
616 | const qreal sw = screen->geometry().width(); | - | ||||||||||||||||||
617 | const qreal sh = screen->geometry().height(); | - | ||||||||||||||||||
618 | w = valuatorNormalized(value, vci) * std::sqrt(sw * sw + sh * sh); | - | ||||||||||||||||||
619 | } else if (vci->label == atom(QXcbAtom::AbsMTTouchMinor)) { | - | ||||||||||||||||||
620 | const qreal sw = screen->geometry().width(); | - | ||||||||||||||||||
621 | const qreal sh = screen->geometry().height(); | - | ||||||||||||||||||
622 | h = valuatorNormalized(value, vci) * std::sqrt(sw * sw + sh * sh); | - | ||||||||||||||||||
623 | } else if (vci->label == atom(QXcbAtom::AbsMTOrientation)) { | - | ||||||||||||||||||
624 | - | |||||||||||||||||||
625 | - | |||||||||||||||||||
626 | - | |||||||||||||||||||
627 | - | |||||||||||||||||||
628 | - | |||||||||||||||||||
629 | value = qAbs(value); | - | ||||||||||||||||||
630 | while (value > vci->max) | - | ||||||||||||||||||
631 | value -= 2 * vci->max; | - | ||||||||||||||||||
632 | value = qAbs(value); | - | ||||||||||||||||||
633 | majorAxisIsY = value < vci->max - value; | - | ||||||||||||||||||
634 | } else if (vci->label == atom(QXcbAtom::AbsMTPressure) || | - | ||||||||||||||||||
635 | vci->label == atom(QXcbAtom::AbsPressure)) { | - | ||||||||||||||||||
636 | touchPoint.pressure = valuatorNormalized(value, vci); | - | ||||||||||||||||||
637 | } | - | ||||||||||||||||||
638 | } | - | ||||||||||||||||||
639 | } | - | ||||||||||||||||||
640 | - | |||||||||||||||||||
641 | if (nx == -1.0) { | - | ||||||||||||||||||
642 | x = touchPoint.area.center().x(); | - | ||||||||||||||||||
643 | nx = x / screen->geometry().width(); | - | ||||||||||||||||||
644 | } | - | ||||||||||||||||||
645 | if (ny == -1.0) { | - | ||||||||||||||||||
646 | y = touchPoint.area.center().y(); | - | ||||||||||||||||||
647 | ny = y / screen->geometry().height(); | - | ||||||||||||||||||
648 | } | - | ||||||||||||||||||
649 | if (xiDeviceEvent->evtype != 20) { | - | ||||||||||||||||||
650 | if (!dev->providesTouchOrientation) { | - | ||||||||||||||||||
651 | if (w == 0.0) | - | ||||||||||||||||||
652 | w = touchPoint.area.width(); | - | ||||||||||||||||||
653 | h = w; | - | ||||||||||||||||||
654 | } else { | - | ||||||||||||||||||
655 | if (w == 0.0) | - | ||||||||||||||||||
656 | w = qMax(touchPoint.area.width(), touchPoint.area.height()); | - | ||||||||||||||||||
657 | if (h == 0.0) | - | ||||||||||||||||||
658 | h = qMin(touchPoint.area.width(), touchPoint.area.height()); | - | ||||||||||||||||||
659 | if (majorAxisIsY) | - | ||||||||||||||||||
660 | qSwap(w, h); | - | ||||||||||||||||||
661 | } | - | ||||||||||||||||||
662 | } | - | ||||||||||||||||||
663 | - | |||||||||||||||||||
664 | switch (xiDeviceEvent->evtype) { | - | ||||||||||||||||||
665 | case 18: | - | ||||||||||||||||||
666 | if (firstTouch) { | - | ||||||||||||||||||
667 | dev->firstPressedPosition = QPointF(x, y); | - | ||||||||||||||||||
668 | dev->firstPressedNormalPosition = QPointF(nx, ny); | - | ||||||||||||||||||
669 | } | - | ||||||||||||||||||
670 | dev->pointPressedPosition.insert(touchPoint.id, QPointF(x, y)); | - | ||||||||||||||||||
671 | - | |||||||||||||||||||
672 | - | |||||||||||||||||||
673 | - | |||||||||||||||||||
674 | if (m_xiGrab) { | - | ||||||||||||||||||
675 | XIAllowTouchEvents(static_cast<Display *>(m_xlib_display), xiDeviceEvent->deviceid, | - | ||||||||||||||||||
676 | xiDeviceEvent->detail, xiDeviceEvent->event, 6); | - | ||||||||||||||||||
677 | - | |||||||||||||||||||
678 | } | - | ||||||||||||||||||
679 | break; | - | ||||||||||||||||||
680 | case 19: | - | ||||||||||||||||||
681 | if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) { | - | ||||||||||||||||||
682 | qreal dx = (nx - dev->firstPressedNormalPosition.x()) * | - | ||||||||||||||||||
683 | dev->size.width() * screen->geometry().width() / screen->physicalSize().width(); | - | ||||||||||||||||||
684 | qreal dy = (ny - dev->firstPressedNormalPosition.y()) * | - | ||||||||||||||||||
685 | dev->size.height() * screen->geometry().height() / screen->physicalSize().height(); | - | ||||||||||||||||||
686 | x = dev->firstPressedPosition.x() + dx; | - | ||||||||||||||||||
687 | y = dev->firstPressedPosition.y() + dy; | - | ||||||||||||||||||
688 | touchPoint.state = Qt::TouchPointMoved; | - | ||||||||||||||||||
689 | } else if (touchPoint.area.center() != QPoint(x, y)) { | - | ||||||||||||||||||
690 | touchPoint.state = Qt::TouchPointMoved; | - | ||||||||||||||||||
691 | dev->pointPressedPosition[touchPoint.id] = QPointF(x, y); | - | ||||||||||||||||||
692 | } | - | ||||||||||||||||||
693 | break; | - | ||||||||||||||||||
694 | case 20: | - | ||||||||||||||||||
695 | touchPoint.state = Qt::TouchPointReleased; | - | ||||||||||||||||||
696 | if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) { | - | ||||||||||||||||||
697 | qreal dx = (nx - dev->firstPressedNormalPosition.x()) * | - | ||||||||||||||||||
698 | dev->size.width() * screen->geometry().width() / screen->physicalSize().width(); | - | ||||||||||||||||||
699 | qreal dy = (ny - dev->firstPressedNormalPosition.y()) * | - | ||||||||||||||||||
700 | dev->size.width() * screen->geometry().width() / screen->physicalSize().width(); | - | ||||||||||||||||||
701 | x = dev->firstPressedPosition.x() + dx; | - | ||||||||||||||||||
702 | y = dev->firstPressedPosition.y() + dy; | - | ||||||||||||||||||
703 | } | - | ||||||||||||||||||
704 | dev->pointPressedPosition.remove(touchPoint.id); | - | ||||||||||||||||||
705 | } | - | ||||||||||||||||||
706 | touchPoint.area = QRectF(x - w/2, y - h/2, w, h); | - | ||||||||||||||||||
707 | touchPoint.normalPosition = QPointF(nx, ny); | - | ||||||||||||||||||
708 | - | |||||||||||||||||||
709 | if (__builtin_expect(!!(lcQpaXInputEvents().isDebugEnabled()), false)) | - | ||||||||||||||||||
710 | for (bool qt_category_enabled = lcQpaXInputEvents().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 745752, __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug() << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition << | - | ||||||||||||||||||
711 | " area " << touchPoint.area << " pressure " << touchPoint.pressure; | - | ||||||||||||||||||
712 | QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiDeviceEvent->time, dev->qtTouchDevice, dev->touchPoints.values()); | - | ||||||||||||||||||
713 | if (touchPoint.state == Qt::TouchPointReleased) | - | ||||||||||||||||||
714 | - | |||||||||||||||||||
715 | dev->touchPoints.remove(touchPoint.id); | - | ||||||||||||||||||
716 | else | - | ||||||||||||||||||
717 | - | |||||||||||||||||||
718 | - | |||||||||||||||||||
719 | touchPoint.state = Qt::TouchPointStationary; | - | ||||||||||||||||||
720 | } | - | ||||||||||||||||||
721 | - | |||||||||||||||||||
722 | bool QXcbConnection::xi2SetMouseGrabEnabled(xcb_window_t w, bool grab) | - | ||||||||||||||||||
723 | { | - | ||||||||||||||||||
724 | if (grab && !canGrab()) | - | ||||||||||||||||||
725 | return false; | - | ||||||||||||||||||
726 | - | |||||||||||||||||||
727 | int num_devices = 0; | - | ||||||||||||||||||
728 | Display *xDisplay = static_cast<Display *>(xlib_display()); | - | ||||||||||||||||||
729 | XIDeviceInfo *info = XIQueryDevice(xDisplay, 1, &num_devices); | - | ||||||||||||||||||
730 | if (!info) | - | ||||||||||||||||||
731 | return false; | - | ||||||||||||||||||
732 | - | |||||||||||||||||||
733 | XIEventMask evmask; | - | ||||||||||||||||||
734 | unsigned char mask[(((26) >> 3) + 1)]; | - | ||||||||||||||||||
735 | evmask.mask = mask; | - | ||||||||||||||||||
736 | evmask.mask_len = sizeof(mask); | - | ||||||||||||||||||
737 | memset(mask, 0, sizeof(mask)); | - | ||||||||||||||||||
738 | evmask.deviceid = 1; | - | ||||||||||||||||||
739 | - | |||||||||||||||||||
740 | (((unsigned char*)(mask))[(4)>>3] |= (1 << ((4) & 7))); | - | ||||||||||||||||||
741 | (((unsigned char*)(mask))[(5)>>3] |= (1 << ((5) & 7))); | - | ||||||||||||||||||
742 | (((unsigned char*)(mask))[(6)>>3] |= (1 << ((6) & 7))); | - | ||||||||||||||||||
743 | (((unsigned char*)(mask))[(7)>>3] |= (1 << ((7) & 7))); | - | ||||||||||||||||||
744 | (((unsigned char*)(mask))[(8)>>3] |= (1 << ((8) & 7))); | - | ||||||||||||||||||
745 | (((unsigned char*)(mask))[(18)>>3] |= (1 << ((18) & 7))); | - | ||||||||||||||||||
746 | (((unsigned char*)(mask))[(19)>>3] |= (1 << ((19) & 7))); | - | ||||||||||||||||||
747 | (((unsigned char*)(mask))[(20)>>3] |= (1 << ((20) & 7))); | - | ||||||||||||||||||
748 | - | |||||||||||||||||||
749 | bool grabbed = true; | - | ||||||||||||||||||
750 | for (int i = 0; i < num_devices; i++) { | - | ||||||||||||||||||
751 | int id = info[i].deviceid, n = 0; | - | ||||||||||||||||||
752 | XIDeviceInfo *deviceInfo = XIQueryDevice(xDisplay, id, &n); | - | ||||||||||||||||||
753 | if (deviceInfo) { | - | ||||||||||||||||||
754 | const bool grabbable = deviceInfo->use != 2; | - | ||||||||||||||||||
755 | XIFreeDeviceInfo(deviceInfo); | - | ||||||||||||||||||
756 | if (!grabbable) | - | ||||||||||||||||||
757 | continue; | - | ||||||||||||||||||
758 | } | - | ||||||||||||||||||
759 | if (!grab) { | - | ||||||||||||||||||
760 | int result = XIUngrabDevice(xDisplay, id, 0L); | - | ||||||||||||||||||
761 | if (result != 0) { | - | ||||||||||||||||||
762 | grabbed = false; | - | ||||||||||||||||||
763 | for (bool qt_category_enabled = lcQpaXInput().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 798805, __PRETTY_FUNCTION__, lcQpaXInput().categoryName()).debug("XInput 2.2: failed to ungrab events for device %d (result %d)", id, result); | - | ||||||||||||||||||
764 | } | - | ||||||||||||||||||
765 | } else { | - | ||||||||||||||||||
766 | int result = XIGrabDevice(xDisplay, id, w, 0L, 0L, 1, | - | ||||||||||||||||||
767 | 1, 0, &evmask); | - | ||||||||||||||||||
768 | if (result != 0) { | - | ||||||||||||||||||
769 | grabbed = false; | - | ||||||||||||||||||
770 | for (bool qt_category_enabled = lcQpaXInput().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 805812, __PRETTY_FUNCTION__, lcQpaXInput().categoryName()).debug("XInput 2.2: failed to grab events for device %d on window %x (result %d)", id, w, result); | - | ||||||||||||||||||
771 | } | - | ||||||||||||||||||
772 | } | - | ||||||||||||||||||
773 | } | - | ||||||||||||||||||
774 | - | |||||||||||||||||||
775 | XIFreeDeviceInfo(info); | - | ||||||||||||||||||
776 | - | |||||||||||||||||||
777 | m_xiGrab = grabbed; | - | ||||||||||||||||||
778 | - | |||||||||||||||||||
779 | return grabbed; | - | ||||||||||||||||||
780 | } | - | ||||||||||||||||||
781 | - | |||||||||||||||||||
782 | - | |||||||||||||||||||
783 | void QXcbConnection::xi2HandleHierachyEvent(void *event) | - | ||||||||||||||||||
784 | { | - | ||||||||||||||||||
785 | xXIHierarchyEvent *xiEvent = reinterpret_cast<xXIHierarchyEvent *>(event); | - | ||||||||||||||||||
786 | - | |||||||||||||||||||
787 | if (!(xiEvent->flags & ((1 << 3) | (1 << 2)))
| 0 | ||||||||||||||||||
788 | return; never executed: return; | 0 | ||||||||||||||||||
789 | xi2SetupDevices(); | - | ||||||||||||||||||
790 | - | |||||||||||||||||||
791 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(auto it = m_mapper.keys())>::type> _container_((cbegin(), end = m_mapper.keys())); _container_.control && _container_.icend(); it
| 0 | ||||||||||||||||||
792 | {xi2Select(window); never executed: xi2Select(it.key()); | 0 | ||||||||||||||||||
} never executed: xi2Select(it.key()); never executed: it.key());xi2Select(it.key()); never executed: xi2Select(it.key()); | ||||||||||||||||||||
793 | } never executed: end of block | 0 | ||||||||||||||||||
794 | - | |||||||||||||||||||
795 | void QXcbConnection::xi2HandleDeviceChangedEvent(void *event) | - | ||||||||||||||||||
796 | { | - | ||||||||||||||||||
797 | xXIDeviceChangedEvent *xiEvent = reinterpret_cast<xXIDeviceChangedEvent *>(event); | - | ||||||||||||||||||
798 | - | |||||||||||||||||||
799 | - | |||||||||||||||||||
800 | if (xiEvent->reason != 1) | - | ||||||||||||||||||
801 | return; | - | ||||||||||||||||||
802 | - | |||||||||||||||||||
803 | - | |||||||||||||||||||
804 | - | |||||||||||||||||||
805 | - | |||||||||||||||||||
806 | - | |||||||||||||||||||
807 | - | |||||||||||||||||||
808 | - | |||||||||||||||||||
809 | QHash<int, ScrollingDevice>::iterator device = m_scrollingDevices.find(xiEvent->sourceid); | - | ||||||||||||||||||
810 | if (device == m_scrollingDevices.end()) | - | ||||||||||||||||||
811 | return; | - | ||||||||||||||||||
812 | - | |||||||||||||||||||
813 | int nrDevices = 0; | - | ||||||||||||||||||
814 | XIDeviceInfo* xiDeviceInfo = XIQueryDevice(static_cast<Display *>(m_xlib_display), xiEvent->sourceid, &nrDevices); | - | ||||||||||||||||||
815 | if (nrDevices <= 0) { | - | ||||||||||||||||||
816 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 852858, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug("scrolling device %d no longer present", xiEvent->sourceid); | - | ||||||||||||||||||
817 | return; | - | ||||||||||||||||||
818 | } | - | ||||||||||||||||||
819 | updateScrollingDevice(*device, xiDeviceInfo->num_classes, xiDeviceInfo->classes); | - | ||||||||||||||||||
820 | XIFreeDeviceInfo(xiDeviceInfo); | - | ||||||||||||||||||
821 | - | |||||||||||||||||||
822 | } | - | ||||||||||||||||||
823 | - | |||||||||||||||||||
824 | void QXcbConnection::updateScrollingDevice(ScrollingDevice &scrollingDevice, int num_classes, void *classInfo) | - | ||||||||||||||||||
825 | { | - | ||||||||||||||||||
826 | - | |||||||||||||||||||
827 | XIAnyClassInfo **classes = reinterpret_cast<XIAnyClassInfo**>(classInfo); | - | ||||||||||||||||||
828 | QPointF lastScrollPosition; | - | ||||||||||||||||||
829 | if (lcQpaXInput().isDebugEnabled()) | - | ||||||||||||||||||
830 | lastScrollPosition = scrollingDevice.lastScrollPosition; | - | ||||||||||||||||||
831 | for (int c = 0; c < num_classes; ++c) { | - | ||||||||||||||||||
832 | if (classes[c]->type == 2) { | - | ||||||||||||||||||
833 | XIValuatorClassInfo *vci = reinterpret_cast<XIValuatorClassInfo *>(classes[c]); | - | ||||||||||||||||||
834 | const int valuatorAtom = qatom(vci->label); | - | ||||||||||||||||||
835 | if (valuatorAtom == QXcbAtom::RelHorizScroll || valuatorAtom == QXcbAtom::RelHorizWheel) | - | ||||||||||||||||||
836 | scrollingDevice.lastScrollPosition.setX(vci->value); | - | ||||||||||||||||||
837 | else if (valuatorAtom == QXcbAtom::RelVertScroll || valuatorAtom == QXcbAtom::RelVertWheel) | - | ||||||||||||||||||
838 | scrollingDevice.lastScrollPosition.setY(vci->value); | - | ||||||||||||||||||
839 | } | - | ||||||||||||||||||
840 | } | - | ||||||||||||||||||
841 | if (__builtin_expect(!!(lcQpaXInputEvents().isDebugEnabled() && lastScrollPosition != scrollingDevice.lastScrollPosition), false)) | - | ||||||||||||||||||
842 | for (bool qt_category_enabled = lcQpaXInputEvents().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger( | - | ||||||||||||||||||
843 | - | |||||||||||||||||||
844 | - | |||||||||||||||||||
845 | __FILE__ | - | ||||||||||||||||||
846 | , | - | ||||||||||||||||||
847 | - | |||||||||||||||||||
848 | - | |||||||||||||||||||
849 | 881887 | - | ||||||||||||||||||
850 | , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("scrolling device %d moved from (%f, %f) to (%f, %f)", scrollingDevice.deviceId, lastScrollPosition.x(), lastScrollPosition.y(), scrollingDevice.lastScrollPosition.x(), scrollingDevice.lastScrollPosition.y()) | - | ||||||||||||||||||
851 | - | |||||||||||||||||||
852 | - | |||||||||||||||||||
853 | ; | - | ||||||||||||||||||
854 | - | |||||||||||||||||||
855 | - | |||||||||||||||||||
856 | - | |||||||||||||||||||
857 | - | |||||||||||||||||||
858 | - | |||||||||||||||||||
859 | } | - | ||||||||||||||||||
860 | - | |||||||||||||||||||
861 | - | |||||||||||||||||||
862 | void QXcbConnection::handleEnterEvent() | - | ||||||||||||||||||
863 | { | - | ||||||||||||||||||
864 | QHash<int, ScrollingDevice>::iterator it = m_scrollingDevices.begin(); | - | ||||||||||||||||||
865 | const QHash<int, ScrollingDevice>::iterator end = m_scrollingDevices.end(); | - | ||||||||||||||||||
866 | while (it != end) { | - | ||||||||||||||||||
867 | ScrollingDevice& scrollingDevice = it.value(); | - | ||||||||||||||||||
868 | int nrDevices = 0; | - | ||||||||||||||||||
869 | XIDeviceInfo* xiDeviceInfo = XIQueryDevice(static_cast<Display *>(m_xlib_display), scrollingDevice.deviceId, &nrDevices); | - | ||||||||||||||||||
870 | if (nrDevices <= 0) { | - | ||||||||||||||||||
871 | for (bool qt_category_enabled = lcQpaXInputDevices().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 899905, __PRETTY_FUNCTION__, lcQpaXInputDevices().categoryName()).debug("scrolling device %d no longer present", scrollingDevice.deviceId); | - | ||||||||||||||||||
872 | it = m_scrollingDevices.erase(it); | - | ||||||||||||||||||
873 | continue; | - | ||||||||||||||||||
874 | } | - | ||||||||||||||||||
875 | updateScrollingDevice(scrollingDevice, xiDeviceInfo->num_classes, xiDeviceInfo->classes); | - | ||||||||||||||||||
876 | XIFreeDeviceInfo(xiDeviceInfo); | - | ||||||||||||||||||
877 | ++it; | - | ||||||||||||||||||
878 | } | - | ||||||||||||||||||
879 | } | - | ||||||||||||||||||
880 | - | |||||||||||||||||||
881 | - | |||||||||||||||||||
882 | void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollingDevice) | - | ||||||||||||||||||
883 | { | - | ||||||||||||||||||
884 | - | |||||||||||||||||||
885 | xXIGenericDeviceEvent *xiEvent = reinterpret_cast<xXIGenericDeviceEvent *>(event); | - | ||||||||||||||||||
886 | - | |||||||||||||||||||
887 | if (xiEvent->evtype == 6 && scrollingDevice.orientations) { | - | ||||||||||||||||||
888 | xXIDeviceEvent* xiDeviceEvent = reinterpret_cast<xXIDeviceEvent *>(event); | - | ||||||||||||||||||
889 | if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) { | - | ||||||||||||||||||
890 | QPoint rawDelta; | - | ||||||||||||||||||
891 | QPoint angleDelta; | - | ||||||||||||||||||
892 | double value; | - | ||||||||||||||||||
893 | if (scrollingDevice.orientations & Qt::Vertical) { | - | ||||||||||||||||||
894 | if (xi2GetValuatorValueIfSet(xiDeviceEvent, scrollingDevice.verticalIndex, &value)) { | - | ||||||||||||||||||
895 | double delta = scrollingDevice.lastScrollPosition.y() - value; | - | ||||||||||||||||||
896 | scrollingDevice.lastScrollPosition.setY(value); | - | ||||||||||||||||||
897 | angleDelta.setY((delta / scrollingDevice.verticalIncrement) * 120); | - | ||||||||||||||||||
898 | - | |||||||||||||||||||
899 | if (scrollingDevice.verticalIncrement > 1) | - | ||||||||||||||||||
900 | rawDelta.setY(delta); | - | ||||||||||||||||||
901 | else if (scrollingDevice.verticalIncrement < -1) | - | ||||||||||||||||||
902 | rawDelta.setY(-delta); | - | ||||||||||||||||||
903 | } | - | ||||||||||||||||||
904 | } | - | ||||||||||||||||||
905 | if (scrollingDevice.orientations & Qt::Horizontal) { | - | ||||||||||||||||||
906 | if (xi2GetValuatorValueIfSet(xiDeviceEvent, scrollingDevice.horizontalIndex, &value)) { | - | ||||||||||||||||||
907 | double delta = scrollingDevice.lastScrollPosition.x() - value; | - | ||||||||||||||||||
908 | scrollingDevice.lastScrollPosition.setX(value); | - | ||||||||||||||||||
909 | angleDelta.setX((delta / scrollingDevice.horizontalIncrement) * 120); | - | ||||||||||||||||||
910 | - | |||||||||||||||||||
911 | if (scrollingDevice.horizontalIncrement > 1) | - | ||||||||||||||||||
912 | rawDelta.setX(delta); | - | ||||||||||||||||||
913 | else if (scrollingDevice.horizontalIncrement < -1) | - | ||||||||||||||||||
914 | rawDelta.setX(-delta); | - | ||||||||||||||||||
915 | } | - | ||||||||||||||||||
916 | } | - | ||||||||||||||||||
917 | if (!angleDelta.isNull()) { | - | ||||||||||||||||||
918 | QPoint local(fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y)); | - | ||||||||||||||||||
919 | QPoint global(fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y)); | - | ||||||||||||||||||
920 | Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(xiDeviceEvent->mods.effective_mods); | - | ||||||||||||||||||
921 | if (modifiers & Qt::AltModifier) { | - | ||||||||||||||||||
922 | std::swap(angleDelta.rx(), angleDelta.ry()); | - | ||||||||||||||||||
923 | std::swap(rawDelta.rx(), rawDelta.ry()); | - | ||||||||||||||||||
924 | } | - | ||||||||||||||||||
925 | QWindowSystemInterface::handleWheelEvent(platformWindow->window(), xiEvent->time, local, global, rawDelta, angleDelta, modifiers); | - | ||||||||||||||||||
926 | } | - | ||||||||||||||||||
927 | } | - | ||||||||||||||||||
928 | } else if (xiEvent->evtype == 5 && scrollingDevice.legacyOrientations) { | - | ||||||||||||||||||
929 | xXIDeviceEvent* xiDeviceEvent = reinterpret_cast<xXIDeviceEvent *>(event); | - | ||||||||||||||||||
930 | if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) { | - | ||||||||||||||||||
931 | QPoint angleDelta; | - | ||||||||||||||||||
932 | if (scrollingDevice.legacyOrientations & Qt::Vertical) { | - | ||||||||||||||||||
933 | if (xiDeviceEvent->detail == 4) | - | ||||||||||||||||||
934 | angleDelta.setY(120); | - | ||||||||||||||||||
935 | else if (xiDeviceEvent->detail == 5) | - | ||||||||||||||||||
936 | angleDelta.setY(-120); | - | ||||||||||||||||||
937 | } | - | ||||||||||||||||||
938 | if (scrollingDevice.legacyOrientations & Qt::Horizontal) { | - | ||||||||||||||||||
939 | if (xiDeviceEvent->detail == 6) | - | ||||||||||||||||||
940 | angleDelta.setX(120); | - | ||||||||||||||||||
941 | else if (xiDeviceEvent->detail == 7) | - | ||||||||||||||||||
942 | angleDelta.setX(-120); | - | ||||||||||||||||||
943 | } | - | ||||||||||||||||||
944 | if (!angleDelta.isNull()) { | - | ||||||||||||||||||
945 | QPoint local(fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y)); | - | ||||||||||||||||||
946 | QPoint global(fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y)); | - | ||||||||||||||||||
947 | Qt::KeyboardModifiers modifiers = keyboard()->translateModifiers(xiDeviceEvent->mods.effective_mods); | - | ||||||||||||||||||
948 | if (modifiers & Qt::AltModifier) | - | ||||||||||||||||||
949 | std::swap(angleDelta.rx(), angleDelta.ry()); | - | ||||||||||||||||||
950 | QWindowSystemInterface::handleWheelEvent(platformWindow->window(), xiEvent->time, local, global, QPoint(), angleDelta, modifiers); | - | ||||||||||||||||||
951 | } | - | ||||||||||||||||||
952 | } | - | ||||||||||||||||||
953 | } | - | ||||||||||||||||||
954 | - | |||||||||||||||||||
955 | - | |||||||||||||||||||
956 | - | |||||||||||||||||||
957 | - | |||||||||||||||||||
958 | } | - | ||||||||||||||||||
959 | - | |||||||||||||||||||
960 | Qt::MouseButton QXcbConnection::xiToQtMouseButton(uint32_t b) | - | ||||||||||||||||||
961 | { | - | ||||||||||||||||||
962 | switch (b) { | - | ||||||||||||||||||
963 | case 1: return Qt::LeftButton; | - | ||||||||||||||||||
964 | case 2: return Qt::MiddleButton; | - | ||||||||||||||||||
965 | case 3: return Qt::RightButton; | - | ||||||||||||||||||
966 | - | |||||||||||||||||||
967 | default: break; | - | ||||||||||||||||||
968 | } | - | ||||||||||||||||||
969 | if (b >= 8 && b <= Qt::MaxMouseButton) | - | ||||||||||||||||||
970 | return static_cast<Qt::MouseButton>(Qt::BackButton << (b - 8)); | - | ||||||||||||||||||
971 | return Qt::NoButton; | - | ||||||||||||||||||
972 | } | - | ||||||||||||||||||
973 | - | |||||||||||||||||||
974 | static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { | - | ||||||||||||||||||
975 | - | |||||||||||||||||||
976 | switch (toolId) { | - | ||||||||||||||||||
977 | case 0xd12: | - | ||||||||||||||||||
978 | case 0x912: | - | ||||||||||||||||||
979 | case 0x112: | - | ||||||||||||||||||
980 | case 0x913: | - | ||||||||||||||||||
981 | case 0x91b: | - | ||||||||||||||||||
982 | case 0x902: | - | ||||||||||||||||||
983 | case 0x90a: | - | ||||||||||||||||||
984 | case 0x100902: | - | ||||||||||||||||||
985 | case 0x10090a: | - | ||||||||||||||||||
986 | return QTabletEvent::Airbrush; | - | ||||||||||||||||||
987 | case 0x007: | - | ||||||||||||||||||
988 | case 0x09c: | - | ||||||||||||||||||
989 | case 0x094: | - | ||||||||||||||||||
990 | return QTabletEvent::FourDMouse; | - | ||||||||||||||||||
991 | case 0x017: | - | ||||||||||||||||||
992 | case 0x806: | - | ||||||||||||||||||
993 | case 0x096: | - | ||||||||||||||||||
994 | case 0x097: | - | ||||||||||||||||||
995 | case 0x006: | - | ||||||||||||||||||
996 | return QTabletEvent::Puck; | - | ||||||||||||||||||
997 | case 0x885: | - | ||||||||||||||||||
998 | case 0x100804: | - | ||||||||||||||||||
999 | case 0x10080c: | - | ||||||||||||||||||
1000 | return QTabletEvent::RotationStylus; | - | ||||||||||||||||||
1001 | case 0: | - | ||||||||||||||||||
1002 | return QTabletEvent::NoDevice; | - | ||||||||||||||||||
1003 | } | - | ||||||||||||||||||
1004 | return QTabletEvent::Stylus; | - | ||||||||||||||||||
1005 | } | - | ||||||||||||||||||
1006 | - | |||||||||||||||||||
1007 | - | |||||||||||||||||||
1008 | bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletData, QXcbWindowEventListener *eventListener) | - | ||||||||||||||||||
1009 | { | - | ||||||||||||||||||
1010 | bool handled = true; | - | ||||||||||||||||||
1011 | Display *xDisplay = static_cast<Display *>(m_xlib_display); | - | ||||||||||||||||||
1012 | const xXIGenericDeviceEvent *xiEvent = static_cast<const xXIGenericDeviceEvent *>(event); | - | ||||||||||||||||||
1013 | const xXIDeviceEvent *xiDeviceEvent = reinterpret_cast<const xXIDeviceEvent *>(xiEvent); | - | ||||||||||||||||||
1014 | - | |||||||||||||||||||
1015 | switch (xiEvent->evtype) { | - | ||||||||||||||||||
1016 | case never executed: 4:case 4: never executed: {case 4: | 0 | ||||||||||||||||||
1017 | Qt::MouseButton b = xiToQtMouseButton(xiDeviceEvent->detail); | - | ||||||||||||||||||
1018 | tabletData->buttons |= b; | - | ||||||||||||||||||
1019 | xi2ReportTabletEvent(*tabletData,(xiEvent, tabletData); | - | ||||||||||||||||||
1020 | break; never executed: break; | 0 | ||||||||||||||||||
1021 | } | - | ||||||||||||||||||
1022 | case never executed: 5:case 5: never executed: {case 5: | 0 | ||||||||||||||||||
1023 | Qt::MouseButton b = xiToQtMouseButton(xiDeviceEvent->detail); | - | ||||||||||||||||||
1024 | tabletData->buttons ^= b; | - | ||||||||||||||||||
1025 | xi2ReportTabletEvent(*tabletData,(xiEvent, tabletData); | - | ||||||||||||||||||
1026 | break; never executed: break; | 0 | ||||||||||||||||||
1027 | } | - | ||||||||||||||||||
1028 | case never executed: 6:case 6: never executed: case 6: | 0 | ||||||||||||||||||
1029 | - | |||||||||||||||||||
1030 | - | |||||||||||||||||||
1031 | if (tabletData->buttons != Qt::NoButton
| 0 | ||||||||||||||||||
1032 | xi2ReportTabletEvent(*tabletData,(xiEvent, tabletData); never executed: xi2ReportTabletEvent(xiEvent, tabletData); | 0 | ||||||||||||||||||
1033 | break; never executed: break; | 0 | ||||||||||||||||||
1034 | case never executed: 12:case 12: never executed: {case 12: | 0 | ||||||||||||||||||
1035 | - | |||||||||||||||||||
1036 | - | |||||||||||||||||||
1037 | const xXIPropertyEvent *ev = reinterpret_cast<const xXIPropertyEvent *>(event); | - | ||||||||||||||||||
1038 | if (ev->what == 2
| 0 | ||||||||||||||||||
1039 | if (ev->property == atom(QXcbAtom::WacomSerialIDs)
| 0 | ||||||||||||||||||
1040 | enum WacomSerialIndex { | - | ||||||||||||||||||
1041 | _WACSER_USB_ID = 0, | - | ||||||||||||||||||
1042 | _WACSER_LAST_TOOL_SERIAL, | - | ||||||||||||||||||
1043 | _WACSER_LAST_TOOL_ID, | - | ||||||||||||||||||
1044 | _WACSER_TOOL_SERIAL, | - | ||||||||||||||||||
1045 | _WACSER_TOOL_ID, | - | ||||||||||||||||||
1046 | _WACSER_COUNT | - | ||||||||||||||||||
1047 | }; | - | ||||||||||||||||||
1048 | Atom propType; | - | ||||||||||||||||||
1049 | int propFormat; | - | ||||||||||||||||||
1050 | unsigned long numItems, bytesAfter; | - | ||||||||||||||||||
1051 | unsigned char *data; | - | ||||||||||||||||||
1052 | if (XIGetProperty(xDisplay, tabletData->deviceId, ev->property, 0, 100,
| 0 | ||||||||||||||||||
1053 | 0, 0L, &propType, &propFormat,
| 0 | ||||||||||||||||||
1054 | &numItems, &bytesAfter, &data) == 0
| 0 | ||||||||||||||||||
1055 | if (propType == atom(QXcbAtom::INTEGER)
| 0 | ||||||||||||||||||
1056 | quint32 *ptr = reinterpret_cast<quint32 *>(data); | - | ||||||||||||||||||
1057 | quint32 tool = ptr[_WACSER_TOOL_ID]; | - | ||||||||||||||||||
1058 | - | |||||||||||||||||||
1059 | - | |||||||||||||||||||
1060 | if (!tool
| 0 | ||||||||||||||||||
1061 | tool = ptr[_WACSER_TOOL_SERIAL]; never executed: tool = ptr[_WACSER_TOOL_SERIAL]; | 0 | ||||||||||||||||||
1062 | - | |||||||||||||||||||
1063 | - | |||||||||||||||||||
1064 | if (tool
| 0 | ||||||||||||||||||
1065 | tabletData->inProximity = true; | - | ||||||||||||||||||
1066 | tabletData->tool = toolIdToTabletDevice(tool); | - | ||||||||||||||||||
1067 | tabletData->serialId = qint64(ptr[_WACSER_USB_ID]) << 32 | qint64(ptr[_WACSER_TOOL_SERIAL]); | - | ||||||||||||||||||
1068 | QWindowSystemInterface::handleTabletEnterProximityEvent(ev->time, | - | ||||||||||||||||||
1069 | tabletData->tool, tabletData->pointerType, tabletData->serialId); | - | ||||||||||||||||||
1070 | } never executed: else {end of block | 0 | ||||||||||||||||||
1071 | tabletData->inProximity = false; | - | ||||||||||||||||||
1072 | tabletData->tool = toolIdToTabletDevice(ptr[_WACSER_LAST_TOOL_ID]); | - | ||||||||||||||||||
1073 | - | |||||||||||||||||||
1074 | - | |||||||||||||||||||
1075 | if (!tabletData->tool
| 0 | ||||||||||||||||||
1076 | tabletData->tool = toolIdToTabletDevice(ptr[_WACSER_LAST_TOOL_SERIAL]); never executed: tabletData->tool = toolIdToTabletDevice(ptr[_WACSER_LAST_TOOL_SERIAL]); | 0 | ||||||||||||||||||
1077 | tabletData->serialId = qint64(ptr[_WACSER_USB_ID]) << 32 | qint64(ptr[_WACSER_LAST_TOOL_SERIAL]); | - | ||||||||||||||||||
1078 | QWindowSystemInterface::handleTabletLeaveProximityEvent(ev->time, | - | ||||||||||||||||||
1079 | tabletData->tool, tabletData->pointerType, tabletData->serialId); | - | ||||||||||||||||||
1080 | } never executed: end of block | 0 | ||||||||||||||||||
1081 | - | |||||||||||||||||||
1082 | - | |||||||||||||||||||
1083 | if (__builtin_expect(!!(lcQpaXInputEvents().isDebugEnabled()), false)
| 0 | ||||||||||||||||||
1084 | for (bool qt_category_enabled = lcQpaXInputEvents().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 1120 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d", tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID], ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool) ; | 0 | ||||||||||||||||||
1085 | 0 | |||||||||||||||||||
1086 | __FILE__ never executed: QMessageLogger( __FILE__ , 1120 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d", tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID], ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool) ; | 0 | ||||||||||||||||||
1087 | , never executed: QMessageLogger( __FILE__ , 1120 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d", tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID], ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool) ; | 0 | ||||||||||||||||||
1088 | 0 | |||||||||||||||||||
1089 | 11141120 never executed: QMessageLogger( __FILE__ , 1120 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d", tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID], ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool) ; | 0 | ||||||||||||||||||
1090 | , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d", tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID], ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool) never executed: QMessageLogger( __FILE__ , 1120 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d", tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID], ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool) ; | 0 | ||||||||||||||||||
1091 | 0 | |||||||||||||||||||
1092 | ; never executed: QMessageLogger( __FILE__ , 1120 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d", tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID], ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool) ; | 0 | ||||||||||||||||||
1093 | } never executed: end of block | 0 | ||||||||||||||||||
1094 | XFree(data); | - | ||||||||||||||||||
1095 | } never executed: end of block | 0 | ||||||||||||||||||
1096 | } never executed: end of block | 0 | ||||||||||||||||||
1097 | } never executed: end of block | 0 | ||||||||||||||||||
1098 | break; never executed: break; | 0 | ||||||||||||||||||
1099 | } | - | ||||||||||||||||||
1100 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
1101 | handled = false; | - | ||||||||||||||||||
1102 | break; never executed: break; | 0 | ||||||||||||||||||
1103 | } | - | ||||||||||||||||||
1104 | - | |||||||||||||||||||
1105 | if (xi2MouseEvents() && eventListener) | 0 | ||||||||||||||||||
eventListener->handleXIMouseEvent(reinterpret_cast<xcb_ge_event_t *>(event), Qt::MouseEventSynthesizedByQt);return never executed: handled;return handled; never executed: return handled; | ||||||||||||||||||||
1106 | } | - | ||||||||||||||||||
1107 | - | |||||||||||||||||||
1108 | void QXcbConnection::xi2ReportTabletEvent(TabletData &tabletData,const void *event, TabletData *tabletData) | - | ||||||||||||||||||
1109 | { | - | ||||||||||||||||||
1110 | const xXIDeviceEvent *ev = reinterpret_cast<const xXIDeviceEvent *>(event); | - | ||||||||||||||||||
1111 | QXcbWindow *xcbWindow = platformWindowFromId(ev->event); | - | ||||||||||||||||||
1112 | if (!xcbWindow
| 0 | ||||||||||||||||||
1113 | return; never executed: return; | 0 | ||||||||||||||||||
1114 | QWindow *window = xcbWindow->window(); | - | ||||||||||||||||||
1115 | const double scale = 65536.0; | - | ||||||||||||||||||
1116 | QPointF local(ev->event_x / scale, ev->event_y / scale); | - | ||||||||||||||||||
1117 | QPointF global(ev->root_x / scale, ev->root_y / scale); | - | ||||||||||||||||||
1118 | double pressure = 0, rotation = 0, tangentialPressure = 0; | - | ||||||||||||||||||
1119 | int xTilt = 0, yTilt = 0; | - | ||||||||||||||||||
1120 | - | |||||||||||||||||||
1121 | for (QHash<int, TabletData::ValuatorClassInfo>::iterator it = tabletData.->valuatorInfo.begin(), | - | ||||||||||||||||||
1122 | ite = tabletData.->valuatorInfo.end(); it != ite
| 0 | ||||||||||||||||||
1123 | int valuator = it.key(); | - | ||||||||||||||||||
1124 | TabletData::ValuatorClassInfo &classInfo(it.value()); | - | ||||||||||||||||||
1125 | xi2GetValuatorValueIfSet(event, classInfo.number, &classInfo.curVal); | - | ||||||||||||||||||
1126 | double normalizedValue = (classInfo.curVal - classInfo.minVal) / (classInfo.maxVal - classInfo.minVal); | - | ||||||||||||||||||
1127 | switch (valuator) { | - | ||||||||||||||||||
1128 | case never executed: QXcbAtom::AbsPressure:case QXcbAtom::AbsPressure: never executed: case QXcbAtom::AbsPressure: | 0 | ||||||||||||||||||
1129 | pressure = normalizedValue; | - | ||||||||||||||||||
1130 | break; never executed: break; | 0 | ||||||||||||||||||
1131 | case never executed: QXcbAtom::AbsTiltX:case QXcbAtom::AbsTiltX: never executed: case QXcbAtom::AbsTiltX: | 0 | ||||||||||||||||||
1132 | xTilt = classInfo.curVal; | - | ||||||||||||||||||
1133 | break; never executed: break; | 0 | ||||||||||||||||||
1134 | case never executed: QXcbAtom::AbsTiltY:case QXcbAtom::AbsTiltY: never executed: case QXcbAtom::AbsTiltY: | 0 | ||||||||||||||||||
1135 | yTilt = classInfo.curVal; | - | ||||||||||||||||||
1136 | break; never executed: break; | 0 | ||||||||||||||||||
1137 | case never executed: QXcbAtom::AbsWheel:case QXcbAtom::AbsWheel: never executed: case QXcbAtom::AbsWheel: | 0 | ||||||||||||||||||
1138 | switch (tabletData.->tool) { | - | ||||||||||||||||||
1139 | case never executed: QTabletEvent::Airbrush:case QTabletEvent::Airbrush: never executed: case QTabletEvent::Airbrush: | 0 | ||||||||||||||||||
1140 | tangentialPressure = normalizedValue * 2.0 - 1.0; | - | ||||||||||||||||||
1141 | break; never executed: break; | 0 | ||||||||||||||||||
1142 | case never executed: QTabletEvent::RotationStylus:case QTabletEvent::RotationStylus: never executed: case QTabletEvent::RotationStylus: | 0 | ||||||||||||||||||
1143 | rotation = normalizedValue * 360.0 - 180.0; | - | ||||||||||||||||||
1144 | break; never executed: break; | 0 | ||||||||||||||||||
1145 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
1146 | break; never executed: break; | 0 | ||||||||||||||||||
1147 | } | - | ||||||||||||||||||
1148 | break; never executed: break; | 0 | ||||||||||||||||||
1149 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
1150 | break; never executed: break; | 0 | ||||||||||||||||||
1151 | } | - | ||||||||||||||||||
1152 | } | - | ||||||||||||||||||
1153 | - | |||||||||||||||||||
1154 | if (__builtin_expect(!!(lcQpaXInputEvents().isDebugEnabled()), false)
| 0 | ||||||||||||||||||
1155 | for (bool qt_category_enabled = lcQpaXInputEvents().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 1188 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d " "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotat...Id, tabletData->tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time, fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y), (int)tabletData->buttons, pressure, xTilt, yTilt, rotation) ; | 0 | ||||||||||||||||||
1156 | 0 | |||||||||||||||||||
1157 | 0 | |||||||||||||||||||
1158 | 0 | |||||||||||||||||||
1159 | 0 | |||||||||||||||||||
1160 | __FILE__ never executed: QMessageLogger( __FILE__ , 1188 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d " "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotat...Id, tabletData->tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time, fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y), (int)tabletData->buttons, pressure, xTilt, yTilt, rotation) ; | 0 | ||||||||||||||||||
1161 | , never executed: QMessageLogger( __FILE__ , 1188 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d " "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotat...Id, tabletData->tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time, fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y), (int)tabletData->buttons, pressure, xTilt, yTilt, rotation) ; | 0 | ||||||||||||||||||
1162 | 0 | |||||||||||||||||||
1163 | 0 | |||||||||||||||||||
1164 | 0 | |||||||||||||||||||
1165 | 0 | |||||||||||||||||||
1166 | 11911188 never executed: QMessageLogger( __FILE__ , 1188 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d " "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotat...Id, tabletData->tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time, fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y), (int)tabletData->buttons, pressure, xTilt, yTilt, rotation) ; | 0 | ||||||||||||||||||
1167 | , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d " "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf", tabletData.->deviceId, tabletData.->tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time, fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y), (int)tabletData.->buttons, pressure, xTilt, yTilt, rotation) never executed: QMessageLogger( __FILE__ , 1188 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d " "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotat...Id, tabletData->tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time, fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y), (int)tabletData->buttons, pressure, xTilt, yTilt, rotation) ; | 0 | ||||||||||||||||||
1168 | 0 | |||||||||||||||||||
1169 | 0 | |||||||||||||||||||
1170 | 0 | |||||||||||||||||||
1171 | 0 | |||||||||||||||||||
1172 | ; never executed: QMessageLogger( __FILE__ , 1188 , __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d " "pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotat...Id, tabletData->tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time, fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y), fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y), (int)tabletData->buttons, pressure, xTilt, yTilt, rotation) ; | 0 | ||||||||||||||||||
1173 | - | |||||||||||||||||||
1174 | QWindowSystemInterface::handleTabletEvent(window, ev->time, local, global, | - | ||||||||||||||||||
1175 | tabletData.->tool, tabletData.->pointerType, | - | ||||||||||||||||||
1176 | tabletData.->buttons, pressure, | - | ||||||||||||||||||
1177 | xTilt, yTilt, tangentialPressure, | - | ||||||||||||||||||
1178 | rotation, 0, tabletData.->serialId); | - | ||||||||||||||||||
1179 | } never executed: end of block | 0 | ||||||||||||||||||
1180 | - | |||||||||||||||||||
1181 | QXcbConnection::TabletData *QXcbConnection::tabletDataForDevice(int id) | - | ||||||||||||||||||
1182 | { | - | ||||||||||||||||||
1183 | for (int i = 0; i < m_tabletData.count(); ++i) { | - | ||||||||||||||||||
1184 | if (m_tabletData.at(i).deviceId == id) | - | ||||||||||||||||||
1185 | return &m_tabletData[i]; | - | ||||||||||||||||||
1186 | } | - | ||||||||||||||||||
1187 | return nullptr; | - | ||||||||||||||||||
1188 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |