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

Dialog DPI scaling issue with multiple monitors under wayland

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 5.15.8
    • GUI: High-DPI
    • None
    • Linux/Wayland

    Description

      My setup is:

      • Debian 12 "Bookworm"
      • Window manager is GNOME with Wayland
      • Multiple monitors with different DPI scaling setup in GNOME:  Monitor 0 has scale 250%, 1 (primary) has scale 100%, 2 has scale 100%.  The problem still happens if I use 200% integer scaling instead of fractional.

      Problem description:

      • I've attached a minimal reproducer
      • If my Qt application opens a modal QDialog when on monitor 1 or 2 then the dialog appears incorrectly: its window decorations appear incorrectly scaled. 
      • If I resize the dialog or drag it to another monitor then it instantly changes to look correct and stays correct no matter how it is moved or resized.
      • If you drag the parent window to monitor 0 and then the dialog always appears correctly.
      • If you start the parent window on monitor 2, then drag it to monitor 1, then the first time you open a dialog it appears correctly, but the next time you open it it looks incorrect.

      Debugging/hypothesis

      • The problem goes away if I use XWayland
      • The problem goes away if I set all monitors to 100% scaling
      • The problem goes away if I only use a single 250%-scaled monitor
      • I have also reproduced this with Qt6 (6.4.2)
      • I think what's happening is when the QDialog is initially created it thinks it's on monitor 0 so assumes 250% scaling.  When it is actually shown on a different monitor it doesn't seem to update the scale.  If I drag the window to another monitor or resize it then it suddenly notices it's not on monitor 0 and updates its scaling.

      Other notes

      • When the QDialog is empty the problem appears as the window decorations being incorrectly scaled.  If there are other layouts/widgets in the dialog then the decorations appear correct but the dialog's background is rendered incorrectly, apparently showing random uninitialised surfaces.
      • In the screenshot, the mainwindow (the one with the button) appears with correct scaling but the dialog (to the lower right) has decorations which are 2.5x larger than they should be

      Attachments

        1. CMakeLists.txt
          0.5 kB
        2. image-2023-09-11-17-34-35-638.png
          image-2023-09-11-17-34-35-638.png
          23 kB
        3. main.cpp
          0.4 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sorvig Morten Sørvig
            dwt David Turner
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes