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

QHighDpi coordinate scaling API update

    XMLWordPrintable

Details

    • Task
    • Resolution: Won't Do
    • P2: Important
    • None
    • None
    • Other
    • None

    Description

      This API is provided by qhihgdpiscaling_p.h, and is used to convert DPI-based scaling to DPR-based scaling on platforms which does not implement DPR-based scaling natively.

      Today, the main form of the coordinate conversion/scaling API is:

      toNativePixels(coords, context)
      fromNativePixels(cords, context)
      

      Where “coords” is a geometry container like QPoint or QSize and context is a QWindow or
      QScreen.

      These convert between the native coordinate system (used by the platform plugin), and the device independent coordinate system (used by Qt Gui).

      Native coordinates can either be local (relative to a window origin), or global (relative to the desktop origin). Global coordinate conversion is special in that the scaling of positions is done around the screen origin. (there is no distinction for scaling of sizes)

      The API uses the context to determine if we are working with local or global coordinates:

      QScreen global
      QWindow (top-level) global
      QWindow (child) local

      This does not always work out correctly, and we currently have an override: fromNativePixelsLocalPos. It looks like we might need to have a “Global” override as well: see QTBUG-71368 and https://codereview.qt-project.org/c/qt/qtbase/+/243977

      Possible solutions:

      1) Make calling code use QScreen as context when they want global coordinates

      See https://codereview.qt-project.org/c/qt/qtbase/+/243977

      2) Switch the QWindow (child) case to use global coordinates. This makes things more predicable. It would however be an API behavior change and we’d have to review all usages.

      3) Add API to make the local/global distinction explicit:

      toNativePixelsLocal
      fromNativePixelsLocal
      toNativePixelsGlobal
      fromNativePixelsGlobal

      Then possibly deprecate fromNativePixels().

      Attachments

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

        Activity

          People

            sorvig Morten Sørvig
            sorvig Morten Sørvig
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes