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

[Windows]: QCursor::pos() and QMouseEvent::globalPos() mismatch when having different scaling monitors and AA_EnableHighDpiScaling is set on

    XMLWordPrintable

Details

    Description

      When having a setup of 2 screens, 4k monitor at 200% scaling and second one 1920x1200 at 150% scaling, with dpiawareness=2, the part of a window that spans to the second monitor yields a mismatch between QCursor::pos() and QMouseEvent::globalPos(). It seems that the QCursor::pos() does not take in to account the scaling of the first monitor and so the QCursor::pos() values are out of the actually workable area.

      Steps to reproduce:

      • Run attached sample
      • Move the application window such that part of it is on second monitor, but it still reports it is on primary monitor
      • Mouseclick on the area that spans to the second monitor
      • EXPECTED: Sample app does not yield any debug output since QCursor::pos() and QMouseEvent::globalPos() give same values
      • ACTUAL: QCursor::pos() values do not account for high dpi scaling and debug output shows this

      Disabling the AA_EnableHighDpiScaling removes this issue. Using dpiawareness=1 or 0 also disables hides this problem.

      Update: Things to look out for that will appear wrong are:

      • Menus can open up on the wrong position.
      • Tooltips in wrong position
      • Toolbar button issues.
      • Windows have the wrong size.

      Attachments

        1. AboutQtAssistant_100Percent.PNG
          AboutQtAssistant_100Percent.PNG
          10 kB
        2. AboutQtAssistant_DraggedTo200Percent.PNG
          AboutQtAssistant_DraggedTo200Percent.PNG
          7 kB
        3. dev.glvlevch.private.Qt.HiRes.patch
          62 kB
        4. qtbug62149_broken_output.txt
          0.5 kB
        5. qtbug62149_qtdiag.txt
          4 kB
        6. qtbug62149.png
          qtbug62149.png
          156 kB
        7. qtbug62149.zip
          2 kB

        Issue Links

          Activity

            People

              kleint Friedemann Kleint
              jussi_witick Jussi Witick
              Votes:
              11 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: