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

QWidget::pos() and QWidget::saveGeometry() give wrong positions under X11

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P2: Important
    • None
    • 4.5.2
    • GUI: Window management
    • None
    • Ubuntu 9.10, Qt 4.5.2, various window managers as installed in Ubuntu 9.10

    Description

      Both QWidget::pos() and QWidget::saveGeometry() give sporadic wrong results under various common X11 window managers.

      To replicate, take the standard Qt Main Window Application example (in mainwindows/application). Start it, move the window to the middle of the screen (so that it has room on all sides), then quit.

      Now start it again, then quit immediately. Repeat many times (20-30 until the results become clear). Notice what happens to the window position over time.

      My observed results are:

      Under Compiz: Almost every time the program is started, the window opens about 20 pixels down and a few pixels to the right of where it opened the previous time (i.e., the window frame's worth).

      Under Metacity: Most of the time, the window opens in the same place as it did on the previous occasion. But sporadically, perhaps a quarter of the times that the program is started, the window opens above and to the left of the previous occasion, by what appears to be one window frame's worth. These sporadic cases seem to occur at random, with no obvious pattern.

      Under Openbox: Same results as for Metacity. The amount of shift up and to the left was smaller than with Metacity, and appeared to be exactly the size of Openbox's window frames (which are smaller than Metacity's).

      Under xfwm4 (with compositing enabled): Same results as for Metacity and Openbox, except that the shifts up and to the left appeared to be more common, happening about a third of the times that the program was launched. In addition, on a couple of occasions the window reverted to being in the top left corner of the screen (after the window was far away from that corner on the previous execution of the program).

      Note that the Application demo uses pos() and size() in its closeEvent() handler to save the position, as recommended in the Qt Window Geometry documentation prior to the introduction of saveGeometry(). However, I encountered this bug, with the same manifestation, in my own program using saveGeometry() in the closeEvent() handler, and from my brief inspection of the QWidget::saveGeometry() source, it would seem that the bugs for pos() and for saveGeometry() have a common cause somewhere in the geometry handling code of QWidget.

      Reproducibility: as described above (always under Compiz, and a seemingly random 20-40% of the time under the other window managers).

      Attachments

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

        Activity

          People

            laknoll Lars Knoll
            lauriefield Laurie Field
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes