Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-109868

make QQuickDeliveryAgentPrivate::pointerTargets() iterative

    XMLWordPrintable

Details

    Description

      This is at least an optimization, as mentioned in the FIXME comment already in https://codereview.qt-project.org/c/qt/qtdeclarative/+/164983
      I was already concerned at that time with all the temporary list (vector) allocation, and wondered if an iterative algorithm would let us populate the final list directly with no temporaries.

      Of course it's well-known that (non-tail) recursion takes execution stack space. But iterative tree traversal usually requires an explicit stack. Could we do without it? https://www.hackerearth.com/practice/notes/iterative-tree-traversals/ suggests that if there are parent pointers in the tree, yes we can do without it.

      Basically this is a recursive depth-first post-order traversal so far. (We put children earlier in the list, so that we will attempt event delivery to leaf items first.) But https://codereview.qt-project.org/c/qt/qtdeclarative/+/288660 threw a wrinkle in, to deal with z-order on the fly. It would be good to be a little more rigorous about what exactly we are doing, and prove that the replacement iterative algorithm is equivalent to the recursive one, and that the order really makes sense even when z properties are modified. At least that patch added an autotest for that use case.

      In addition to being an optimization, I think being iterative will make it easier to deal with the Item.modal flag: if we discover it during traversal, we should probably just clear the whole list (return value): those items must be irrelevant siblings, since we have not yet gone upwards to the parents of the modal item. And also need well-defined behavior when there are multiple subtrees with item.modal = true. Probably just the naive thing to begin with: the first-encountered modal subtree will "win", as long as the eventpoint is within its total bounds. So maybe we need to be calculating this bounding rectangle on the fly, too.

      Attachments

        1. IMG_2607.jpg
          IMG_2607.jpg
          1.84 MB
        2. IMG_2608.jpg
          IMG_2608.jpg
          3.16 MB
        3. draggableButton.png
          draggableButton.png
          88 kB
        4. draggableButton-order.png
          draggableButton-order.png
          146 kB

        Issue Links

          Activity

            People

              srutledg Shawn Rutledge
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: