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>
This commit is contained in:
Liang Qi 2021-05-26 11:23:29 +02:00
parent 8e506fdd29
commit 50a4b97d31
4 changed files with 19 additions and 7 deletions

View File

@ -96,8 +96,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
m_eventQueue = new QXcbEventQueue(this); m_eventQueue = new QXcbEventQueue(this);
m_xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP").toLower();
if (hasXRandr()) if (hasXRandr())
xrandrSelectEvents(); xrandrSelectEvents();
@ -795,6 +793,15 @@ void QXcbConnection::ungrabServer()
xcb_ungrab_server(xcb_connection()); 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() xcb_timestamp_t QXcbConnection::getTimestamp()
{ {
// send a dummy event to myself to get the timestamp from X server. // send a dummy event to myself to get the timestamp from X server.

View File

@ -213,8 +213,7 @@ public:
void grabServer(); void grabServer();
void ungrabServer(); void ungrabServer();
bool isUnity() const { return m_xdgCurrentDesktop == "unity"; } QString windowManagerName() const;
bool isGnome() const { return m_xdgCurrentDesktop == "gnome"; }
QXcbNativeInterface *nativeInterface() const { return m_nativeInterface; } QXcbNativeInterface *nativeInterface() const { return m_nativeInterface; }
@ -378,7 +377,6 @@ private:
friend class QXcbEventQueue; friend class QXcbEventQueue;
QByteArray m_xdgCurrentDesktop;
QTimer m_focusInTimer; QTimer m_focusInTimer;
}; };

View File

@ -648,6 +648,9 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event)
if (xiEvent->event_type == XCB_INPUT_BUTTON_RELEASE if (xiEvent->event_type == XCB_INPUT_BUTTON_RELEASE
&& xiEvent->detail == XCB_BUTTON_INDEX_1 ) { && xiEvent->detail == XCB_BUTTON_INDEX_1 ) {
abortSystemMoveResize(xiEvent->event); abortSystemMoveResize(xiEvent->event);
} else if (xiEvent->event_type == XCB_INPUT_TOUCH_END) {
abortSystemMoveResize(xiEvent->event);
return;
} else { } else {
return; return;
} }
@ -921,6 +924,8 @@ bool QXcbConnection::startSystemMoveResizeForTouch(xcb_window_t window, int edge
m_startSystemMoveResizeInfo.deviceid = devIt.key(); m_startSystemMoveResizeInfo.deviceid = devIt.key();
m_startSystemMoveResizeInfo.pointid = pointIt.key(); m_startSystemMoveResizeInfo.pointid = pointIt.key();
m_startSystemMoveResizeInfo.edges = edges; m_startSystemMoveResizeInfo.edges = edges;
setDuringSystemMoveResize(true);
qCDebug(lcQpaXInputDevices) << "triggered system move or resize from touch";
return true; return true;
} }
} }

View File

@ -2332,8 +2332,10 @@ bool QXcbWindow::startSystemMoveResize(const QPoint &pos, int edges)
// ### FIXME QTBUG-53389 // ### FIXME QTBUG-53389
bool startedByTouch = connection()->startSystemMoveResizeForTouch(m_window, edges); bool startedByTouch = connection()->startSystemMoveResizeForTouch(m_window, edges);
if (startedByTouch) { if (startedByTouch) {
if (connection()->isUnity()) { const QString wmname = connection()->windowManagerName();
// Unity fails to move/resize via _NET_WM_MOVERESIZE (WM bug?). 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); connection()->abortSystemMoveResize(m_window);
return false; return false;
} }