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

Low resolution title bar icon on Wayland on Hi DPI displays

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 6.0.0
    • Fix Version/s: None
    • Component/s: GUI: High-DPI, QPA: Wayland
    • Labels:
      None
    • Platform/s:
      Linux/Wayland

      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

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

          Activity

            People

            Assignee:
            bbouclet Bastien Bouclet
            Reporter:
            bbouclet Bastien Bouclet
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There is 1 open Gerrit change