aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/tray/icon.c
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2020-03-04 14:34:32 +0000
committerLibravatar Simon Ser <contact@emersion.fr>2020-03-30 17:31:00 +0200
commit68f53cd509af8812562d743a55128a1b341247f5 (patch)
tree269042ba89e26b4124bb9f53cd9debf29e6f2599 /swaybar/tray/icon.c
parenttray: allow themes to inherit from multiple themes (diff)
downloadsway-68f53cd509af8812562d743a55128a1b341247f5.tar.gz
sway-68f53cd509af8812562d743a55128a1b341247f5.tar.zst
sway-68f53cd509af8812562d743a55128a1b341247f5.zip
tray: tidy code
This includes some refactoring and fixing a small memory leak.
Diffstat (limited to 'swaybar/tray/icon.c')
-rw-r--r--swaybar/tray/icon.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/swaybar/tray/icon.c b/swaybar/tray/icon.c
index 69df3582..c426c3d4 100644
--- a/swaybar/tray/icon.c
+++ b/swaybar/tray/icon.c
@@ -412,7 +412,7 @@ static char *find_icon_in_subdir(char *name, char *basedir, char *theme,
412#endif 412#endif
413 "png", 413 "png",
414#if HAVE_GDK_PIXBUF 414#if HAVE_GDK_PIXBUF
415 "xpm" 415 "xpm" // deprecated
416#endif 416#endif
417 }; 417 };
418 418
@@ -508,21 +508,13 @@ static char *find_icon_with_theme(list_t *basedirs, list_t *themes, char *name,
508 return icon; 508 return icon;
509} 509}
510 510
511char *find_icon_in_dir(char *name, char *dir, int *min_size, int *max_size) {
512 char *icon = find_icon_in_subdir(name, dir, "", "");
513 if (icon) {
514 *min_size = 1;
515 *max_size = 512;
516 }
517 return icon;
518
519}
520
521static char *find_fallback_icon(list_t *basedirs, char *name, int *min_size, 511static char *find_fallback_icon(list_t *basedirs, char *name, int *min_size,
522 int *max_size) { 512 int *max_size) {
523 for (int i = 0; i < basedirs->length; ++i) { 513 for (int i = 0; i < basedirs->length; ++i) {
524 char *icon = find_icon_in_dir(name, basedirs->items[i], min_size, max_size); 514 char *icon = find_icon_in_subdir(name, basedirs->items[i], "", "");
525 if (icon) { 515 if (icon) {
516 *min_size = 1;
517 *max_size = 512;
526 return icon; 518 return icon;
527 } 519 }
528 } 520 }
@@ -537,7 +529,7 @@ char *find_icon(list_t *themes, list_t *basedirs, char *name, int size,
537 icon = find_icon_with_theme(basedirs, themes, name, size, theme, 529 icon = find_icon_with_theme(basedirs, themes, name, size, theme,
538 min_size, max_size); 530 min_size, max_size);
539 } 531 }
540 if (!icon) { 532 if (!icon && !(theme && strcmp(theme, "Hicolor") == 0)) {
541 icon = find_icon_with_theme(basedirs, themes, name, size, "Hicolor", 533 icon = find_icon_with_theme(basedirs, themes, name, size, "Hicolor",
542 min_size, max_size); 534 min_size, max_size);
543 } 535 }