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

Multiple monitor high DPI, new window is created half offscreen

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.4
    • Fix Version/s: None
    • Component/s: GUI: High-DPI
    • Labels:
      None
    • Platform/s:
      Windows

      Description

      Multiple monitor setup, when creating another window it will be displayed half off screen.

      Config:
      Two monitors
      DisplayOne: 1920x1080 at 100% DPI (main) axis 0.0
      DisplayTwo: 1920x1080 at 150% DPI and the axis 1920.0

      Steps:
      (Test-app attached)
      User has the application with high DPI enabled running on DisplayTwo.
      User clicks the button to open a new window.
      The window is opened on DisplayOne but is also half off screen.

      Root cause:
      1. When a window is first created it's default axis is 0.0
      2. New screen will be created on the same screen as the cursor, as this is the default behavior.
      3. When a window doesn't fit the screen Qt doesn't center the rect of the new window.

      When creating the new window this flow seems to happen:
      In the method `QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) const` the requested geometry will have the axis of (0.0) (DisplayOne) because the new window doesn't have a parent.

      Then in the method `QScreen *effectiveScreen(const QWindow *window)`, `QCursor::pos()` is used to get the QScreen (DisplayTwo) for the new window.

      Next in the method `QRect QPlatformWindow::initialGeometry` Qt doesn't center the rect from the availableGeometry of DisplayTwo because the rect is too big for that screen.

      Result
      In `QRect QPlatformWindow::initialGeometry` Qt is returning the result of `QHighDpi::toNativePixels(rect, screen);` where `rect` still has the axis of (0.0) and `screen` is DisplayTwo.

      And the result of `QHighDpi::toNativePixels` will be a axis with a negative value.
      Qt will use this axis to display the new window.
       

        Attachments

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

          Activity

            People

            Assignee:
            sorvig Morten Sørvig
            Reporter:
            chrisog Chris O'Gorman
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes