diff options
author | Liang Qi <liang.qi@qt.io> | 2021-05-26 11:23:29 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2021-06-16 15:53:22 +0200 |
commit | 50a4b97d3160d45a5dcadc68d08f04b2e9efa16d (patch) | |
tree | 2718c2d64070053f8c81245f01ee661ebc60b3be /src/plugins/platforms/xcb | |
parent | 8e506fdd299d2fa18172209bea316f484e234e19 (diff) |
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 <shawn.rutledge@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.cpp | 11 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 5 | ||||
-rw-r--r-- | 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 58a4a8ea04..e1c9bf80fc 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 556e6b1002..a7db3eda89 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 0e79f35d60..4657c2ac89 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 122e89f22e..ea8e1f479d 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; } |