aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* DeliveryAgent: stop sending hovering mouse moves to grabberShawn Rutledge2025-08-131-5/+4
| | | | | | | | | | | | | | | | | | | | For applications running under Qt Wayland compositors, touch events may be accompanied by fake mouse moves coming from the touchscreen device. That might or might not be useful: but since most of Qt Quick ignores such stray mouse moves, and PinchHandler was getting deactivated by them, we now make an effort to avoid delivering them to PinchHandler after it has become the exclusive grabber of those touchpoints (which looks the same as being the grabber of "that" mouse). Added a reminder to the handlePointerEvent() comment that tablet events are different: hover events are not enough, in fact we need to deliver TabletMove events to HoverHandler so that it has a chance to change the cursor (i.e. keep the tst_HoverHandler::deviceCursor test working). Pick-to: 6.8 6.9 6.10 Fixes: QTBUG-123985 Change-Id: I513caf277e2fb87401b3e0bb5547f9623467b423 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* tests: do not leak QPointingDevice instancesShawn Rutledge2025-05-101-24/+23
| | | | | | | | | QTest::createTouchDevice() passes ownership of the device to the caller, so make sure it gets deleted. Pick-to: 6.8 6.9 Change-Id: I1289def6b40bf688a7334b9997f7e4319516d018 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Tests: include QTest, not QtTestGiuseppe D'Angelo2025-04-151-1/+1
| | | | | | | | | | | | | Never use module-wide inclusions. They blow up build times. For QtTest this is usually just a typo (QTest was meant instead). Add missing includes as needed. In the diffs I've spotted other huge inclusions (QtQuick, QtQml), but those need more attention. Task-number: QTQAINFRA-7110 Pick-to: 6.9 6.8 Change-Id: I74bf3fe212f50a7a3a6af2b1c80bbcaabc2516d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qquickpointerhandler: fix warning about mismatched enums; ctor castsShawn Rutledge2025-02-241-13/+13
| | | | | | | | | | | | | | | | | | | | | | | The GrabTransition enum has no "none" value: there's no reason we need one for public API. But this test records events and transitions, and needs a way to record that no grab transition happened. It's just an int anyway, so QCOMPARE_EVENT simply casts it before comparison; and in any ternary-if expression using NoGrab, we cast both arms to int. The warning was warning: enumerated mismatch in conditional expression: ‘<unnamed enum>’ vs ‘QPointingDevice::GrabTransition’ [-Wenum-compare] 549 | QEventPoint::State::Pressed, itemIgnoreMouse ? NoGrab : QPointingDevice::GrabExclusive); | ^ Next, there is -Wint-in-bool-context: fixed by surrounding the ternary if's with parentheses. Replace C-style with constructor-style casts while we're at it. Change-Id: I0796abc8e19c1842a6b2f4e343d566ff0cc226e6 Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
* Refactor, clarify and generalize tst_PointerHandlers::mouseEventDeliveryShawn Rutledge2024-09-261-130/+153
| | | | | | | | | | | | | | | | - findChild() doesn't need a string argument if there's only one instance of the type, and thus nothing to disambiguate - initialize member variables where declared - rename pointer->point - move relevant behavior flags from EventItem to EventHandler - since press events arrive pre-accepted, it makes more sense to test what happens if we ignore() - test all combinations of an item and/or handler ignoring the event - we could test weird combinations like a handler that ignores the event but also grabs... but aren't doing that so far Change-Id: I6b9da7120c779ad9d9cffc2ef468fdafb087bc20 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* tst_qquickpointerhandler: add Q_OBJECTGiuseppe D'Angelo2024-04-041-0/+1
| | | | | | | | | | The EventHandler class is used in calls to findChild. This requires it to have a Q_OBJECT macro since ce2585d0e9 in qtbase. Add the macro. Pick-to: 6.7 Change-Id: Iea8233231e32f4fcd73a75c6c385e06e9edd11ed Reviewed-by: Matthias Rauter <matthias.rauter@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Correct license for test filesLucie Gérard2024-02-271-1/+1
| | | | | | | | | | | | | | According to QUIP-18 [1], all test files should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I26d72e8de04d4c7c57b3b7838af5d033265de5ba Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix pointer delivery to child items of items with clip:trueJan Arve Sæther2023-07-111-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | QQuickDeliveryAgentPrivate::pointerTargets() can visit a lot of items and their handlers, before actual event delivery really starts. One optimization in place since 6adc36115f4fc658fb907ee8af3013f2609ae761 is that if an item is clipped, and the point is outside its bounds, we can be sure that it's also irrelevant to the item's children, because the parts of any children that may be under that point are clipped away and invisible. At the time that was written, QQuickItem::contains() was only doing a simple bounding-rect check. Since then, bf74a908cb0591c2adc024a6f93d566c7348c125 added containmentMask; and we should also keep in mind the precedence of the PointerHandler.margin property (currently, TapHandler.margin does not expand the sensitive area beyond a clipped Rectangle, or beyond the containmentMask either). So it seems we now need to check clipRect().contains() explicitly: a child item may be outside its parent's containmentMask, and containmentMask does not affect clipping, so one would expect to still be able to interact with the child. The current definition of clipRect() is from 9b62f4c27ac3fb3dc563c7f4657094c14d752bac. It's virtual, but documented as "the region intended to remain visible if clip is true". Fixes: QTBUG-115179 Pick-to: 5.15 6.2 6.5 6.6 Change-Id: I6ae8f492b99725459cdff2a89ac8508da5167102 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add test case for reparenting item while handler holds grabVolker Hilsheimer2023-07-041-0/+51
| | | | | | | | | | | | | | | | | | | | | This is a partial port of 7cf29f3250cb48842eba25815ce46ca8065f8e6e to Qt 6. The crash that the change fixes in Qt 5.15 doesn't happen in Qt 6, make sure that we don't introduce issues later. We don't get grabChanged signals emitted when the item gets reparented, so it's likely that the handler still holds the grab, it just doesn't cause any problems for this particular scenario. The test counting signal emissions is expected to fail in Qt 6, we can't clear up the grab as we don't have a currentEvent in the handler at the point of item scene change anymore. Task-number: QTBUG-114475 Pick-to: 6.6 6.5 Change-Id: I1cc39174c4b9b5ed1d5868610d6eacf0151cff5f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* qquickpointerhandler_p.h: Clean up includesFabian Kosmale2022-10-191-0/+2
| | | | | | | | | | | | | | | | | The referenced bug report specifically complained about warnings caused by including qquickpointerhandler_p.h. All of those -Wshorten-64-to-32 warnings come from headers that aren't strictly needed for qquickpointerhandler_p, though. So fix the issue by only including what is actually need, which also slightly improves compile times. This requires adding a few transitive includes in select places. As a drive-by, remove the unneeded QML_DECLARE_TYPE. Fixes: QTBUG-105055 Change-Id: I24d78e7131771a4bbcb402e6838a5a9a11abbbec Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add QQDAPriv::allPointsGrabbed() and stop using QPointerEvent::apg()Shawn Rutledge2022-07-131-19/+20
| | | | | | | | | | | | | | | QPointerEvent::allPointsGrabbed() was implemented wrong in qtbase 8932e80d0c8879a1e720fef825ed0d9c4e384a01. Fixing it has ramifications for event delivery; so it's easier to take care of that in one patch in qtdeclarative first, rather than causing a submodule update crisis, and then fix the public QPointerEvent version afterwards. It fits nicely alongside anyPointGrabbed() anyway. Pick-to: 6.2 6.3 6.4 Task-number: QTBUG-101932 Change-Id: I4141a492c941963e5eb716b63d3e09f9ae165c57 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-27/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Do not rely on transitive includes in testsFabian Kosmale2022-02-141-0/+1
| | | | | Change-Id: Icb68dbecab6f675352cd58333c82fa6648025367 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Allow reparenting Pointer HandlersShawn Rutledge2021-12-101-0/+37
| | | | | | | | | | | | [ChangeLog][Event Handlers] The parent property of any Pointer Handler is now settable. Fixes: QTBUG-84730 Task-number: QTBUG-85926 Task-number: QTBUG-17286 Change-Id: Id738dd783de1acfbef9b5be203025040b0913008 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Consolidate test helpers into private librariesMitch Curtis2021-09-131-5/+6
| | | | | | | | | | | | | | | | | | | | Previously each test would include and build sources from the shared folder. Now we make those sources a library, build it once, then have each test link to it instead. We also take the opportunity to move some helpers that qtquickcontrols2 had added into the quicktestutils library where it makes sense, and for the helpers that don't make sense to be there, move them into quickcontrolstestutils. We add the libraries to src/ so that they are internal modules built as part of Qt, rather than tests. That way we can use them in a standalone test outside of qtdeclarative. Task-number: QTBUG-95621 Pick-to: 6.2 Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* PointerHandler constructor: add to Item parent's list of handlersShawn Rutledge2021-05-261-0/+37
| | | | | | | | | | | | | When a pointer handler is created in C++, a parent Item might be given to the constructor, so QQuickItemPrivate::data_append() might not be called. But to be functional, it needs to be added to ExtraData.pointerHandlers. Task-number: QTBUG-68110 Change-Id: I02f6574f801018b964ecf4167bac65792d9c6094 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add dynamically-created pointer handlers to parent's resourcesShawn Rutledge2021-05-261-0/+7
| | | | | | Fixes: QTBUG-94005 Change-Id: I609620627682e3e95c284adf897b08007e3e0726 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Mark overrides in tests, fix compiler warningsVolker Hilsheimer2021-04-011-9/+9
| | | | | | Change-Id: If753558d911e50a73e351a93eed2e4df3e6592c7 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix some "can be marked override" warningsAndreas Buhr2021-02-231-1/+1
| | | | | | Change-Id: I13da0d085901314950c4fa0afb5853e183652e67 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Don't synthesize mouse from touch for items that accept touchShawn Rutledge2020-11-171-33/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Followup to 1457df74f4c1d770e1e820de8cd082be1bd2489e : if an item that has acceptTouchEvents() == true merely fails to accept one touch event, that does not mean a mouse event should be sent. Finish changing the default to false: handling touch events is opt-in, just like handling mouse events; most items don't. And if you opt in, then you MUST handle touch events, because you will NOT receive mouse events as a fall-back. Now that Flickable handles touch, filtering multi-touch events becomes relevant. There was a failure in tst_touchmouse::mouseOnFlickableOnPinch when Flickable grabs a stationary touchpoint at the same time as another touchpoint is pressed, preventing a child PinchArea from reacting. So there's a new rule: just as we start over with event delivery when a new point is pressed, QQuickFlickable::filterPointerEvent() should also not immediately grab when any point is newly pressed; it can afford to wait, because it's filtering, so it will be able to see if one point is dragged past the drag threshold later on. When a parent (such as Flickable) contains only mouse-handling items (such as MouseArea), the parent should filter the touch event if it is able (if acceptTouchEvents() returns true). Flickable is now able to. Filtering parents that are not able to filter touch events can still filter a synth-mouse event as before. But filtering both must be avoided: then we would have the problem that Flickable filters a touch move, sees that it's being dragged past the drag threshold, and sets d->stealMouse to true to indicate that it wants to steal the _next_ event; then it filters a synth-mouse move, and that's perceived as being the next event even though it's just a different view of the same event, so it steals it. In tst_qquickflickable::nestedMouseAreaUsingTouch we rely on the delay caused by waiting for the next event: the MouseArea is trying to drag an item and the Flickable wants to flick; both of them decide on the same event that the drag threshold is exceeded. But MouseArea calls setKeepMouseGrab() immediately, whereas Flickable doesn't try to steal the grab until the next event, and then it sees the keepMouseGrab flag has been set, so it doesn't do it. If Flickable could filter the same event twice (once as touch, once as synth-mouse), this logic doesn't work, so it's effectively "more grabby" than intended. So it works better to have it filter only the actual touch event, not the synth-mouse that comes after. When the child has pointer handlers, we need to visit them, and therefore we should let Flickable filter a touch event on the way. tst_FlickableInterop::touchDragFlickableBehindButton() depends on this. [ChangeLog][QtQuick][QQuickWindow] In Qt 6, a QQuickItem subclass must explicitly call setAcceptTouchEvents(true) to receive QTouchEvents, and then it must handle them: we no longer fall back to sending a QMouseEvent if the touch event is not accepted. If it has additionally called setFiltersChildMouseEvents(true), then it will filter touch events, not any synthetic mouse events that may be needed for some children. Task-number: QTBUG-87018 Fixes: QTBUG-88169 Change-Id: I8784fe097198c99c754c4ebe205bef8fe490f6f4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix tst_PointerHandlers::touchReleaseOutsideShawn Rutledge2020-10-271-1/+3
| | | | | | | | | In Qt 6, setAcceptTouchEvents(true) must be done explicitly for an item to receive touch events. Task-number: QTBUG-86729 Change-Id: Ib18db22b6a7213dfcfdf091d554ef60fbede6111 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix tst_PointerHandlers::mouseEventDeliveryShawn Rutledge2020-10-271-7/+17
| | | | | | | | PointerHandlers see more events now. Task-number: QTBUG-86729 Change-Id: I4dbddc8b54292450cf5ffb77489178a8a824b90d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix tst_PointerHandlers::touchEventDeliveryShawn Rutledge2020-10-271-18/+34
| | | | | | Task-number: QTBUG-86729 Change-Id: I47a0a4aad7cff956b2ebd450870d625f817690d4 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Remove QQuickPointerEvent etc.; deliver QPointerEvents directlyShawn Rutledge2020-09-181-47/+50
| | | | | | | | | | | | | | | | | | | | | | | QEventPoint does not have an accessor to get the QPointerEvent that it came from, because that's inconsistent with the idea that QPointerEvent instances are temporary, stack-allocated and movable (the pointer would often be wrong or null, therefore could not be relied upon). So most functions that worked directly with QQuickEventPoint before (which fortunately are still private API) now need to receive the QPointerEvent too, which we choose to pass by pointer. QEventPoint is always passed by reference (const where possible) to be consistent with functions in QPointerEvent that take QEventPoint by reference. QEventPoint::velocity() should be always in scene coordinates now, which saves us the trouble of transforming it to each item's coordinate system during delivery, but means that it will need to be done in handlers or applications sometimes. If we were going to transform it, it would be important to also store the sceneVelocity separately in QEventPoint so that the transformation could be done repeatedly for different items. Task-number: QTBUG-72173 Change-Id: I7ee164d2e6893c4e407fb7d579c75aa32843933a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace QTouchEvent::TouchPoint with QEventPointShawn Rutledge2020-07-151-72/+72
| | | | | | | | | | | | It's a cosmetic change at this time, because we have declared using TouchPoint = QEventPoint; Also replace Qt::TouchPointState enum with QEventPoint::State. Task-number: QTBUG-72173 Change-Id: Ife017aa98801c28abc6cccd106f47a95421549de Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove QQuickPointerDevice in favor of QPointingDeviceShawn Rutledge2020-06-231-3/+3
| | | | | | | | | | | | | | ...and generally deal with changes immediately required after adding QInputDevice and QPointingDevice. Also fixed a few usages of deprecated accessors that weren't taken care of in 212c2bffbb041aee0e3c9a7f0551ef151ed2d3ad. Task-number: QTBUG-46412 Task-number: QTBUG-69433 Task-number: QTBUG-72167 Change-Id: I93a2643162878afa216556f10808fd92e0b20071 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Replace calls to deprecated QEvent accessor functionsShawn Rutledge2020-06-111-7/+7
| | | | | | | | | | | | | | | | | | | | Several event accessors were deprecated in qtbase/24e52c10deedbaef833c0e2c3ee7bee03eacc4f5. Replacements were generated by clazy using the new qevent-accessors check: $ export CLAZY_CHECKS=qevent-accessors $ export CLAZY_EXPORT_FIXES=1 $ ../qt6/configure -platform linux-clang -developer-build -debug -no-optimize-debug -opensource -confirm-license -no-pch QMAKE_CXX=clazy $ make $ cd ../../qt6/qtdeclarative $ find . -name "*.clazy.yaml" $ clang-apply-replacements . Task-number: QTBUG-20885 Task-number: QTBUG-84775 Change-Id: I1be5819506fd5039e86b4494223acbe193e6b0c9 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Make test more robust in case we have interleaved update eventsJan Arve Saether2019-02-131-6/+10
| | | | | | | | | This could for instance happen if the window gets exposed under the cursor, and it sends a mouse move event that might interleave the press and release events, causing the eventCount variable to jump to 3. Change-Id: Icce59b2aa1a937a990baa83f503907633003e2bb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Ensure that each Event Handler has an Item parent rather than assertingShawn Rutledge2018-12-071-0/+25
| | | | | | | | | | QQuickItemPrivate::data_append() was already getting called, but the assert (that the parent was already an Item) was failing in case a handler was declared inside a Window or a Dialog. Fixes: QTBUG-71317 Change-Id: Ia497182e3b4a9722eee97a375f9ee5d4151108e6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add dynamically-created Event Handlers to the relevant handlers vectorShawn Rutledge2018-12-071-4/+61
| | | | | | | | | | | | | | | | | If any kind of Pointer Handler is created dynamically in JS by calling Component.createObject(), QObject::setParent() is called rather than passing the parent to the constructor, so QQuickItemPrivate::data_append() did not take care of adding the handler to QQuickItemPrivate's extra->pointerHandlers vector. We need to use the auto-parent mechanism (just as we did with handling dynamic creation of nested Windows in 8cb02e23abbefc9d020707fc1a2d8b6eb4e103b6). Added QQuickItemPrivate::addPointerHandler() to put the prepend() and implied setAcceptedMouseButtons() in one place. Fixes: QTBUG-71427 Change-Id: I3be3dd033c1c89e6e5b5c3463e1a720bbe963281 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Rename QQEventPoint::GrabState to GrabTransitionShawn Rutledge2018-08-311-13/+13
| | | | | | | | | | | | | | | | | | | This enum represents a transient state transition, and only sometimes corresponds to the current grab state of an event point. For example after exclusive grab has been canceled, the current state is that there is no exclusive grab: it doesn't make sense to remember that the way it got there was by cancellation. There was an idea to add a grabState property, but not all values would be eligible. An EventPoint can be exclusively grabbed by one item or handler at a time, and by multiple passive grabbers at the same time, so even a Q_FLAG would not fully express all possible states. Besides, there is already an exclusiveGrabber property, and we could add a passiveGrabbers list property if we had a real need. So adding a grabState property seems unlikely, and therefore is not a good enough reason to keep this enum named as GrabState. Change-Id: Ie37742b4bd431a7e51910d79a7223fba9a6bd848 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QQuickWindow: obey AA_SynthesizeMouseForUnhandledTouchEventsShawn Rutledge2018-08-061-27/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, AA_SynthesizeMouseForUnhandledTouchEvents has only affected behavior of QGuiApplicationPrivate::processTouchEvent, but had no effect in Qt Quick. QQuickWindow also accepts the touch event just to make sure that QGuiApplication will not synthesize mouse from touch, because it would be redundant: QQuickWindow does that for itself. Now we make it have an effect in Qt Quick too: skip mouse synthesis if it is set to false. This provides a way to simplify the event delivery. If you set it false, then you cannot manipulate old mouse-only items like MouseArea and Flickable on a touchscreen. (You can of course use event handlers for that.) [ChangeLog][QtQuick][QQuickWindow] You can now disable touch->mouse event synthesis in QtQuick by calling qGuiApp.setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, false); This will simplify and speed up event delivery, and it will also prevent any and all interaction with mouse-only items like MouseArea and Flickable on a touchscreen. Task-number: QTBUG-52748 Change-Id: I71f1731b5abaeabd9dbce1112cd23bc97d24c12a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-2/+2
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Do not stop delivering to handlers if all points are acceptedJan Arve Saether2018-01-311-7/+8
| | | | | | | | | | | Some Pointer Handlers can perform the desired interaction using only passive grabs. When such a handler is used to modify behavior of another event-handling Item or Handler which needs to take the exclusive grab, this allows them to cooperate: both can see the updates, and neither prevents delivery of events to both. Change-Id: I312cc301c52fcdf805245bbe0ac60fd28f92c01f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* rename QQuickEventPoint pos properties to positionShawn Rutledge2017-09-051-2/+2
| | | | | | | | For consistency we always spell it out, although it does make some of these properties inconveniently verbose. Change-Id: I64a08c3aa261c0ab89e09472dd47510abafbf7ca Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Merge remote-tracking branch 'origin/dev' into wip/pointerhandlerJan Arve Saether2017-07-111-1/+1
| | | | | | | | | | | Conflicts: examples/quick/shared/LauncherList.qml src/quick/items/qquickevents.cpp src/quick/items/qquickevents_p_p.h src/quick/items/qquickwindow.cpp tests/auto/quick/touchmouse/tst_touchmouse.cpp Change-Id: Id692d291455093fc72db61f1b854f3fc9190267b
* Add tst_PointerHandlers::touchReleaseOutsideShawn Rutledge2017-05-261-0/+57
| | | | | | | | to verify when a point is pressed on a PointerHandler, dragged outside, and released, the handler gets a release event, or a cancel. Change-Id: Icdcb67c5549aca605bc6e7b425978760330ba270 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* tst_qquickpointerhandler: Test grab changesShawn Rutledge2017-05-241-61/+90
| | | | | | | | Now an Event could represent a QEvent, a PointerEvent, or a call to onGrabChanged, so we can test the sequence more thoroughly. Change-Id: Ib935cda8dfc87c37d917989423615688dc9c260c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* tst_qquickpointerhandler: Remove unused includes; better debug outputShawn Rutledge2017-05-191-19/+19
| | | | | Change-Id: I1e0539fe24e19ca15641fa4007488b33c24ab8ba Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* tst_qquickpointerhandler: use QScopedPointer; improvementsShawn Rutledge2017-05-111-81/+103
| | | | | | | | | | | | | | | | | It's now standard practice in autotests to use QScopedPointer to manage the window so that it doesn't need to be deleted (or would be left dangling if the test fails). It's nice to be able to see the bounds of the EventItem. Test not only the order of the event types received, but the EventPoint state, and where they were received. Of course PointerEvents go only to PointerHandlers in this test so far... but now we can distinguish filtered events from events which were received via the QQuickItem virtual function overrides. Change-Id: I4830a431bedb7101c8c980ab3260d23b5852b645 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* clarify further exclusive vs. passive grabsShawn Rutledge2017-02-201-3/+3
| | | | | | | | | | Add documentation to the grab-related event and eventpoint methods. Rename "grabber" functions which relate only to the exclusive grab, in cases where it would otherwise be ambiguous. And a few other documentation changes. Change-Id: I1a203c8c06a19d4abdb000f08b387c38341ef476 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* allow stealing grab from handlers; notify passive grabbers when stolenShawn Rutledge2017-02-161-14/+13
| | | | | | | | | | | | | Now if a Button with a TapHandler is pressed and has only a passive grab, Flickable can take the exclusive grab, and it notifies the TapHandler so that the button can go back to released state. This reverts parts of commit e2fd141372335f917c2d216051abb00d8b15f87c such that more of tst_PointerHandlers is working the same as it was before we started adding the passive grab concept. Change-Id: I88970716fcbbfb066a313fcefb233cf9263da944 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* start making explicit exclusive or passive grabsShawn Rutledge2017-02-101-3/+3
| | | | | Change-Id: I4a6e3c72d69e893fec2e39f4faab24af6d00c7e0 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QQuickWindow: use QVector eventDeliveryTargets to avoid repeated deliveryShawn Rutledge2017-02-071-10/+8
| | | | | | | | | | | | | | | | If no handler or item accepts a newly-pressed point, the event will be re-delivered in deliverTouchEvent(). It doesn't make sense to re-deliver to the same handlers though. A temporary QSet isn't cheap to create, whereas it seems we will need to keep track of handlers which have already been visited, in order to avoid visiting passively-grabbing handlers multiple times. Since both a QVector and a QSet are heap-allocated, and we expect to have a limited quantity of handlers grabbing at one time, a retained QVector (cleared between events) seems to be the cheapest data structure. Change-Id: I831e9a2576b2fcb9095e065795f2baff58115a49 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QQuickWindow: deliver updates to handlers even if they don't grabShawn Rutledge2017-02-021-24/+33
| | | | | | | | | | The "weak grab" concept depends on this. First we deliver to grabbers, then we deliver to non-grabbing handlers (but not to non-grabbing items). Avoid re-delivering to grabbing handlers which already received the same event. Change-Id: If51e1cd9372e3bed1daea3758e9ef8e37c0ba5e3 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* move qquickpointerhandler test to a subdirectoryShawn Rutledge2016-09-021-0/+465
Tests will become too complex to do them all in one class, so let's have a subdirectory for each handler. Change-Id: I157f6c150f15ca53d77bc9eb716723c6105e393a Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>