Skip to content

Commit a930989

Browse files
committed
Merge remote-tracking branch 'origin/pr/249'
* origin/pr/249: Send optimized icon size
2 parents 31d173c + 8c1e9c1 commit a930989

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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)