Skip to content

Commit 8c1e9c1

Browse files
committed
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: QubesOS/qubes-issues#10359
1 parent 299a8ba commit 8c1e9c1

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

window-icon-updater/icon-sender

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,18 @@ import time
3434
import xcffib
3535
from xcffib import xproto
3636

37-
ICON_MAX_SIZE = 256
37+
ICON_MAX_SIZE = 1024
38+
# Chronological order of preferred icon sizes based on certified HW and defaults
39+
ICON_PREFERRED_SIZES = (
40+
(128, 128),
41+
(96, 96),
42+
(64, 64),
43+
(48, 48),
44+
(256, 256),
45+
(512, 512),
46+
(32, 32),
47+
)
48+
3849
IconPixmapHint = 0b1 << 2
3950
IconMaskHint = 0b1 << 5
4051

@@ -247,7 +258,13 @@ class IconRetriever(object):
247258
def describe_icon(self, w):
248259
try:
249260
icons = self.get_icons(w)
250-
chosen_size = sorted(icons.keys())[-1]
261+
# Override the largest icon with our preferred sizes (if possible)
262+
for size in ICON_PREFERRED_SIZES:
263+
if size in icons.keys():
264+
chosen_size = size
265+
break
266+
else:
267+
chosen_size = sorted(icons.keys())[-1]
251268

252269
data = b''
253270
data += "{}\n".format(w).encode('ascii')

0 commit comments

Comments
 (0)