From 955529b809d16c0dab5d57dcba01a80dad0e8e91 Mon Sep 17 00:00:00 2001 From: Rumen Date: Mon, 1 Dec 2025 20:36:01 +0100 Subject: [PATCH] fix(bar-appicons): fixed compiler warnings --- patches/bar-appicons/bar-appicons.patch | 103 +++++++++++++----------- 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/patches/bar-appicons/bar-appicons.patch b/patches/bar-appicons/bar-appicons.patch index 95a0c85..eaacf3d 100644 --- a/patches/bar-appicons/bar-appicons.patch +++ b/patches/bar-appicons/bar-appicons.patch @@ -1,12 +1,12 @@ -From f0c747be0deca64801fe01eebfa78ce5b3d803fe Mon Sep 17 00:00:00 2001 +From f5d1206f7f467cafd5a0217a46c31928316ba2fe Mon Sep 17 00:00:00 2001 From: Rumen -Date: Fri, 24 Oct 2025 17:14:02 +0200 -Subject: [PATCH] fix: appicons displaying on all monitors +Date: Mon, 1 Dec 2025 20:29:49 +0100 +Subject: [PATCH] fix(bar-appicons): fixed various compiler warnings --- config.def.h | 14 +++-- - dwl.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++-- - 2 files changed, 149 insertions(+), 7 deletions(-) + dwl.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 150 insertions(+), 7 deletions(-) diff --git a/config.def.h b/config.def.h index 1b7472d..a48b78d 100644 @@ -15,7 +15,7 @@ index 1b7472d..a48b78d 100644 @@ -26,12 +26,20 @@ static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; /* logging */ static int log_level = WLR_ERROR; - + +/* appicons */ +/* NOTE: set to 0 to set to default (whitespace) */ +static char outer_separator_beg = '['; @@ -34,10 +34,10 @@ index 1b7472d..a48b78d 100644 + { "Gimp_EXAMPLE", NULL, 0, 1, -1, NULL }, /* Start on currently visible tags floating, not tiled */ + { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, "" }, /* Start on ONLY tag "9" */ }; - + /* layout(s) */ diff --git a/dwl.c b/dwl.c -index bf340d8..ba6388a 100644 +index bf340d8..e2baf66 100644 --- a/dwl.c +++ b/dwl.c @@ -143,6 +143,7 @@ typedef struct { @@ -62,7 +62,7 @@ index bf340d8..ba6388a 100644 int monitor; + const char *appicon; } Rule; - + typedef struct { @@ -313,6 +316,9 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data); static void destroysessionlock(struct wl_listener *listener, void *data); @@ -70,28 +70,27 @@ index bf340d8..ba6388a 100644 static Monitor *dirtomon(enum wlr_direction dir); +static void remove_outer_separators(char **str); +static void appiconsappend(char **str, const char *appicon, size_t new_size); -+static void applyappicon(char *tag_icons[], int *icons_per_tag, const Client *c); ++static void applyappicon(char *tag_icons[], unsigned int *icons_per_tag, const Client *c); static void drawbar(Monitor *m); static void drawbars(void); static void focusclient(Client *c, int lift); -@@ -520,6 +526,11 @@ applybounds(Client *c, struct wlr_box *bbox) - void - applyrules(Client *c) - { +@@ -527,12 +533,19 @@ applyrules(Client *c) + const Rule *r; + Monitor *mon = selmon, *m; + + outer_separator_beg = outer_separator_beg ? outer_separator_beg : ' '; + outer_separator_end = outer_separator_end ? outer_separator_end : ' '; + inner_separator = inner_separator ? inner_separator : ' '; + truncate_icons_after = truncate_icons_after > 0 ? truncate_icons_after : 1; + - /* rule matching */ - const char *appid, *title; - uint32_t newtags = 0; -@@ -533,6 +544,8 @@ applyrules(Client *c) + appid = client_get_appid(c); + title = client_get_title(c); + for (r = rules; r < END(rules); r++) { if ((!r->title || strstr(title, r->title)) && (!r->id || strstr(appid, r->id))) { + /* r->appicon is static, so lifetime is sufficient */ -+ c->appicon = (char*) r->appicon; ++ c->appicon = (char*) r->appicon; c->isfloating = r->isfloating; newtags |= r->tags; i = 0; @@ -107,10 +106,10 @@ index bf340d8..ba6388a 100644 @@ -905,6 +918,16 @@ cleanupmon(struct wl_listener *listener, void *data) wlr_output_layout_remove(output_layout, m->wlr_output); wlr_scene_output_destroy(m->scene_output); - -+ for (int i = 0; i < LENGTH(tags); i++) { -+ if (m->tag_icons[i]) free(m->tag_icons[i]); -+ m->tag_icons[i] = NULL; + ++ for (long unsigned int tag_idx = 0; tag_idx < LENGTH(tags); tag_idx++) { ++ if (m->tag_icons[tag_idx]) free(m->tag_icons[tag_idx]); ++ m->tag_icons[tag_idx] = NULL; + } + + if (m->tag_icons) { @@ -128,32 +127,32 @@ index bf340d8..ba6388a 100644 + + m->tag_icons = (char**) malloc(LENGTH(tags) * sizeof(char*)); + if (m->tag_icons == NULL) perror("dwm: malloc()"); -+ for (int i = 0; i < LENGTH(tags); i++) { -+ m->tag_icons[i] = NULL; ++ for (long unsigned int tag_idx = 0; tag_idx < LENGTH(tags); tag_idx++) { ++ m->tag_icons[tag_idx] = NULL; + } + wlr_output_state_set_scale(&state, r->scale); wlr_output_state_set_transform(&state, r->rr); break; -@@ -1566,6 +1596,97 @@ dirtomon(enum wlr_direction dir) +@@ -1566,6 +1596,98 @@ dirtomon(enum wlr_direction dir) return selmon; } - + +void +remove_outer_separators(char **str) +{ -+ size_t clean_tag_name_len = strlen(*str) - 2; ++ const char *clean_tag_name_beg = *str + 1; ++ const size_t clean_tag_name_len = strlen(*str) - 2; + -+ char *temp_tag_name = (char*) ++ char *temp_tag_name = (char*) + malloc(clean_tag_name_len + 1); + + if (temp_tag_name == NULL) perror("dwm: malloc()"); + + memset(temp_tag_name, 0, clean_tag_name_len + 1); + -+ char *clean_tag_name_beg = *str + 1; -+ strncpy(temp_tag_name, -+ clean_tag_name_beg, ++ strncpy(temp_tag_name, ++ clean_tag_name_beg, + clean_tag_name_len); + + if (*str) free(*str); @@ -185,11 +184,15 @@ index bf340d8..ba6388a 100644 +} + +void -+applyappicon(char *tag_icons[], int *icons_per_tag, const Client *c) ++applyappicon(char *tag_icons[], unsigned int *icons_per_tag, const Client *c) +{ ++ const size_t outer_separators_size = 2; ++ const size_t inner_separator_size = 1; ++ size_t new_size = 0; ++ + for (unsigned t = 1, i = 0; + i < LENGTH(tags); -+ t <<= 1, i++) ++ t <<= 1, i++) + { + if (c->tags & t) { + if (icons_per_tag[i] == 0) { @@ -205,18 +208,15 @@ index bf340d8..ba6388a 100644 + icons_per_tag[i]++; + continue; + } -+ ++ + /* remove outer separators from previous iterations + * otherwise they get applied recursively */ + if (icons_per_tag[i] > 1) { + remove_outer_separators(&tag_icons[i]); + } + -+ size_t outer_separators_size = 2; -+ size_t inner_separator_size = 1; -+ -+ size_t new_size = strlen(tag_icons[i]) -+ + outer_separators_size ++ new_size = strlen(tag_icons[i]) ++ + outer_separators_size + + inner_separator_size + + strlen(icon) + + 1; @@ -233,16 +233,23 @@ index bf340d8..ba6388a 100644 void drawbar(Monitor *m) { -@@ -1588,9 +1709,22 @@ drawbar(Monitor *m) +@@ -1575,6 +1697,7 @@ drawbar(Monitor *m) + uint32_t i, occ = 0, urg = 0; + Client *c; + Buffer *buf; ++ unsigned int icons_per_tag[LENGTH(tags)]; + + if (!m->scene_buffer->node.enabled) + return; +@@ -1588,9 +1711,21 @@ drawbar(Monitor *m) drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0); } - -+ int icons_per_tag[LENGTH(tags)]; + + memset(icons_per_tag, 0, LENGTH(tags) * sizeof(int)); + -+ for (int i = 0; i < LENGTH(tags); i++) { ++ for (long unsigned int tag_idx = 0; tag_idx < LENGTH(tags); tag_idx++) { + /* set each tag to default value */ -+ m->tag_icons[i] = strndup(tags[i], strlen(tags[i])); ++ m->tag_icons[tag_idx] = strndup(tags[tag_idx], strlen(tags[tag_idx])); + } + wl_list_for_each(c, &clients, link) { @@ -256,7 +263,7 @@ index bf340d8..ba6388a 100644 occ |= c->tags; if (c->isurgent) urg |= c->tags; -@@ -1598,10 +1732,10 @@ drawbar(Monitor *m) +@@ -1598,10 +1733,10 @@ drawbar(Monitor *m) x = 0; c = focustop(m); for (i = 0; i < LENGTH(tags); i++) { @@ -270,6 +277,6 @@ index bf340d8..ba6388a 100644 drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, m == selmon && c && c->tags & 1 << i, urg & 1 << i); --- -2.51.1 +-- +2.52.0