From 64d7bb9f555afb9e02cdf92d36f75655e7df2f1d Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 17 Feb 2015 17:18:27 +0300 Subject: [PATCH] xcb: Check for the presence of XInput 2.2 before selecting touch events Change-Id: I5309f9cdaadb87e0a577a0701d2c100d29525424 Reviewed-by: Laszlo Agocs Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.h | 10 ++++-- .../platforms/xcb/qxcbconnection_xi2.cpp | 32 ++++++++++--------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 17600839e7f..2a4cfea62d7 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -404,11 +404,15 @@ public: void xi2Select(xcb_window_t window); #endif #ifdef XCB_USE_XINPUT21 - bool isUsingXInput21() { return m_xi2Enabled && m_xi2Minor >= 1; } + bool isUsingXInput21() const { return m_xi2Enabled && m_xi2Minor >= 1; } #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 - void sync(); diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index c63a9c88bc5..f225518cb90 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -274,21 +274,23 @@ void QXcbConnection::xi2Select(xcb_window_t window) unsigned char *xiBitMask = reinterpret_cast(&bitMask); #ifdef XCB_USE_XINPUT22 - bitMask |= XI_TouchBeginMask; - bitMask |= XI_TouchUpdateMask; - bitMask |= XI_TouchEndMask; - XIEventMask mask; - mask.mask_len = sizeof(bitMask); - mask.mask = xiBitMask; - if (!m_touchDevices.isEmpty()) { - mask.deviceid = XIAllMasterDevices; - Status result = XISelectEvents(xDisplay, window, &mask, 1); - // If we select for touch events on the master pointer, XInput2 - // will not synthesize mouse events. This means Qt must do it, - // which is also preferable, since Qt can control better when - // to do so. - if (m_xi2Minor >= 2 && result == Success) - has_touch_without_mouse_emulation = true; + if (isUsingXInput22()) { + bitMask |= XI_TouchBeginMask; + bitMask |= XI_TouchUpdateMask; + bitMask |= XI_TouchEndMask; + XIEventMask mask; + mask.mask_len = sizeof(bitMask); + mask.mask = xiBitMask; + if (!m_touchDevices.isEmpty()) { + mask.deviceid = XIAllMasterDevices; + Status result = XISelectEvents(xDisplay, window, &mask, 1); + // If we select for touch events on the master pointer, XInput2 + // will not synthesize mouse events. This means Qt must do it, + // which is also preferable, since Qt can control better when + // to do so. + if (result == Success) + has_touch_without_mouse_emulation = true; + } } #endif // XCB_USE_XINPUT22