From 8c1e9c1929ae2242ba3730ffe9c857514da7c6c1 Mon Sep 17 00:00:00 2001 From: Ali Mirjamali Date: Tue, 11 Nov 2025 00:59:50 +0330 Subject: [PATCH] Send optimized icon size Lookup for the most common icon sizes and select one of them first. Then revert to whatever available size which does not violate our maximum. Unfortunately pre-SVG era icon designs for few legacy applications is totally different per icon size. So sending the highest resolution is not always desirable as it does not scale down well on low-DPI screens. Practically this patch does not change anything for most programs (compared to previous situation). Since the previous code started from 128x128 down to the lowest resolution. Background on various icon sizes in different OS: https://icons8.com/blog/articles/choosing-the-right-size-and-format-for-icons/ resolves: https://github.com/QubesOS/qubes-issues/issues/10359 --- window-icon-updater/icon-sender | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/window-icon-updater/icon-sender b/window-icon-updater/icon-sender index 0b094e47..6330023b 100755 --- a/window-icon-updater/icon-sender +++ b/window-icon-updater/icon-sender @@ -34,7 +34,18 @@ import time import xcffib from xcffib import xproto -ICON_MAX_SIZE = 256 +ICON_MAX_SIZE = 1024 +# Chronological order of preferred icon sizes based on certified HW and defaults +ICON_PREFERRED_SIZES = ( + (128, 128), + (96, 96), + (64, 64), + (48, 48), + (256, 256), + (512, 512), + (32, 32), +) + IconPixmapHint = 0b1 << 2 IconMaskHint = 0b1 << 5 @@ -247,7 +258,13 @@ class IconRetriever(object): def describe_icon(self, w): try: icons = self.get_icons(w) - chosen_size = sorted(icons.keys())[-1] + # Override the largest icon with our preferred sizes (if possible) + for size in ICON_PREFERRED_SIZES: + if size in icons.keys(): + chosen_size = size + break + else: + chosen_size = sorted(icons.keys())[-1] data = b'' data += "{}\n".format(w).encode('ascii')