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

Low resolution title bar icon on Wayland on Hi DPI displays

    XMLWordPrintable

Details

    • Linux/Wayland
    • fc91cd6b1306c6d452cbddab3c2289ccb92218d6(dev) 9e921538cef35d6346744884a59aaee396209a20(6.3) a023d7cdd588b39bee748af01404f9d9aa3e9f15 (6.2) 06b2f437219b5e44aebcff7c13362c062be06273(tqtc/lts-5.15)

    Description

      On my Linux/Wayland (Gnome) system, when the DPI scale is set to 200%, the window title bar icon of my Qt application is displayed in low resolution. I have provided an QIcon with an appropriate hi resolution pixmap to `QApplication::setWindowIcon`, therefore I would expect a full resolution result.

      The responsible code appears to be here: https://github.com/qt/qtwayland/blame/50dbd5f508e03f1cc57300830049581bef9c73b2/src/plugins/decorations/bradient/main.cpp#L165-L175

       

      QPixmap pixmap = icon.pixmap(QSize(128, 128));
      QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
      
      QRectF iconRect(0, 0, 22, 22);
      p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
                                     margins().left() + BUTTON_SPACING, 4),
                   scaled, iconRect);

       

      In this snippet, it is apparent that the QIcon 128x128 (or 256x256) pixmap is explicitly scaled to 22x22 native pixels, and then painted using the display scale aware `QPainter` which will scale it back up to 44x44 for display. As with QTBUG-90363, the double scaling results in poor visual quality.

       

      I suggest replacing the above code with the following:

      icon.paint(&p, iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
                                     margins().left() + BUTTON_SPACING, 4));
      

       

      That way, QIcon uses directly a pixmap with the appropriate size according to the display scale.

      Attachments

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

        Activity

          People

            liaqi Liang Qi
            bbouclet Bastien Bouclet
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes