From a611c632bb906cf77dd3af29ddd7b166f79ad1b0 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 6 Feb 2018 17:21:13 +0100 Subject: Add QWindow::startSystemMove and startSystemResize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can be used to create custom client side window decorations. Refactors the xcb implementation to use edges instead of corners and we now use the last mouse position for `root_x` and `root_y` in the `_NET_WM_MOVERESIZE` event. Touch has also been changed, so just pick a point that's currently being pressed. The workaround for QTBUG-69716 has now been moved to QSizeGrip, as the comment in the bug report says that it should ideally be fixed at the widget level. On Windows, we no longer abort when GetSystemMenu returns false. I assume this code was added to check whether the window didn't have any decorations and not resize in that case. However, since the point of this patch is to let windows without native decorations resize/move, it makes most sense to remove the check. Adds a manual test, which calls QWindow::startSystemMove and startSystemResize on touch and mouse events. [ChangeLog][QtGui] Added API for starting interactive window resize and move operations handled by the system. Fixes: QTBUG-73011 Change-Id: I7e47a0b2cff182af71d3d479d6e3746f08ea30aa Reviewed-by: Friedemann Kleint Reviewed-by: Qt CI Bot Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms/xcb/qxcbconnection_xi2.cpp') diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 2d114c51b3..4620f0fd1d 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -753,7 +753,7 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo xcb_input_xi_allow_events(xcb_connection(), XCB_CURRENT_TIME, xiDeviceEvent->deviceid, XCB_INPUT_EVENT_MODE_REJECT_TOUCH, xiDeviceEvent->detail, xiDeviceEvent->event); - window->doStartSystemMoveResize(QPoint(x, y), m_startSystemMoveResizeInfo.corner); + window->doStartSystemMoveResize(QPoint(x, y), m_startSystemMoveResizeInfo.edges); m_startSystemMoveResizeInfo.window = XCB_NONE; } } @@ -787,19 +787,20 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo touchPoint.state = Qt::TouchPointStationary; } -bool QXcbConnection::startSystemMoveResizeForTouchBegin(xcb_window_t window, const QPoint &point, int corner) +bool QXcbConnection::startSystemMoveResizeForTouch(xcb_window_t window, int edges) { QHash::const_iterator devIt = m_touchDevices.constBegin(); for (; devIt != m_touchDevices.constEnd(); ++devIt) { TouchDeviceData deviceData = devIt.value(); if (deviceData.qtTouchDevice->type() == QTouchDevice::TouchScreen) { - QHash::const_iterator pointIt = deviceData.pointPressedPosition.constBegin(); - for (; pointIt != deviceData.pointPressedPosition.constEnd(); ++pointIt) { - if (pointIt.value().toPoint() == point) { + auto pointIt = deviceData.touchPoints.constBegin(); + for (; pointIt != deviceData.touchPoints.constEnd(); ++pointIt) { + Qt::TouchPointState state = pointIt.value().state; + if (state == Qt::TouchPointMoved || state == Qt::TouchPointPressed || state == Qt::TouchPointStationary) { m_startSystemMoveResizeInfo.window = window; m_startSystemMoveResizeInfo.deviceid = devIt.key(); m_startSystemMoveResizeInfo.pointid = pointIt.key(); - m_startSystemMoveResizeInfo.corner = corner; + m_startSystemMoveResizeInfo.edges = edges; return true; } } -- cgit v1.2.3