xcb: Check for the presence of XInput 2.2 before selecting touch events

Change-Id: I5309f9cdaadb87e0a577a0701d2c100d29525424
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
Alexander Volkov 2015-02-17 17:18:27 +03:00 committed by Shawn Rutledge
parent cb95fff1c7
commit 64d7bb9f55
2 changed files with 24 additions and 18 deletions

View File

@ -404,11 +404,15 @@ public:
void xi2Select(xcb_window_t window); void xi2Select(xcb_window_t window);
#endif #endif
#ifdef XCB_USE_XINPUT21 #ifdef XCB_USE_XINPUT21
bool isUsingXInput21() { return m_xi2Enabled && m_xi2Minor >= 1; } bool isUsingXInput21() const { return m_xi2Enabled && m_xi2Minor >= 1; }
#else #else
bool isUsingXInput21() { return false; } bool isUsingXInput21() const { return false; }
#endif
#ifdef XCB_USE_XINPUT22
bool isUsingXInput22() const { return m_xi2Enabled && m_xi2Minor >= 2; }
#else
bool isUsingXInput22() const { return false; }
#endif #endif
void sync(); void sync();

View File

@ -274,21 +274,23 @@ void QXcbConnection::xi2Select(xcb_window_t window)
unsigned char *xiBitMask = reinterpret_cast<unsigned char *>(&bitMask); unsigned char *xiBitMask = reinterpret_cast<unsigned char *>(&bitMask);
#ifdef XCB_USE_XINPUT22 #ifdef XCB_USE_XINPUT22
bitMask |= XI_TouchBeginMask; if (isUsingXInput22()) {
bitMask |= XI_TouchUpdateMask; bitMask |= XI_TouchBeginMask;
bitMask |= XI_TouchEndMask; bitMask |= XI_TouchUpdateMask;
XIEventMask mask; bitMask |= XI_TouchEndMask;
mask.mask_len = sizeof(bitMask); XIEventMask mask;
mask.mask = xiBitMask; mask.mask_len = sizeof(bitMask);
if (!m_touchDevices.isEmpty()) { mask.mask = xiBitMask;
mask.deviceid = XIAllMasterDevices; if (!m_touchDevices.isEmpty()) {
Status result = XISelectEvents(xDisplay, window, &mask, 1); mask.deviceid = XIAllMasterDevices;
// If we select for touch events on the master pointer, XInput2 Status result = XISelectEvents(xDisplay, window, &mask, 1);
// will not synthesize mouse events. This means Qt must do it, // If we select for touch events on the master pointer, XInput2
// which is also preferable, since Qt can control better when // will not synthesize mouse events. This means Qt must do it,
// to do so. // which is also preferable, since Qt can control better when
if (m_xi2Minor >= 2 && result == Success) // to do so.
has_touch_without_mouse_emulation = true; if (result == Success)
has_touch_without_mouse_emulation = true;
}
} }
#endif // XCB_USE_XINPUT22 #endif // XCB_USE_XINPUT22