aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickpointerhandler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add effectivelyClipsEventHandlingChildren; skip event delivery when irrelevantShawn Rutledge2025-11-171-0/+5
| | | | | | | | | | | | | | | If a QEventPoint is clearly outside an item _and_ the bounds of all its children, or is simply outside the bounds of an item that clips its children, we can stop recursion, for purposes of QPointerEvent delivery, finding which items/handlers are hovered, or which could control the cursor shape. effectivelyClipsEventHandlingChildren() is also recursive, but at least the result gets cached. Task-number: QTBUG-140340 Task-number: QTBUG-115179 Change-Id: I085e38964de6993fa82ad3bd1256868125fde090 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Reduce QTransform use in event delivery and cursor-finding functionsShawn Rutledge2025-11-111-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pass localPos to deliverHoverEventRecursive, deliverHoverEventToItem and sendHoverEvent, so that deliverHoverEventRecursive() can merely transform from its own coordinate space to each child's space by calling itemToParentTransform(). That doesn't require up-the-tree recursion like mapFromScene() does. Apply the same trick to QQuickWindowPrivate::findCursorItemAndHandler(). Apply the same trick to QQuickPointerHandler::parentContains(local, scene): now QQuickPointerHandler::parentContains(QEventPoint) also calls that with both local and scene positions, which it already has, so this likely optimizes some use cases outside of the hover and cursor cases. But to make that work, we need to apply the same trick to QQuickDeliveryAgentPrivate::eventTargets() as well, and now it needs to localize the QEventPoint before calling the predicate. Usually, global position is QGuiApplicationPrivate::lastCursorPosition; but when no mouse events occur, only touch events, lastCursorPosition may remain offscreen. So we use the QEventPoint::globalPosition when possible; so it's useful to pass globalPos along to each of these hover functions, so that deliverHoverEventToItem() can construct the QMouseEvent with it, and sendHoverEvent() can construct the QHoverEvent with it. Also amends f5140d62082e9b06e0ca6c8e2175b5836286f52e: that looked rather CPU-intensive to call several mapping functions. The test is retained. Task-number: QTBUG-134099 Task-number: QTBUG-140340 Change-Id: I2c520d430e58ec7c00ada2207541b2936c7ae596 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Doc: Mark internal APIs with \internal commandJerome Pasion2025-11-071-1/+10
| | | | | | | | | | | These internal APIs have function documentation but are missing class documentation. Adding an internal class documentation fixes QDoc warnings. Task-number: QTBUG-141697 Change-Id: Iecb289d39e34ddaa964fbe0a1404830cd2269caa Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Set explicit default security level of all files with default securityJan Arve Sæther2025-09-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The files (folders) already processed are listed in each issue in epic QTBUG-134547 These files were processed half a year ago. In order to make it clear that all of these files are already processed, mark them with an explicit default security header. For the record, this was generated with this script: find -E . -regex ".*\.(cpp|h|hpp|mm|qml|js)$" | xargs python3 ~/bin/add-cra-header.py in the folders listed in each subtask of QTBUG-134547 (add-cra-header.py only exist at my desktop, but it simply adds the default security header if it doesn't already have any existing security header) QUIP: 23 Fixes: QTBUG-134547 Pick-to: 6.10 6.9 6.8 Change-Id: Ieb8c78ea6561fdbdd27c7b13185ece853eedf80f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* PointerHandler: Add handler to parent also on componentComplete()Oliver Eftevaag2025-07-181-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | It was possible for a handler to not be added to its parent item via data_append() when the handler is created as a property binding: ``` Item { id: parentItem property HoverHandler handler: HoverHandler { parent: parentItem } } ``` In that case, the HoverHandler won't be added to the parent item's default list property (data), since it's being assigned to a different property instead (handler). data_append() was the main way that pointer handlers installed themselves to items, but it is skipped in this case. Now we also call QQuickItemPrivate::addPointerHandler() in componentComplete() if the pointer handler was not already added. Pick-to: 6.10 Change-Id: I5c797f6abcfb19af7e897354fba39dd536e66140 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Ensure TapHandler.pressed==false when deactivated; tolerate null eventShawn Rutledge2025-03-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dating back at least to 507efe5a8a2390813fb620a91b0b3b6b383f599d the initial plan was that an ungrab calls setActive(false), and that ought to be enough, because every pointer handler can react to deactivation in its own way. But QQuickTapHandler did not override onActiveChanged(); and it would still not work very well to do that, because setPressed() takes various arguments that are not available in onActiveChanged(). So an odd state of dubious utility was possible: it could be inactive and pressed at the same time. That's now prevented, as long as TapHandler relies on an exclusive grab. If a TapHandler's window is deactivated while it has an exclusive grab, onGrabChanged() is called with a null event, because the deactivation event is not a pointer event. Don't crash, and don't get stuck in pressed state either. Currently in this scenario, the grab transition is UngrabExclusive, not CancelGrabExclusive. If we are sure that a TapHandler should no longer be pressed if its window is no longer active, and one symptom is that it's ungrabbed, probably it makes sense to be consistent that when it loses any kind of grab that it has taken, it should no longer be pressed. But then we would run into the issue with the null event as described above. So these changes are best done together. If a TapHandler's window is deactivated while it has a passive grab, the TapHandler cannot be deactivated or un-pressed, because it is not in active state in the first place. (As documented, `active` means it has an exclusive grab.) Fixes: QTBUG-118454 Fixes: QTBUG-124777 Change-Id: I855a0e0ddcb13866af5501f6164b6b18b41dda2a Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Doc: Replace \instantiates with \nativetypePaul Wicking2024-08-201-1/+1
| | | | | | | | | | | Since the implementation of the `\nativetype`-command in QDoc, the `\instantiates`-command is deprecated. Replace the use of the deprecated command in favor of its replacement. Pick-to: 6.8 Task-number: QTBUG-128216 Change-Id: I23d9f66d3f6db2e5f827d7868497a432bb9b0626 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* QtQuick: Straighten out some logging categoriesUlf Hermann2024-06-191-3/+2
| | | | | | | | | | | | Either make them static or declare them in a header. We want them to be static wherever possible, in order to reduce the number of visible symbols. If they can't be static, however, they should at least be declared in only one place. Task-number: QTBUG-67692 Change-Id: I485bb7e4379e86f72619f848399ad58c76586851 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix PointHandler rejecting click events near window edge with HiDPIFushan Wen2024-03-161-3/+3
| | | | | | | | | | | | | | When using HiDPI and a click happens near the window edge, the global position might have fractional parts, but after the global position is converted to QPoint, the position can be rounded so it happens to stay at the window edge, so the window geometry will not contain the rounded position. Related bugreport: https://bugs.kde.org/show_bug.cgi?id=482580 Pick-to: 6.6 6.7 Change-Id: I51a26f955fd58f2a135c64ceb32ee881a03fcaf8 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Update cursor if frame-synchronous hover update discovers hover changeShawn Rutledge2023-11-181-0/+3
| | | | | | | | | | | | Also mark cursor as dirty and force update after shape change. Done-with: Matthias Rauter <matthias.rauter@qt.io> Fixes: QTBUG-53987 Fixes: QTBUG-90457 Task-number: QTBUG-54019 Pick-to: 6.5 6.6 Change-Id: I64d9f5d0a39dbf141a8e82bee824b47a8884139b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Include what you need: <QPointer>Marc Mutz2023-10-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | All these TUs relied on transitive includes of qpointer.h, maybe to a large extent via qevent.h, though, given that qevent.h is more or less the only public QtBase header that includes qpointer.h, something else seems to be at play here. Said qevent.h actually needs QPointer in-name-only, so a forward declaration would suffice. Prepare for qevent.h dropping the include. The algorithm I used was: If the TU mentions 'passiveGrabbers', the name of the QEvent function that returns QPointers, and the TU doesn't have qpointer.h included explicitly, include it. That may produce False Positives, but better safe than sorry. Otherwise, in src/, add an include to all source and header files which mention QPointer. Exception: if foo.h of a foo.cpp already includes it, don't include again. Task-number: QTBUG-117670 Change-Id: I9b98cda524a0e6a61be7805edda708916bb2bc2b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Fix minor documentation issuesTopi Reinio2023-09-151-1/+1
| | | | | | | | | | | | | | | | * src/qmlcompiler/qqmlsa.cpp:925: Fix linking to global Qt object * src/quick/handlers/qquickpointerhandler.cpp:881: Mark a member of QQuickPointerHandlerPrivate as \internal * src/quick/items/qquickrendercontrol.cpp:636: Fix malformed link to QRhi::[begin|end]OffscreenFrame(). In passing, replace unnecessary usage of \badcode with \code. Pick-to: 6.6 Change-Id: I8fd333929fb082215ccac16cca351afcf0e00696 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Fix qdoc warningsAndreas Eliasson2023-08-091-5/+8
| | | | | | | | | | Make sure \li is inside \list \endlist. Also, fix some punctuation. Pick-to: 6.6 6.5 Change-Id: Ic877e391b17b4b008f9f8543019f3944eb264475 Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Add more internal docs in QQuickDeliveryAgent and its PrivateShawn Rutledge2023-07-121-3/+9
| | | | | | | | Try to explain pointer event delivery better. Change-Id: I015170fbf94f3e7d06d329223730426362f884fe Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Add internal PointerHandler docs; arrange accessors together with docsShawn Rutledge2023-07-071-31/+149
| | | | | | | | | | | When subclassing to make a custom handler, there are several things to know, so it's good to get some docs in place. Task-number: QTBUG-68110 Task-number: QTBUG-111013 Pick-to: 6.6 Change-Id: I4bd296cf1b312df8b76be9bf403ae01bbb34eb72 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Use correct names for QEventPoint::State, PointerDevice::GrabTransitionShawn Rutledge2023-04-141-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Qt::TouchPointState is not the actual type here, and we should not encourage e.g. making a comparison between eventPoint.state and Qt.TouchPointMoved in an onGrabChanged handler. The equivalence is an internal detail; and eventPoint can come from any pointing device, not only from a touchscreen. QEventPoint is a Q_GADGET; we keep the registration to expose it as a value type (eventPoint). But such types cannot be created in QML, and we also need to give it an uppercase name to scope the enum values that it declares: that's a new foreign namespace called EventPoint. So it's possible to compare an eventPoint instance's state property against EventPoint.Pressed, and so on. Also show complete QML syntax in the \value tables where PointerDevice::GrabTransition is emitted to QML, namely PointerDevice::grabChanged and PointerHandler::grabChanged. Amends b43a873264d012dc0a0e574ea53335a40af8aa38 Task-number: QTBUG-102160 Change-Id: If1a97f21d8e005e3692298b8512f7f8b56a92c97 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Remove duplicate words (typos)Andreas Eliasson2023-03-071-1/+1
| | | | | | Pick-to: 6.5 6.4 6.2 Change-Id: Ibd29739b894598e5d7837ed5f9150e08ca07fa35 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* doc: Update QML eventPoint; fix GrabTransition linkShawn Rutledge2023-02-211-9/+9
| | | | | | | | | | | | | | | | | | | | Amends outdated stuff from 507efe5a8a2390813fb620a91b0b3b6b383f599d and c248a32fe69dfe1c685105d0c6aeaeb15d7ba29f. "eventPoint" should now always link to docs added in b43a873264d012dc0a0e574ea53335a40af8aa38. Replace the phrase "event point" with a link to the QML eventPoint value type. QPointingDevice is called PointerDevice in QML, so the GrabTransition enum ought to be found in those docs, in theory, for use in the PointerHandler::grabChanged doc. Pick-to: 6.2 6.4 6.5 Task-number: QTBUG-102160 Task-number: QTBUG-104761 Change-Id: I5d1a8dedd9d98e6dee3fbca457aa38f42ea7bfb1 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Pointer handlers: don't emit canceled() when an extra button interruptsShawn Rutledge2022-12-151-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the intention is that a handler should react only to the left mouse button (by default, acceptedButtons == Qt.LeftButton), and the user presses the right button while the handler is already active, it de-activates, because wantsPointerEvent() returns false. But now it will no longer emit canceled() in that case. The docs for the canceled signal say "If this handler has already grabbed the given point, this signal is emitted when the grab is stolen by a different Pointer Handler or Item." But in this case the handler gives up its grab voluntarily, it's not being stolen by anything else. Probably we were emitting canceled because it's intuitive that the gesture is being canceled because something weird happened. But that's not the documented reason for emitting this signal, and it's perhaps inconsistent with the fact that dragging can be resumed. The mechanism for emitting when another handler or item takes over the grab begins in QPointingDevicePrivate::setExclusiveGrabber(), which emits grabChanged(), which is connected to QQuickDeliveryAgentPrivate::onGrabChanged(), which will call onGrabChanged() on the handler, and the base class implementation QQuickPointerHandler::onGrabChanged() will emit canceled(). At least in this case a handler does not need to decide on its own to emit. [ChangeLog][QtQuick][Event Handlers] A Pointer Handler no longer emits the canceled() signal when it deactivates due to violating conditions (such as pressing the right button when acceptedButtons == LeftButton). Fixes: QTBUG-102201 Pick-to: 6.5 Change-Id: Ibe67c8f2a5e44d96df3a788ca1ee4e43f7de658d 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 FOREIGN declaration for QEventPointSami Shalayel2022-11-111-2/+2
| | | | | | | | | | | | Add a foreign declaration to QEventPoint such that qml compilers can work correctly with it. Also fix the links to eventPointer in the documentation, and duplicate the list of properties of the C++ api. Fixes: QTBUG-107624 Change-Id: I11c4a4a416a40d40fc7ce45d7f894406035a6d87 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickHoverHandler: listen for parent changes, and update hasHoverInChildRichard Moe Gustavsen2022-10-311-1/+4
| | | | | | | | | | | | | | | | | | | A QQuickHoverHandler is normally created by the QML engine, but can sometimes also be created directly from C++. And for the latter case, QQuickHoverHandler::componentComplete() will not be called. This causes a problem, since it takes care of subscribing for hover events on the parent item. To support creating hover handlers from c++, we therefore need to also subscribe to hover events from the constructor. Moreover, since the parentItem can change at runtime, we also need a virtual function that informs it when the parent item changes, so that we can remove hover subscription from the old parent, and subscribe for it on the new parent. Pick-to: 6.4 Change-Id: I52f3cd16d6bbfbbe2e4c3c019efdc7f06c5f2c31 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickHoverHandler: setHasHoverInChild to false when disabledRichard Moe Gustavsen2022-09-161-0/+2
| | | | | | | | | | | | | | | | Toggle setHasHoverInChild in sync with the handler being enabled. This fixes a bug: if a HoverHandler is hovered, and somehow the enabled property is programmatically set to false with no mouse moveement and without any other scenegraph changes (i.e. no item gets marked dirty and therefore flushFrameSynchronousEvents() doesn't run), its hovered property now changes to false immediately, as it should. The DA will get less items to traverse, so this is also an optimization. Pick-to: 6.4 Change-Id: I24be7d25ee15180fff010cc1c532266cd6e73ffb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Ensure that multiple HoverHandlers can react to multiple device typesShawn Rutledge2022-08-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | 1c44804600ad3dbeb60d1f5209ce9cf937d30ab3 had some known incompleteness in QQuickItemPrivate::effectiveCursorHandler because it couldn't be finished in Qt 5; but HoverHandlers with different acceptedDevices and acceptedPointerTypes were working together in Qt 6.0 and 6.1 to an extent. Perhaps for this case it helped that HoverHandlers got passive grabs, but we stopped that in bbcc2657fa0dbf715e6db7d675662e4be94a1e04. So now, as with mouse events, we need to ensure that when a HoverHandler detects a particular stylus device in a QTabletEvent and chooses a different cursor, it is applied to the window. At this time, since QQuickDeliveryAgentPrivate::deliverHoverEvent() sends a synth-mouse event, it's not suitable for tablet hover; so we depend on correct implementation of allPointsGrabbed() to ensure that QQuickDeliveryAgentPrivate::deliverUpdatedPoints() will visit all the HoverHandlers, in this case only. Pick-to: 6.3 6.4 Fixes: QTBUG-101932 Change-Id: Ia8f31610e9252825afc7151be58765ac5217b0e8 Reviewed-by: Doris Verria <doris.verria@qt.io>
* doc: Add missing PointerHandler.CanTakeOverFromItems enum valueShawn Rutledge2022-08-161-0/+2
| | | | | | | | Amends 0a3eec60cab3c453b378ee45ac335e0dc2951f4b Pick-to: 6.2 6.3 6.4 5.15 Change-Id: Iae9d1b2b68dc48a52adf0438a09af8e53f5527f1 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Consistently set and reset QQuickPointerHandler's currentEventVolker Hilsheimer2022-07-111-3/+4
| | | | | | | | | | | Set the pointer before we deliver to the handler implementation, and reset to nullptr afterwards. Fixes: QTBUG-104325 Pick-to: 6.4 6.3 6.2 Change-Id: I37ddcb7b20760867ebfd3f23449c6a83088926aa Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+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>
* Quick: includemocsMarc Mutz2022-04-291-0/+2
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102948 Change-Id: I695daa12613de3bada67eb69a26a8dce07c4b85e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Code tidiesZhang Hao2022-01-261-1/+1
| | | | | | | Delete the conditional judgment that must be established Change-Id: I2db7292cb368a979821336d5a639df9fb8e7e959 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Allow reparenting Pointer HandlersShawn Rutledge2021-12-101-1/+15
| | | | | | | | | | | | [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>
* HoverHandler: allow cursorShape binding before parentItem is setShawn Rutledge2021-12-031-6/+18
| | | | | | | | | | | | | | | When a HoverHandler is declared in a Window, the handler's bindings are evaluated before QQuickItemPrivate::data_append() is called to add the handler to the window's content item. So we need null pointer checks again (as we have for a lot of calls to parentItem() already). And to ensure that the declared cursorShape actually is shown, we need to check again in componentComplete(). And don't forget to call the parent class implementation whenever overriding any virtual function. Fixes: QTBUG-98717 Pick-to: 6.2 5.15 Change-Id: Id0defac7a238df522e8eee69f71e83a3947560af Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Fix more documentation issuesTopi Reinio2021-06-161-2/+2
| | | | | | | | | | | | | | * Screen QML type is moved under the main QtQuick import * XmlListModel types are their own documentation project, add a dependency to qtquick.qdocconf. * Remove QDoc comment identifiers from internal, undocumented class. * Fix linking to Qt Creator manual. * Fix linking to QtQuick3D.Model. Pick-to: 6.2 Change-Id: I3b48165c04ef84288472963e39eafc0868c14c49 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Check for null pointer in QQuickPointerHandler::approveGrabTransition()Shawn Rutledge2021-06-041-2/+3
| | | | | | | | | | Found by static analysis: https://testresults.qt.io/codechecker/daily_diffs/qtdeclarative/dev/qtdeclarative-dev-20210604-1285b67a11/qquickpointerhandler.cpp_51058486.html#reportHash=9b76a76200c3a2eceb0e115776dda98b Amends b09ce7dcd8ecf24ef23da8197a64e3fced3fc894 Pick-to: 6.1 Change-Id: I4c35f648be9513e5e237d9b8d4e502e40e9f8a76 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow pointer handlers to be added to QQuick3DModel objectsShawn Rutledge2021-06-031-3/+12
| | | | | | | | | | | | | | | | | | | | | | Mainly it's a matter of removing the assumption that parent() is always a QQuickItem. But handlers that have a target property do not know how to manipulate it when it's not an item; so for example you can use DragHandler's translation property to manipulate the object, but it doesn't drag a 3D object by default. Delivery logic for now is implemented in QQuick3DViewport, because it's intimately tied to picking, and QQuickDeliveryAgent doesn't really know anything about QQ3D objects, and the conventional delivery to handlers in Qt Quick depends on QQuickItemPrivate::handlePointerEvent() which isn't available in that use case. Hover events are interfering with DragHnadler (wantsPointerEvent() returns false, therefore the handler gets deactivated right away). HoverHandler detects hover but does not detect leave, but that's probably a matter for the delivery logic to fix. Change-Id: Id0ec385ce8df3a003f72a6666d16632cef72bbd6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* PointerHandler constructor: add to Item parent's list of handlersShawn Rutledge2021-06-011-6/+6
| | | | | | | | | | | | Amends 2d1ec2f84953f93fb661d442cd4207e7f0198e4b to fix the other constructor and delegate to it. QQuickTapHandler(parent) -> QQuickSinglePointHandler(parent) -> QQuickPointerDeviceHandler(QQSinglePtHandlerPriv, parent) -> QQuickPointerHandler(priv, parent) so in the intended use case, this is the constructor that counts. Change-Id: I856b3825609fa7601b50f6a7a69c46563dc9a34f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* PointerHandler constructor: add to Item parent's list of handlersShawn Rutledge2021-05-261-0/+7
| | | | | | | | | | | | | 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>
* Don't let PointerHandler steal mouse grab from keepMouseGrab layerShawn Rutledge2021-05-201-8/+17
| | | | | | | | | | | | | | | As explained in the comment, the handler can override the keepMouseGrab "veto" if the item is a parent (like a Flickable) that filters events, but not in other cases. The logic was wrong though, apparently. Amends 090f404cf80da35734f712b02cc1543acecd5b62 Pick-to: 5.15 6.1 Fixes: QTBUG-78258 Task-number: QTBUG-79163 Change-Id: I9a473ab3b23743f863cb0be13767fdbc29cd5e1c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Enhance approveGrabTransition log messageShawn Rutledge2021-05-141-2/+3
| | | | | | | | Show the existing grabber, not only the proposed grabber. Pick-to: 6.1 Change-Id: Idd1b41f96b063793c3c97aa67aa4425e2d58a027 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Map window coordinates to the same coordinate system as the QPointerEvent pointAlexey Edelev2021-05-111-1/+4
| | | | | | | | | | | If the window has parent windows its geometry should be mapped to the global coordinates before check if it contains the point coordinates. Fixes: QTBUG-91716 Pick-to: 5.15 6.1 Change-Id: I300547361dbe895b67caeee0d47f416426444552 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Use QQDeliveryAgent::sceneTransform, if set, in QQuickItem::mapFromGlobalShawn Rutledge2021-05-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During dragging of a QEventPoint, Flickable computes the drag delta as pos - mapFromGlobal(point.globalPressPosition()) We cannot use only the global position delta, because the Flickable might be transformed in 2D (by setting rotation on it or in a parent, as in tst_qquickflickable::clickAndDragWhenTransformed) or in 3D (by mapping it onto a Model object). So we really need QQuickItem::mapFromGlobal() to actually work regardless how many of these transformations are in place. This is just the beginning: we have a lot of these mapFrom/To functions; but it's enough for the Flickable in the quick3d/dynamictexture example to work better. Without this fix, if you tried to drag a yellow note on the door panel, at the very first drag ListView saw a large delta and considered its drag threshold exceeded immediately, whereas the DragHandler on the note saw a very small delta; so ListView grabbed and DragHandler did not steal it: it relies on having "first dibs". When the drag threshold is exceeded, Flickable merely plans to grab on the next event rather than grabbing immediately, and therefore a child has a chance to grab first. Therefore it's normally OK for DragHandler to simply become the first exclusive grabber when the drag threshold is exceeded, and not steal the grab from another item (although grabPermissions can be changed to allow stealing if necessary). However this means that we continue to enforce the drag threshold in local (transformed) coordinates: if Flickable should wait until the user drags 10 pixels, but it's scaled to half-size, it will start dragging after only 5 pixels of movement, for example. Pick-to: 6.1 Task-number: QTBUG-92944 Change-Id: Id01cc833ca80850ca18a965adf47f435e43e20ed Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix build without features.gesturesTasuku Suzuki2021-04-161-0/+2
| | | | | | Change-Id: I9c5cb83ad45b7af7060fee2fed593da7efae7158 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PinchHandler: scale incrementally when new pinch gesture beginsShawn Rutledge2021-03-251-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | When the gesture begins, we begin multiplying the target item's scale by 1.0 at first; it doesn't make sense to start immediately with the accumulated scale remembered from previous pinch gestures, because the target item remembers its own scale. When QQuickPinchHandler::wantsPointerEvent() returns false because some irrelevant gesture was received (for example a PanNativeGesture), that's not a good reason to deactivate. Deactivating and re-activating with each ZoomNativeGesture event results in extreme behavior, because PinchHandler depends on the BeginNativeGesture and EndNativeGesture events to reset internal state. Likewise, the fact that the button state is NoButton is not a good reason for wantsPointerEvent() to return false. Added an autotest: the first of its kind that actually simulates the native gesture events. Fixes: QTBUG-92064 Pick-to: 5.15 6.0 6.1 Change-Id: I3a9b92d70f99497ee58ad8557d90d521fbe16d41 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Remove QQWindowPriv::is[Mouse|Touch|Tablet]EventShawn Rutledge2021-03-191-2/+2
| | | | | | | They are moved to QQuickDeliveryAgentPrivate. Change-Id: I5d6656dd6362dd03f0f4321cff07a8b207fadd39 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Move event delivery from QQWindow to QQuickDeliveryAgentShawn Rutledge2021-02-241-9/+6
| | | | | | | | | | | | | | | | | | | | QQuickWindow owns QQuickRootItem which owns QQuickDeliveryAgent, so for every window there's an object responsible for event delivery, while the window itself is mainly responsible for rendering (separation of concerns). However, QQuickRootItem and QQuickDeliveryAgent can now be used in cases where the scene doesn't directly belong to a window, such as when a Qt Quick sub-scene is mapped somewhere into a Qt Quick 3D scene. In that case, we must remember which delivery agent was in use at the time when a QEventPoint is grabbed and deliver subsequent updates via the same DA. There's also a QQuickDeliveryAgent::Transform abstraction which subscene-management code (such as QQuick3DViewport) can implement, to provide a formula to map the window's scene coordinates to subscene coordinates; if defined, it will be used during delivery of subsequent updates to existing grabbers. Task-number: QTBUG-84870 Change-Id: I70b433f7ebb05d2e60214ff3192e05da0aa84a42 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Doc: Fix documentation warnings for Qt QuickTopi Reinio2020-11-051-2/+2
| | | | | | | | | | | - Remove links to modules and examples that are not part of Qt 6. - Remove links to entities marked as \internal - Add missing enum value and QML property docs where it's trivial to do so. Task-number: QTBUG-88156 Change-Id: I10a1c7bcc5fe0e2354ea69eaf24930362edb7415 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QQuickPointerHandler: Don't leak the QtQuick-specific extra dataUlf Hermann2020-10-311-0/+1
| | | | | | Change-Id: I0c5697e9df4dc01aeedf427aab723c306e19338d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Remove QQuickPointerEvent etc.; deliver QPointerEvents directlyShawn Rutledge2020-09-181-58/+92
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Add ; to Q_UNUSED and UNUSED_PARAMLars Schmertmann2020-06-261-1/+1
| | | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: Iead53d18fd790fb2d870d80ef2db79666f0d2392 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove QQuickPointerDevice in favor of QPointingDeviceShawn Rutledge2020-06-231-1/+12
| | | | | | | | | | | | | | ...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>
* Add PointerHandler.cursorShape propertyShawn Rutledge2020-01-311-1/+83
| | | | | | | | | | | | | | | | | | Also, QQuickItemPrivate::setHasCursorInChild() was unable to check the QQuickItemPrivate::hasCursor variable, because the function argument hasCursor was shadowing that, even though the comment "nope! sorry, I have a cursor myself" hints that the intention was to check that. So this change exposed a problem there, and we have to fix that too, in order to keep the tst_qquickwindow::cursor() test passing. [ChangeLog][Event Handlers] Pointer Handlers now have a cursorShape property to set the cursor when the handler is active and the mouse is hovering, and restore to the previous cursor when the mouse leaves. Fixes: QTBUG-68073 Change-Id: Ib5c66bd59c4691c4210ee5465e1c95e7bdcf5ae1 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix Qt6 build in preparation of qt5 submodule updateAlexandru Croitor2019-12-191-2/+2
| | | | | | | | | Fixes the QTextStream usages. Change-Id: I0c009a82fb644a9f3c3d42ec410d18b680977f23 (cherry picked from commit 1c5c5f7aadc2dcc73a21eeb818e95c4e1b7de70f) Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>