diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 43 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 6 |
3 files changed, 30 insertions, 21 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 498e93aea0..bda212b08b 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -553,7 +553,7 @@ private: bool compressEvent(xcb_generic_event_t *event, int currentIndex, QXcbEventArray *eventqueue) const; #if QT_CONFIG(xinput2) bool m_xi2Enabled = false; - int m_xi2Minor = 2; + int m_xi2Minor = -1; void initializeXInput2(); void xi2SetupDevices(); struct TouchDeviceData { diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 61a48cfc9b..1deab2a6c5 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -57,29 +57,39 @@ void QXcbConnection::initializeXInput2() const_cast<QLoggingCategory&>(lcQpaXInput()).setEnabled(QtDebugMsg, true); if (qEnvironmentVariableIsSet("QT_XCB_DEBUG_XINPUT_DEVICES")) const_cast<QLoggingCategory&>(lcQpaXInputDevices()).setEnabled(QtDebugMsg, true); + Display *xDisplay = static_cast<Display *>(m_xlib_display); if (XQueryExtension(xDisplay, "XInputExtension", &m_xiOpCode, &m_xiEventBase, &m_xiErrorBase)) { int xiMajor = 2; - // try 2.2 first, needed for TouchBegin/Update/End - if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) { - m_xi2Minor = 1; // for smooth scrolling 2.1 is enough - if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) { - m_xi2Minor = 0; // for tablet support 2.0 is enough - m_xi2Enabled = XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) != BadRequest; - } else - m_xi2Enabled = true; - } else +#if defined(XCB_USE_XINPUT22) + m_xi2Minor = 2; // for touch support 2.2 is enough +#elif defined(XCB_USE_XINPUT21) + m_xi2Minor = 1; // for smooth scrolling 2.1 is enough +#else + m_xi2Minor = 0; // for tablet support 2.0 is enough +#endif + qCDebug(lcQpaXInput, "Plugin build with support for XInput 2 version up " + "to %d.%d", xiMajor, m_xi2Minor); + + switch (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor)) { + case Success: + // Server's supported version can be lower than the version we have + // announced to support. In this case Qt client will be limited by + // X server's supported version. + qCDebug(lcQpaXInput, "Using XInput version %d.%d", xiMajor, m_xi2Minor); m_xi2Enabled = true; - if (m_xi2Enabled) { #ifdef XCB_USE_XINPUT22 - qCDebug(lcQpaXInputDevices, "XInput version %d.%d is available and Qt supports 2.2 or greater", xiMajor, m_xi2Minor); m_startSystemResizeInfo.window = XCB_NONE; -#else - qCDebug(lcQpaXInputDevices, "XInput version %d.%d is available and Qt supports 2.0", xiMajor, m_xi2Minor); #endif + xi2SetupDevices(); + break; + case BadRequest: // Must be an X server with XInput 1 + qCDebug(lcQpaXInput, "X server does not support XInput 2"); + break; + default: // BadValue + qCDebug(lcQpaXInput, "Internal error"); + break; } - - xi2SetupDevices(); } } @@ -91,9 +101,6 @@ void QXcbConnection::xi2SetupDevices() m_scrollingDevices.clear(); m_touchDevices.clear(); - if (!m_xi2Enabled) - return; - Display *xDisplay = static_cast<Display *>(m_xlib_display); int deviceCount = 0; XIDeviceInfo *devices = XIQueryDevice(xDisplay, XIAllDevices, &deviceCount); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index e6f89fbdb4..7ea60d7fde 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2451,12 +2451,14 @@ void QXcbWindow::handleXIEnterLeave(xcb_ge_event_t *event) case XI_Enter: { const int event_x = fixed1616ToInt(ev->event_x); const int event_y = fixed1616ToInt(ev->event_y); - qCDebug(lcQpaXInput, "XI2 mouse enter %d,%d, mode %d, detail %d, time %d", event_x, event_y, ev->mode, ev->detail, ev->time); + qCDebug(lcQpaXInputEvents, "XI2 mouse enter %d,%d, mode %d, detail %d, time %d", + event_x, event_y, ev->mode, ev->detail, ev->time); handleEnterNotifyEvent(event_x, event_y, root_x, root_y, ev->mode, ev->detail, ev->time); break; } case XI_Leave: - qCDebug(lcQpaXInput, "XI2 mouse leave, mode %d, detail %d, time %d", ev->mode, ev->detail, ev->time); + qCDebug(lcQpaXInputEvents, "XI2 mouse leave, mode %d, detail %d, time %d", + ev->mode, ev->detail, ev->time); connection()->keyboard()->updateXKBStateFromXI(&ev->mods, &ev->group); handleLeaveNotifyEvent(root_x, root_y, ev->mode, ev->detail, ev->time); break; |