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

MouseArea breaks velocity calculation for QEventPoints in some scenarios

    XMLWordPrintable

Details

    • Linux/Wayland

    Description

      Displaying `MouseArea` with `hoverEnabled` set to true on top of `mouseArea` with `hoverEnabled` set to false causes application-wide break in QEventPoint velocity calculations. The result is Flickables either losing "flick" behavior (QEventPoint velocity gets stuck at (0,0) value) or always performing "flick" behavior in the same direction (velocity is stuck as some arbitrary vector value) when interacted with a mouse.

      The behavior can be reproduced with qml:

      import QtQuick
      import QtQuick.Window
      import QtQml
      import QtQuick.Controls
      import QtQuick.Layouts
      Window {    
          id: topWindow
          height: 200
          title: "undefined"
          visible: true
          width: 200
          ColumnLayout {
              id: columnLayout
              anchors.fill: parent
              Item {
                  id: fogSummoner
                  height: 20
                  width: 200
                  Text {
                      anchors.fill: parent
                      text: "Summon fog"
                  }
                  MouseArea {
                      id: fogSummonerArea
                      anchors.fill: parent
                      onClicked:  {
                          fog.visible = true
                      }
                  }
              }
              Flickable {
                  height: 180
                  width: 200
                  contentWidth: 400
                  contentHeight: 900
                  id: flickable
                  Rectangle {
                      width: 400
                      height: 900
                      gradient: Gradient {
                          GradientStop { position: 0.0; color: "lightsteelblue" }
                          GradientStop { position: 1.0; color: "red" }
                      }
                  }
              }
          }
          MouseArea {
              id: fog
              visible: false
              anchors.fill: parent
              hoverEnabled: true
              onClicked: {
                  fog.visible = false
              }
          }
      }
      

       

      1) Start application and verify that flickable has inertia when flicking with mouse.

      2) Press the "Summon fog" area

      3) Click anywhere within the window

      4) Verify that flickable now lost inertia and stops scrolling the moment you release mouse button

       

      Analysis:
      It looks like the problem is caused by specific code path in QQuickMouseArea which generates HoverEnter event with timestamp which has 1970 epoch:

      https://codebrowser.dev/qt6/qtdeclarative/src/quick/items/qquickmousearea.cpp.html#1079

      Since other code paths use elapsedTimer for events' timestamp which has program start epoch, this check in QEventPoint code starts failing for new events:
      https://codebrowser.dev/qt6/qtbase/src/gui/kernel/qeventpoint.cpp.html#581
      As a result, all consecutive QPointerEvent objects have velocity for event points set to wrong value. This, in turn, causes every instance of flickable in program to malfunction, since it relies on QEventPoint's velocity to determine if flick should be performed and its speed and direction.

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            anatoliibaranov Anatolii Baranov
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes