aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickdeliveryagent.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix click-to-focus in items within subscenes; improve loggingShawn Rutledge2021-03-041-14/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the ability to focus an item by clicking (such as a TextInput) when it's part of a subscene mapped to a 3D object in Qt Quick 3D, even if there are multiple subscenes with focusable items. QQuickDeliveryAgentPrivate::setFocusInScope(subsceneRoot, textInput) for example did not succeed; for one thing, this check fails: // Does this change the active focus? if (item == rootItem || scopePrivate->activeFocus) { because in a 3D scene, so far the viewport has focus by default, so the given scope (subscene root) does not have active focus. Each window ultimately has one actively focused item, so we need to delegate to the delivery agent belonging to the window's root item, to set its active focus. It's not even clear whether it's really a good idea for each subscene delivery agent to have its own QQuickDeliveryAgentPrivate::activeFocusItem. It might give us flexibility: perhaps each subscene root item should be a focus scope, and each delivery agent should decide which item would be hypothetically focused if the whole subscene got focus. But for now, it seems enough to set the activeFocusItem on the root item of the whole scene. Another problem was that when QQuickItem::forceActiveFocus() goes up the parent hierarchy, it didn't find a focus scope. So when you clicked on a TextInput that already had its focus property set to true, 1) QQuickItem::setFocus() does nothing because d->focus is already set 2) QQuickItem::forceActiveFocus() did not find a parent focus scope Therefore neither of them changed anything, and it wouldn't get active focus. Setting the ItemIsFocusScope flag on each subscene root item fixes (2), and that seems to be enough for now. Another problem was that QQuickWindow::event() was calling QQuickDeliveryAgent::grabberAgent() even when delivering an event that is NOT a press event, in spite of the comment "When delivering _update_ and _release_ events to existing grabbers, use the subscene delivery agent, if any." A hover event often results in a HoverHandler getting a passive grab, but that passive grab is not a reason to deliver a subsequent press event to the same subscene. When the mouse moves, we need to start over with picking in the 3D scene. When the 60fps frame-synchronous hover event occurs, we need to start over with picking, in case 3D objects are being animated under the cursor. When a press occurs, we need to start over with picking in case the press occurs in a different location from the last hover (even though that's unlikely with a mouse, it happens easily with a touchscreen). Another problem was that QQuickItemPrivate::deliveryAgent() was not finding the subscene DA during delivery of key events. A child item's extra is often not allocated, but we still need to keep looking at the parents. The optimization from 68c103225f4e8bd6c1b18ef547108fd60f398c0f was also wrong: after an Item's default initialization, we always need to do the search for the subcene DA. Only if we are sure that the item is NOT in a subscene (as in all normal 2D scenes) we can avoid doing that search next time. Consolidate the number of lines of output in the qt.quick.focus logging category and show the activeFocusItem transition. As with most logging in Qt Quick, it's expected that you set QT_MESSAGE_PATTERN to include %{function} so that you can always see where each line comes from. Therefore the log output itself has only minimal context (as in "q focus item x in scope y") rather than repeating the function name. Change-Id: I1b2a989c02c58c966653f965c0de512aa641bb99 Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 543598a6cc07d67e7651c9f65c058465ea6d8425) Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickDeliveryAgent: Do not send hover to deleted itemFabian Kosmale2021-02-281-1/+2
| | | | | | | Change-Id: I58fff14184abc9dcffb3992a473fd2a1ef8446c7 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit 503bfae6ef76c18e1596cd872c0f6dd0838bbc51) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move event delivery from QQWindow to QQuickDeliveryAgentShawn Rutledge2021-02-251-237/+470
| | | | | | | | | | | | | | | | | | | | | | 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> (cherry picked from commit 68c103225f4e8bd6c1b18ef547108fd60f398c0f) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Split event delivery code from qqwindow into qqdeliveryagent.cppShawn Rutledge2021-02-251-0/+2012
Event delivery logic will live in util/qquickdeliveryagent.cpp now. The actual QQuickDeliveryAgent class will be created in a followup patch. This patch is roughly the same as this series in dev branch: 44eebdf5f5fe3bd7be16bc0ef05f8fc63e38a9f2 ca9c29348a9e149109d9d381cdd44538160b7898 902c68f3ceaae407306ca5a3fdcdcfa159009e78 79f0af6cd097f55eacb763574e173f134c9c0a32 0ccea574f8e4e9a3954ef3bb95909565957bacbe dbdee417dc073a0da3c99849a3f393fa3cb660e9 Change-Id: I25f234d0550768cb01cd80c38525291202b25d99 Reviewed-by: Andy Nichols <andy.nichols@qt.io>