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

QWidget::setMinimumSize API guarantee is broken on i3

    XMLWordPrintable

Details

    • Linux/X11

    Description

      From the https://doc.qt.io/qt-5/qwidget.html#minimumSize-prop documentation page:

      The widget cannot be resized to a smaller size than the minimum widget size. The widget's size is forced to the minimum size if the current size is smaller.

      However, I'm getting reports that this guarantee is being broken on X11 with i3 window manager what leads to crashes in application code assuming the widget size can't be less than minimum size. I believe there either should be some code in the xcb QPA to enforce minimum window size or some code in the widget subsystem to ensure the widget size is not less than the minimum size even if the corresponding QWidgetWindow is smaller (maybe clamp new crect size in QWidgetWindow::updateSize() according to minimum and maxmium size? This can work as QWindow::setMinimumSize API documentation says it's just a hint, so the window can be smaller apparently while its QWidget is not). E.g. something like

          QWExtra *extra = m_widget->d_func()->extraData();
          QSize boundedSize(qBound(extra->minw, geometry().width(), extra->maxw),
                            qBound(extra->minh, geometry().height(), extra->maxh));
          if (m_widget->data->crect.size() != boundedSize) {
              changed = true;
              m_widget->data->crect.setSize(boundedSize);
          }
      

      Reproduction steps from the report I've got:

      1. Run wmctrl -l to get the window id
      2. If you are on a tiling window manager (like i3) you have to get it out of tiling (Shift-Meta-Space per default on i3)
      3. Run wmctrl -i -r $window_id -e 0,500,500,300,400 (the 500,500 is position, the 300,400 dimensions)

      Something like that code should be enough to reproduce:

      QWidget w;
      w.setMinimumSize(380, 480);
      w.show();
      

      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
              ilya-fedin Ilya Fedin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes