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

QDesktopWidget::availableGeometry(...) unreliable with xinerama

    XMLWordPrintable

Details

    Description

      On X11, QDesktopWidget::availableGeometry(...) relies on the _NET_WORKAREA hint exposed by the window manager (metacity in my case) to calculate the geometry available on a given screen.
      This is unreliable as _NET_WORKAREA itself spans across the whole virtual desktop on all screens.
      In some cases the window manager may completely exclude a screen from _NET_WORKAREA if it contains windows with reserved space on the edges (struts). In such cases, QDesktopWidget::availableGeometry(...) will return a null QRect, which is likely incorrect (unless all the actual screen surface is reserved, which is not the case in my tests).

      My setup is as follows: a laptop screen (1280×800) set as primary screen on the left and a 23" external monitor (1920×1080) on the right, positioned higher than the laptop. To reflect the relative positions of the monitors, in the configuration utility I positioned them such that neither the top edges nor the bottom ones are aligned. The following bit of ASCII art should help understand the setup:

      ╔═══════════╤════════════════╗
      ║░░░░░░░░░░░│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║
      ║░░░░░░░░░░░│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║
      ╟───────────┘▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║
      ║▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║
      ║▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║
      ║▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒║
      ║▓▓▓▓▓▓▓▓▓▓▓▓┌───────────────╢
      ║▓▓▓▓▓▓▓▓▓▓▓▓│░░░░░░░░░░░░░░░║
      ╚════════════╧═══════════════╝

      Where:

      ▓ laptop monitor
      ▒ external monitor
      ░ area that is not covered by any monitor
      ═ shape of the virtual desktop
      ─ shape of the area that is actually covered by monitors

      If I position a panel at the top of the left screen, in order to reserve space (struts), I need to take into account all the unused space above, so the height of the strut would be (leftScreen.top() + panel.height()). However when I do that, the window manager decides that the area covered by _NET_WORKAREA should be reduced to the area of the right screen only. I get something like _NET_WORKAREA(CARDINAL) = 1281, 0, 1919, 1449.
      As a result, the intersection with QDesktopWidget::screenGeometry(...) for the left screen is null, and QDesktopWidget::availableGeometry(...) returns a null QRect. However, there is available space on the left screen.

      I think the calculation of QDesktopWidget::availableGeometry(...) should not use _NET_WORKAREA, but instead subtract from QDesktopWidget::screenGeometry(...) all the reserved areas by going through the list of windows and see which ones have reserved space.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-18380
          # Subject Branch Project Status CR V

          Activity

            People

              paeglis Gatis Paeglis
              osomon Olivier Tilloy
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes