xcb: don't allow isAtLeastXI2{1,2} in builds without Xinput2

.. 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 <allan.jensen@qt.io>
This commit is contained in:
Gatis Paeglis 2017-06-04 12:30:32 +02:00
parent af00fe5d89
commit f8c42ea891
2 changed files with 4 additions and 8 deletions

View File

@ -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();

View File

@ -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;
}