From 50a4b97d3160d45a5dcadc68d08f04b2e9efa16d Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 26 May 2021 11:23:29 +0200 Subject: [PATCH] xcb: fix QWindow::startSystemMove()/Resize() triggered by touch Abort the system move/resise at XCB_INPUT_TOUCH_END. Limit the behavior only on supported platforms, such as KDE and OpenBox. Change-Id: I53c86979ca56f4de8c5cf2807f781abdad6987b2 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.cpp | 11 +++++++++-- src/plugins/platforms/xcb/qxcbconnection.h | 4 +--- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 5 +++++ src/plugins/platforms/xcb/qxcbwindow.cpp | 6 ++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 58a4a8ea04a..e1c9bf80fc9 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -96,8 +96,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra m_eventQueue = new QXcbEventQueue(this); - m_xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP").toLower(); - if (hasXRandr()) xrandrSelectEvents(); @@ -795,6 +793,15 @@ void QXcbConnection::ungrabServer() xcb_ungrab_server(xcb_connection()); } +QString QXcbConnection::windowManagerName() const +{ + QXcbVirtualDesktop *pvd = primaryVirtualDesktop(); + if (pvd) + return pvd->windowManagerName().toLower(); + + return QString(); +} + xcb_timestamp_t QXcbConnection::getTimestamp() { // send a dummy event to myself to get the timestamp from X server. diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 556e6b10028..a7db3eda89a 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -213,8 +213,7 @@ public: void grabServer(); void ungrabServer(); - bool isUnity() const { return m_xdgCurrentDesktop == "unity"; } - bool isGnome() const { return m_xdgCurrentDesktop == "gnome"; } + QString windowManagerName() const; QXcbNativeInterface *nativeInterface() const { return m_nativeInterface; } @@ -378,7 +377,6 @@ private: friend class QXcbEventQueue; - QByteArray m_xdgCurrentDesktop; QTimer m_focusInTimer; }; diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 0e79f35d60f..4657c2ac898 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -648,6 +648,9 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) if (xiEvent->event_type == XCB_INPUT_BUTTON_RELEASE && xiEvent->detail == XCB_BUTTON_INDEX_1 ) { abortSystemMoveResize(xiEvent->event); + } else if (xiEvent->event_type == XCB_INPUT_TOUCH_END) { + abortSystemMoveResize(xiEvent->event); + return; } else { return; } @@ -921,6 +924,8 @@ bool QXcbConnection::startSystemMoveResizeForTouch(xcb_window_t window, int edge m_startSystemMoveResizeInfo.deviceid = devIt.key(); m_startSystemMoveResizeInfo.pointid = pointIt.key(); m_startSystemMoveResizeInfo.edges = edges; + setDuringSystemMoveResize(true); + qCDebug(lcQpaXInputDevices) << "triggered system move or resize from touch"; return true; } } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 122e89f22eb..ea8e1f479dc 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2332,8 +2332,10 @@ bool QXcbWindow::startSystemMoveResize(const QPoint &pos, int edges) // ### FIXME QTBUG-53389 bool startedByTouch = connection()->startSystemMoveResizeForTouch(m_window, edges); if (startedByTouch) { - if (connection()->isUnity()) { - // Unity fails to move/resize via _NET_WM_MOVERESIZE (WM bug?). + const QString wmname = connection()->windowManagerName(); + if (wmname != QLatin1String("kwin") && wmname != QLatin1String("openbox")) { + qCDebug(lcQpaXInputDevices) << "only KDE and OpenBox support startSystemMove/Resize which is triggered from touch events: XDG_CURRENT_DESKTOP=" + << qgetenv("XDG_CURRENT_DESKTOP"); connection()->abortSystemMoveResize(m_window); return false; }