From f8c42ea8913da919f221b92dc2de67058a982e1a Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Sun, 4 Jun 2017 12:30:32 +0200 Subject: [PATCH] xcb: don't allow isAtLeastXI2{1,2} in builds without Xinput2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .. thus making it purely into a _runtime_ check of XInput 2 version. If Qt was build with -no-xinput2, it does not make sense to compile in code that always returns "false". Simply exclude code that is not relevant for -no-xinput2 builds with XCB_USE_XINPUT2 ifdefs. In addition, this improves readability of the code. Now, trying to use ::isAtLeastXI21() in a -no-xinput2 build will result in the following build error: error: ‘class QXcbConnection’ has no member named ‘isAtLeastXI21’ Change-Id: If242510d43d71829b327edc1f76322f3a0db0e08 Reviewed-by: Allan Sandfeld Jensen --- src/plugins/platforms/xcb/qxcbconnection.h | 8 -------- src/plugins/platforms/xcb/qxcbwindow.cpp | 4 ++++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index bda212b08b..b4c9a1f62a 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -428,16 +428,8 @@ public: #if QT_CONFIG(xinput2) void xi2Select(xcb_window_t window); -#endif -#ifdef XCB_USE_XINPUT21 bool isAtLeastXI21() const { return m_xi2Enabled && m_xi2Minor >= 1; } -#else - bool isAtLeastXI21() const { return false; } -#endif -#ifdef XCB_USE_XINPUT22 bool isAtLeastXI22() const { return m_xi2Enabled && m_xi2Minor >= 2; } -#else - bool isAtLeastXI22() const { return false; } #endif void sync(); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 7a15caaac6..c3d00b53bf 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2185,7 +2185,9 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in QPoint global(root_x, root_y); if (isWheel) { +#if QT_CONFIG(xinput2) if (!connection()->isAtLeastXI21()) { +#endif QPoint angleDelta; if (detail == 4) angleDelta.setY(120); @@ -2198,7 +2200,9 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in if (modifiers & Qt::AltModifier) std::swap(angleDelta.rx(), angleDelta.ry()); QWindowSystemInterface::handleWheelEvent(window(), timestamp, local, global, QPoint(), angleDelta, modifiers); +#if QT_CONFIG(xinput2) } +#endif return; }