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

Incorrect position of shown window on X11 when the frame values (_NET_FRAME_EXTENTS) are asymmetric

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.15, 6.8.2
    • QPA: X11/XCB
    • None
    • Debian/unstable with FVWM (version 2 or 3) window manager
    • Linux/X11

    Description

      Under X11 with the FVWM window manager (version 2 or 3), when the title-bar is shown, a window set up with setGeometry gets incorrectly positioned vertically. https://github.com/nomacs/nomacs/issues/1304#issuecomment-2772895954 contains a testcase (main.cpp source attached), which basically does:

        w->setGeometry(initialRect);
        w->showNormal();
        while (!w->isActiveWindow())
          qApp->processEvents();

      The window appears as follows, ignoring the border width (but not the title-bar):

      ┌─────────────────────────┐
      │                         │
      X        title-bar        │
      │                         │
      ├─────────────────────────┤
      │                         │
      │                         │
      │                         │
      │                         │
      │                         │
      │                         │
      │                         │
      │                         │
      │                         │
      │                         │
      └─────────────────────────┘

      When there is no title-bar (in which case the position is correct), the X above denotes the position of the top-left corner. Note that the X is at the vertical middle of the title-bar. In short, due to the title-bar, the window excluding its frame is shifted downward, and the amount of the shift is half the height of the title-bar.

      The above could be measured visually, but the shift is confirmed by values obtained from the program. For instance, if (100,100) were the first two values of initialRect, then the first two values given by w->geometry() after the window is shown are (100,109).

      FVWM implements its window decorations (borders and title-bar) as frame extents, which can be shown with the xprop _NET_FRAME_EXTENTS command, e.g.

      _NET_FRAME_EXTENTS(CARDINAL) = 4, 4, 32, 4

      It seems that the issue occurs because the values are asymmetric due to the title-bar (32 on the top, 4 on the bottom). According to various tests, if B is the border width and T is the height of the title-bar, then xprop _NET_FRAME_EXTENTS gives "B, B, B+T, B", and the shift for the window position is T/2.

      The fact that the shift is T/2 could mean that the window is positioned relatively to its center, but there is a confusion between taking the window frame into account or not, which yields a shift. Due to the symmetry concerning the border width, the borders have no influence (explaining that the horizontal position is correct). But this is not the case of the title-bar.

      Attachments

        Issue Links

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

          Activity

            People

              liaqi Liang Qi
              vinc17qt Vincent Lefevre
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes