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

QApplication::screens() returns one screen if multiple screens report same device name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2.4
    • GUI: Window management
    • None
    • Qt 6.2.4 LTS on Windows 10 Pro 19043.1348
    • Windows

    Description

      On Windows Environments, QApplication::screens() will only ever return one screen if the screens are the same manufacturer / report the same device name.

      Whenever I run any Qt application on my work computer setup, I get this strange bug where any popups (menu bar menus, combo box dropdowns, etc) always only ever appear on my secondary monitor. (Not my PRIMARY, my SECONDARY.) It doesn't matter where I move the application to, Qt refuses to open a popup on the primary monitor.

      I started trying to track down why this is, as we're creating a Qt application ourselves, and discovered that QApplication::screens() only ever returns a single screen when I run the application, and that screen is only my secondary monitor. Tracing further, I eventually found my way to the QWindowsScreenManager and how it enumerates the monitors.

      I believe the root cause are these functions:

      https://github.com/qt/qtbase/blob/dev/src/plugins/platforms/windows/qwindowsscreen.cpp#L558-L574 

      https://github.com/qt/qtbase/blob/dev/src/plugins/platforms/windows/qwindowsscreen.cpp#L637

      Both of my monitors on my work computer are "DELL E2311H" monitors. They both report the exact same display name and are the same size and shape. The only difference between the reported monitors would be the logical offset of the displays. When Qt enumerates the monitors via the Windows API, it uses `indexOfMonitor()` to check to see if the monitor is already present in the list. Windows reports my primary monitor first and my secondary monitor second, but both monitors are named the same, which is the sole thing Qt checks to see if the monitors match. And so when the secondary monitor is reached, it replaces the primary monitor as Qt's "primary" monitor. 

      There seems to be an attempt (https://github.com/qt/qtbase/commit/75f22702933bad4f0da2b63a94ea183021771e4c) to address something similar for the string returned by QScreen::name(), and perhaps that sort of thing can be used to fix this problem as well?

      I suspect this may be the problem behind this: https://forum.qt.io/topic/136480/qscreen-of-multi-monitor-cannot-be-returned 

      Attachments

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

        Activity

          People

            vestbo Tor Arne Vestbø
            tpittman_cmpx2 Timothy Pittman
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes