diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2016-02-25 14:39:51 +0300 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-12-08 12:41:04 +0000 |
commit | 2488f34ecfd68702b5508c50cca3fb8e967ac8ea (patch) | |
tree | 244cca0542cb34f8bd731e3af703013e3d09b241 /src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | |
parent | d829dd3f445afae8c74630c4c8b93347b4a7c7bd (diff) |
xcb: Adapt QXcbWindow::startSystemResize() for touch events
Window managers typically grab the pointer after receiving
the _NET_WM_MOVERESIZE event. But they fail to do it for
touch sequences which have a receiver. So we should reject
the touch sequence before sending _NET_WM_MOVERESIZE event.
QSizeGrip calls startSystemResize() on MouseButtonPress event
which is synthesized by Qt on TouchBegin. We can find the id
of the touch point by comparing coordinates of the synthesized
MouseButtonPress event with coordinates of all TouchBegin events.
Then we use this id to reject the touch sequence (it's possible
only after receiving XI_TouchUpdate).
Change-Id: I26519840cd221e28b0be7854e4617c9aba4b0817
Task-number: QTBUG-51385
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection_xi2.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 93f8db92bf..0ace79a4f5 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -61,9 +61,9 @@ struct XInput2TouchDeviceData { XIDeviceInfo *xiDeviceInfo; QTouchDevice *qtTouchDevice; QHash<int, QWindowSystemInterface::TouchPoint> touchPoints; + QHash<int, QPointF> pointPressedPosition; // in screen coordinates where each point was pressed // Stuff that is relevant only for touchpads - QHash<int, QPointF> pointPressedPosition; // in screen coordinates where each point was pressed QPointF firstPressedPosition; // in screen coordinates where the first point was pressed QPointF firstPressedNormalPosition; // device coordinates (0 to 1, 0 to 1) where the first point was pressed QSizeF size; // device size in mm @@ -93,6 +93,7 @@ void QXcbConnection::initializeXInput2() 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 @@ -714,7 +715,21 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo touchPoint.state = Qt::TouchPointMoved; } else if (touchPoint.area.center() != QPoint(x, y)) { touchPoint.state = Qt::TouchPointMoved; - dev->pointPressedPosition[touchPoint.id] = QPointF(x, y); + if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad) + dev->pointPressedPosition[touchPoint.id] = QPointF(x, y); + } + + if (dev->qtTouchDevice->type() == QTouchDevice::TouchScreen && + xiDeviceEvent->event == m_startSystemResizeInfo.window && + xiDeviceEvent->sourceid == m_startSystemResizeInfo.deviceid && + xiDeviceEvent->detail == m_startSystemResizeInfo.pointid) { + QXcbWindow *window = platformWindowFromId(m_startSystemResizeInfo.window); + if (window) { + XIAllowTouchEvents(static_cast<Display *>(m_xlib_display), xiDeviceEvent->deviceid, + xiDeviceEvent->detail, xiDeviceEvent->event, XIRejectTouch); + window->doStartSystemResize(QPoint(x, y), m_startSystemResizeInfo.corner); + m_startSystemResizeInfo.window = XCB_NONE; + } } break; case XI_TouchEnd: @@ -745,6 +760,27 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo touchPoint.state = Qt::TouchPointStationary; } +bool QXcbConnection::startSystemResizeForTouchBegin(xcb_window_t window, const QPoint &point, Qt::Corner corner) +{ + QHash<int, XInput2TouchDeviceData*>::const_iterator devIt = m_touchDevices.constBegin(); + for (; devIt != m_touchDevices.constEnd(); ++devIt) { + XInput2TouchDeviceData *deviceData = devIt.value(); + if (deviceData->qtTouchDevice->type() == QTouchDevice::TouchScreen) { + QHash<int, QPointF>::const_iterator pointIt = deviceData->pointPressedPosition.constBegin(); + for (; pointIt != deviceData->pointPressedPosition.constEnd(); ++pointIt) { + if (pointIt.value().toPoint() == point) { + m_startSystemResizeInfo.window = window; + m_startSystemResizeInfo.deviceid = devIt.key(); + m_startSystemResizeInfo.pointid = pointIt.key(); + m_startSystemResizeInfo.corner = corner; + return true; + } + } + } + } + return false; +} + bool QXcbConnection::xi2SetMouseGrabEnabled(xcb_window_t w, bool grab) { if (grab && !canGrab()) |