aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickhandlerpoint.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* doc: Fix string, real, point and size QML property documentationDavid Boddie2024-12-051-7/+7
| | | | | | Pick-to: 6.8 Change-Id: I2de731368e403696ecf9d74a0ac68d1982d5ce24 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
* doc: Fix string, vector2d and matrix4x4 QML property documentationDavid Boddie2024-12-051-1/+1
| | | | | | Pick-to: 6.8 Change-Id: I30dc4f1573e5bfbf11bc0c69060fd5b77f1681e2 Reviewed-by: Andreas Eliasson <andreas.eliasson@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-1/+0
| | | | | | | | | | | | 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>
* 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>
* doc: Rename QML type HandlerPoint to handlerPointShawn Rutledge2023-02-171-15/+15
| | | | | | | | | | | | | | It's a Q_GADGET value type so it needs a lowercase name. Link eventPoint to handlerPoint to help reduce confusion. There's already a link in the other direction. Pick-to: 6.2 6.4 6.5 Task-number: QTBUG-104761 Task-number: QTBUG-104570 Change-Id: I962d2d44690ec2f75190e07be7489eb3883d0657 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* doc: Add the handlerPoint.device propertyShawn Rutledge2023-02-171-0/+7
| | | | | | | | | | Amends a1c91787264f6f535b5cf094b57ee53058856df4 Task-number: QTBUG-76381 Pick-to: 6.2 6.4 6.5 Change-Id: I7fdd15abbe15805815f5d2b2fc298501e1ab34d7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qquickpointerhandler_p.h: Clean up includesFabian Kosmale2022-10-191-0/+1
| | | | | | | | | | | | | | | | | 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>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@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>
* Add DragHandler.activeTranslation and persistentTranslationShawn Rutledge2021-06-041-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you want to set target: null and then bind translation to some object's x and y properties directly (perhaps an Item, a Qt Quick 3D Model object, etc.), it's a lot less trouble to use a translation property that does not keep changing back to 0,0 every time a gesture begins. In hindsight, the translation property should have been the persistent one (for consistency with the fix for QTBUG-68941, in which we made PinchHandler.scale persistent and added activeScale: b4d31c9ff5f0c5821ea127c663532d9fc2cae43e). But for several years, the translation property has been restarting with each gesture; so now we add a persistentTranslation property. The new activeTranslation property has the same value as the translation property (which is deprecated). Also, the persistentTranslation property is settable, because in some UIs there may be multiple ways to move the same object, and there needs to be a way to sync them up. Also fixed a bug: when minimumPointCount == 2, QQuickMultiPointHandler::wantsPointerEvent() doesn't initialize d->currentPoints until two points are pressed. But often, one point is pressed, and in the next event, the second point is pressed while the first is held Stationary. So QQuickHandlerPoint::reset() needs to set pressPosition and scenePressPosition on both points at the same time, because it is called on each HandlerPoint in d->currentPoints at that time when both points are pressed. So if any point is pressed, act as if they all were freshly pressed. Without this fix, the centroid's scenePressPosition is wrong (based on the average of 0,0 and the second point), therefore a "jump" was occurring when persistentTranslation is used to directly drive a binding (like the tilt in map.qml). [ChangeLog][QtQuick][Event Handlers] DragHandler.activeTranslation now holds the amount of movement since the drag gesture began. DragHandler.persistentTranslation holds the accumulated sum of movement that has occurred during subsequent drag gestures, and can be set to arbitrary values between gestures. Task-number: QTBUG-94168 Change-Id: I1b2f8ea31d0f6ff55ccffe393bc9ba28c1a71d09 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>
* Rename DBG_* logging categories in Qt QuickShawn Rutledge2021-02-151-1/+1
| | | | | | | | | | | | | We prefer camelCase rather than SHOUTING for module constants. It fits well to have logging categories as constants that start with lc. That has become conventional in various modules, and we've been using that convention already for some time when defining new logging categories. Now we finish renaming the Qt Quick ones, ahead of a refactoring which will result in moving some of them around. Pick-to: 6.1 Change-Id: I47003b9e525fe70d35dbd2450d03379b52d67c1d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Fix documentation warnings for Qt QuickTopi Reinio2020-11-051-3/+3
| | | | | | | | | | | - 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>
* Rename PointingDeviceUniqueId QML type to lowercaseUlf Hermann2020-09-191-1/+1
| | | | | | | | | Value types should be lowercase and this one is not a QObject. It's also undocumented. Therefore we should be able to rename it without much drama. Change-Id: I7ae75aca5e592c9bee2a33ec3c36ed2ffa1edecd Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Remove QQuickPointerEvent etc.; deliver QPointerEvents directlyShawn Rutledge2020-09-181-28/+26
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix TapHandler so that it actually registers a tapJan Arve Sæther2020-09-041-2/+2
| | | | | | | | | | | | | | | | | | This bug caused all quick examples that used the shared\LauncherList.qml to be broken. In QtGui, QSinglePointEvent will construct itself with a point id of 0 if there is a valid point, and with a point id of -1 if the point is invalid (the default constructor does the latter). However, QQuickSinglePointHandler::wantsPointerEvent() did not agree with that, because it assumed that a point id of 0 meant uninitialized/invalid point. The fix is to change QQuickSinglePointHandler::wantsPointerEvent() and QQuickHandlerPoint so that it assumes that the id -1 is now an invalid point, (instead of 0) Change-Id: I8c9683dfe06ebb77c5342a26f08174b67e7cbd90 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add QQuickHandlerPoint::device propertyShawn Rutledge2020-09-041-0/+3
| | | | | | | | | | | | The HandlerPoint type is used as the memory of an event or TouchPoint that a handler has already handled. Maybe in the future we'll store a copy of a QEventPoint instead. But for now, it's nice to have the device pointer available for binding properties, instead of only in QQuickEventPoint, which was only exposed in signals like TapHandler.tapped(). Change-Id: I314fc8c76311dc2620f1d97d4cadacf2e9869274 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Replace QTouchEvent::TouchPoint with QEventPointShawn Rutledge2020-07-151-3/+3
| | | | | | | | | | | | 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>
* Make qtdeclarative compile with -no-feature-tableteventShawn Rutledge2020-02-201-0/+2
| | | | | | | | Amends 8e822e981d91e688799c8670f11dfdf6aaf9e0d1. Fixes: QTBUG-82168 Change-Id: I8d849747a3394ca05d62b674a725d45165f081eb Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Deliver QTabletEvents to pointer handlersv5.15.0-alpha1Shawn Rutledge2020-02-111-1/+4
| | | | | | | | | | | | | | | | | | | | At this time, there are not yet any specialized handlers to do anything specifically with tablet events; but we demonstrate how to use HoverHandler to detect the type of stylus in use, and how to use PointHandler to draw on a Canvas. Unfortunately, events of types TabletEnterProximity and TabletLeaveProximity are not delivered to the window, only to QGuiApplication. So HoverHandler can detect when the stylus is moved out of its parent Item (as long as it's still hovering over the tablet surface), but cannot detect when the stylus leaves the tablet completely. In Qt 5 that would require a custom application subclass (see qtbase/examples/widgets/widgets/tablet/tabletapplication.cpp). Fixes: QTBUG-79660 Change-Id: I81fdb99082dc41c0455085e6b6d3952402bf8742 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* TapHandler: wait until after tapped is emitted to reset point.positionShawn Rutledge2019-07-051-10/+5
| | | | | | | | | | | | | | | | | | | We don't want it to hold its position indefinitely after the button is released. But in practice, reset() gets called again anyway in QQuickSinglePointHandler::handlePointerEventImpl(), _after_ handleEventPoint(), which means after tapped() is emitted. Having the point hold its position that much longer is convenient for applications and more consistent with the state expressed by the release event. Also amend the documentation. Partially reverts 17237efaefabe924599abe00e92d8b54032d7915 [ChangeLog][Event Handlers][Important Behavior Changes] TapHandler.point now holds the release position while the tapped() signal is emitted. Fixes: QTBUG-76871 Task-number: QTBUG-64847 Change-Id: I621a2eba4507a498788e9384344e8b4b7da32403 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Doc: Fix link issuesNico Vertriest2019-01-031-2/+0
| | | | | Change-Id: I738b9da5335afb048d2eda2edf2be5095a91d7e5 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: fix grabPermissions and other enumeration propertiesShawn Rutledge2018-09-141-2/+2
| | | | | | | | | | | | * grabPermissions is a flags property, not bool. * Add a list of the possible grabPermissions values. * Fix two other places where \qmlproperty enum was used instead of enumeration. * acceptedButtons, acceptedDevices, acceptedModifiers and acceptedPointerTypes are flags properties, not plain int. Change-Id: I6f49dcc1e1762e913e4989b208380d64899630a6 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* PointHandler: stay active as long as acceptedButtons satisfiedShawn Rutledge2018-07-271-3/+7
| | | | | | | | | Ignore buttons which do not fit the acceptedButtons filter, and do not assume that it's all over when any release happens. Task-number: QTBUG-66360 Change-Id: I871ea7fdd9b76f06fa0d73382617b287c04d35ab Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix PointerHandler constructors and destructorsShawn Rutledge2018-07-271-3/+0
| | | | | | | | | | | | | - Constructors should take QQuickItem* not QObject* to be symmetric with the parentItem() accessor (and other code) which assumes its type - Use header initialization everywhere possible - Reorder variables to minimize padding (somewhat) - Remove empty destructor bodies (the compiler can write them) - Remove override and virtual from destructors in accordance with https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-override Change-Id: I682a53a803d65e29136bfaec3a5b534e975ecf30 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Rearrange docs: Pointer Handlers -> Input HandlersShawn Rutledge2018-07-261-2/+1
| | | | | | | | | | | | | | | At QtCS 2018 we decided to rename Pointer Handlers to Input Handlers and include the Keys attached property as part of this set (since we plan to have attached-property pointer handlers too, eventually). It's no longer a module, it's included in Qt Quick 2.12. We need to start promoting Input Handlers and reducing the visibility of legacy stuff like MouseArea and MultiPointTouchArea (in the hope of being able to deprecate them eventually). Task-number: QTBUG-66651 Change-Id: I801351ac2531191cbb1faac9318441c67a109af6 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Make sure pressPosition and scenePressPosition are correctly initializedJan Arve Sæther2018-07-231-1/+6
| | | | | | | | | | | | | | | | | | | | The problem was that QQuickMultiPointHandler::m_currentPoints were only initialized when the candidate points matched the min and max number of points. So if we wanted to do a two-finger pinch it would only initialize them when *both* fingers were pressed. Due to the checking of point->state() in QQuickHandlerPoint::reset(const QQuickEventPoint *point) it meant that it would only initialize the press position correctly for the *last* pressed point. This was because the first pressed point would at the point when reset() was called have a point->state() == QQuickEventPoint::Updated, so it would not initialize the pressPosition nor the scenePressPosition. Luckilly we can get the scenePressPosition from the QQuickEventPoint, but the pressPosition we have to explicitly localize. Change-Id: I493c736814cfbc265ec33e8a72fc4283edbbdc43 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickMultiPointHandler: store QQuickHandlerPoints, not QQEventPoint*sShawn Rutledge2018-07-191-21/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QQuickPointerTouchEvent::reset(QEvent *event) reuses instances of QQuickEventPoint from one touch event to the next, but it makes no attempt to match up each instance with the same pointId from the event. So from the perspective of Handlers, each event can have its touchpoints in a different order, and therefore it's always wrong to hold onto any QQuickEventPoint pointer between events. Instead we use QQuickHandlerPoint for storage: both for exposing to QML, and for internal storage in handlers that need to remember touchpoint state. Without this change, any MultiPointHandler could "forget" which point IDs it had chosen to react to, in any case where the event contains additional points. It was using a QVector<QQuickEventPoint *> to remember the chosen points, but each of those instances might be assigned a different touchpoint during the handling of the next touch event (and thus its ID would change "underneath"). Perhaps this went unnoticed until now because 1) the only subclass of MultiPointHandler was PinchHandler, and we didn't often test use cases with extra touchpoints beyond the ones involved in the pinch and 2) on Linux/X11 they stayed in the same order in each event. But as soon as we try to make DragHandler inherit MultiPointHandler, it becomes clear that it does not succeed in holding on to a particular touchpoint while dragging multiple DragHandlers with multiple fingers, without this patch. Change-Id: If7e0daa9ed77b263efc09f5ea73dfba6a3c8205c Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devUlf Hermann2018-06-251-1/+1
| | | | | | | | | | Conflicts: src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp src/quick/handlers/qquickhandlerpoint.cpp src/quick/handlers/qquicksinglepointhandler.cpp tests/auto/qml/ecmascripttests/test262 Change-Id: I8908ec8c6116ca626fbd269af7625d4c429429ca
* Add QQuickHandlerPoint::modifiers propertyShawn Rutledge2018-05-181-0/+14
| | | | | | | | | The event includes it; this exposes it to QML, for the benefit of conditional JS logic in Pointer Handler use cases. Task-number: QTBUG-68101 Change-Id: I3f04c5db7f5aef461edb6168922b70e3fb3bda37 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* MultiPointHandler: add a centroid propertyShawn Rutledge2018-05-181-0/+83
| | | | | | | | | | | | | | | One of the reasons we were so fond of using SinglePointHandler for the "simple" handlers like TapHandler and DragHandler is that it has the point property, which is easy to bind to in QML. But multi-point handlers tend to use the centroid as the focal point or fulcrum of the transformation, so exposing the centroid as a QQuickHandlerPoint gadget rather than just a QPointF has all the same advantages as the point property in SinglePointHandler, including letting the QQuickHandlerPoint instance store state between events (press position, grab position, last known position etc.) Change-Id: I4a955fa21b54b7ebb50b0ee2c942fb98eeccb560 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Move QQuickHandlerPoint into its own header and cpp filesShawn Rutledge2018-05-161-0/+254
...in anticipation of needing it in QQuickMultiPointHandler. Change-Id: Id98f2da34ee12b4cea3ba58550b446bfc989da1b Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>