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

Calculation of GlobalPos

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 6.4.0 Beta1
    • 6.3.0
    • QPA: Wayland
    • None
    • Linux/Wayland
    • 94981ddd1e (qt/qtwayland/dev) 94981ddd1e (qt/tqtc-qtwayland/dev)

    Description

      In wayland, if a window's coordinates are 100,100,100*100
      At this point there is scaling, QT_SCALE_FACTOR = 2
      In Qt we get the following coordinates
      Widget: 0,0,100*100
      Window: 0,0,100*100
      QWaylandWIndow 0,0,200,200
      these are no problem

      Consider this time a mouse event pointer_motion arrives, pos = 20,20. This is based on the coordinates of the Surface.

      Next in QWaylandInputDevice::Pointer::pointer_motion we convert it to global coordinates

      QPointF global = window->window()->mapToGlobal(pos.toPoint());(https://github.com/qt/qtwayland/blob/dev/src/client/qwaylandinputdevice.cpp#L786)

      The global coordinates we get are still 20,20

      Since our window topleft = 0,0, we get the result without any problems.

      However, there is a problem with the call here window->window()->mapToGlobal, if we set the coordinates of the window in the future, the coordinates obtained here will be 120,120 This is a wrong answer. The pos = 20,20 we received is the value after scaling. When calculating the global coordinates, we should also calculate the value based on scaling. The correct value should be 220,220.

      So, even though it doesn't seem wrong now, there are some wayland extensions that specify the topleft of the window. This creates problems.

      And, a zoomed coordinate + the topleft of an unzoomed window. It seems incomprehensible.

      Attachments

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

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            tanghaixiang haixiang tang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes