From 25feb2fe3e393dd1820bb4ee8c4105fb088de045 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 8 Jul 2021 11:53:42 +0200 Subject: xcb: update connection time when possible At least we try to do it with all events triggered by user. Pick-to: 5.15 6.1 6.2 Change-Id: I28b399a2517600f7da2c91a50fecdf58b9d81fb6 Reviewed-by: JiDe Zhang Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.cpp | 21 ++++++++++++++++++--- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/xcb') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 86d1c6cd90..b5b9b72ca8 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -579,6 +579,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent); case XCB_BUTTON_PRESS: { auto ev = reinterpret_cast(event); + setTime(ev->time); m_keyboard->updateXKBStateFromCore(ev->state); // the event explicitly contains the state of the three first buttons, // the rest we need to manage ourselves @@ -591,6 +592,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) } case XCB_BUTTON_RELEASE: { auto ev = reinterpret_cast(event); + setTime(ev->time); if (m_duringSystemMoveResize && ev->root != XCB_NONE) abortSystemMoveResize(ev->root); m_keyboard->updateXKBStateFromCore(ev->state); @@ -603,6 +605,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) } case XCB_MOTION_NOTIFY: { auto ev = reinterpret_cast(event); + setTime(ev->time); m_keyboard->updateXKBStateFromCore(ev->state); m_buttonState = (m_buttonState & ~0x7) | translateMouseButtons(ev->state); if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) @@ -643,14 +646,19 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) // Prefer XI2 enter (XCB_INPUT_ENTER) events over core events. break; } + setTime(reinterpret_cast(event)->time); HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent); case XCB_LEAVE_NOTIFY: + { if (hasXInput2()) { // Prefer XI2 leave (XCB_INPUT_LEAVE) events over core events. break; } - m_keyboard->updateXKBStateFromCore(reinterpret_cast(event)->state); + auto ev = reinterpret_cast(event); + setTime(ev->time); + m_keyboard->updateXKBStateFromCore(ev->state); HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent); + } case XCB_FOCUS_IN: HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_in_event_t, event, handleFocusInEvent); case XCB_FOCUS_OUT: @@ -658,13 +666,18 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) case XCB_KEY_PRESS: { auto keyPress = reinterpret_cast(event); + setTime(keyPress->time); m_keyboard->updateXKBStateFromCore(keyPress->state); setTime(keyPress->time); HANDLE_KEYBOARD_EVENT(xcb_key_press_event_t, handleKeyPressEvent); } case XCB_KEY_RELEASE: - m_keyboard->updateXKBStateFromCore(reinterpret_cast(event)->state); + { + auto keyRelease = reinterpret_cast(event); + setTime(keyRelease->time); + m_keyboard->updateXKBStateFromCore(keyRelease->state); HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent); + } case XCB_MAPPING_NOTIFY: m_keyboard->updateKeymap(reinterpret_cast(event)); break; @@ -672,6 +685,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) { #if QT_CONFIG(draganddrop) || QT_CONFIG(clipboard) auto selectionRequest = reinterpret_cast(event); + setTime(selectionRequest->time); #endif #if QT_CONFIG(draganddrop) if (selectionRequest->selection == atom(QXcbAtom::XdndSelection)) @@ -696,11 +710,12 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) break; case XCB_PROPERTY_NOTIFY: { + auto propertyNotify = reinterpret_cast(event); + setTime(propertyNotify->time); #ifndef QT_NO_CLIPBOARD if (m_clipboard->handlePropertyNotify(event)) break; #endif - auto propertyNotify = reinterpret_cast(event); if (propertyNotify->atom == atom(QXcbAtom::_NET_WORKAREA)) { QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window); if (virtualDesktop) diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 4657c2ac89..c0bd2c6165 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -639,6 +639,7 @@ static inline qreal fixed1616ToReal(xcb_input_fp1616_t val) void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) { auto *xiEvent = reinterpret_cast(event); + setTime(xiEvent->time); if (m_xiSlavePointerIds.contains(xiEvent->deviceid)) { if (!m_duringSystemMoveResize) return; -- cgit v1.2.3