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

Touch events on the right and bottom edge of the screen are lost

    XMLWordPrintable

Details

    • All

    Description

      The touch events on the right and bottom edge of the screen are lost.

      This is due to an incorrect conversion of QPointF to QPoint inside QGuiApplicationPrivate::processTouchEvent.

       

      Example

      Consider a touch event with with screen position of QPointF(1919.5, 660.617) on the screen of size 1920x1080. This point when handled by the QGuiApplicationPrivate::processTouchEvent method will be passed to QGuiApplication::topLevelAt by the following code:

      window = QGuiApplication::topLevelAt(touchPoint.screenPos().toPoint());

      This code will call the toPoint method converting the touch location to QPoint(1920, 661). The test performed in QGuiApplication::topLevelAt against the screen size represented by the QRect(0, 0, 1920x1080) will then subsequently fail.

       

      Fix

      The following diff to qtbase fixes the issue:

      diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
      index d466ca6..d1ba1f5 100644
      --- a/src/gui/kernel/qguiapplication.cpp
      +++ b/src/gui/kernel/qguiapplication.cpp
      @@ -2695,7 +2695,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
                   if (!w) {
                       // determine which window this event will go to
                       if (!window)
      -                    window = QGuiApplication::topLevelAt(touchPoint.screenPos().toPoint());
      +                    window = QGuiApplication::topLevelAt(QPoint((int)touchPoint.screenPos().x(), (int)touchPoint.screenPos().y()));
                       if (!window)
                           continue;
                       w = window;
      

      Remarks

      There are many places in QGuiApplicationPrivate that rely on the QPointF to QPoint transformation using the toPoint method. This includes mouse and tablet event handlers. I suspect this issue to be even more prevalent in the code.

      Attachments

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

        Activity

          People

            srutledg Shawn Rutledge
            bartsiwek Bart Siwek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes