[wiki] [sites] dwm-appicons fix || Rumen
commit 31e7d6198aa0e294e5109cfc0b3c03ad6106c35f
Author: Rumen <rumenmitov_AT_protonmail.com>
Date: Mon Jan 6 14:29:25 2025 +0100
dwm-appicons fix
appicons patch should now correctly handle mouse clicks
diff --git a/dwm.suckless.org/patches/appicons/dwm-appicons-6.5.diff b/dwm.suckless.org/patches/appicons/dwm-appicons-6.5.diff
index fb970cd9..05f3b86b 100644
--- a/dwm.suckless.org/patches/appicons/dwm-appicons-6.5.diff
+++ b/dwm.suckless.org/patches/appicons/dwm-appicons-6.5.diff
_AT_@ -1,14 +1,13 @@
-From 5bd12261788064919c47ea35085bba6c9a1110ed Mon Sep 17 00:00:00 2001
+From f967b9b49ab3522d84fba8d95bbd90b6b5db0052 Mon Sep 17 00:00:00 2001
From: Rumen <rumenmitov_AT_protonmail.com>
-Date: Sat, 4 Jan 2025 22:28:14 +0100
-Subject: [PATCH] appicons patch:
+Date: Mon, 6 Jan 2025 14:22:39 +0100
+Subject: [PATCH] appicons patch
-clients can now be assigned icons based on rules set by the user.
-these icons will be displayed insteas of the tag indicator and tag name.
+Adds support for app icons that can replace the tag indicator and tag name.
---
config.def.h | 14 ++++--
- dwm.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++--
- 2 files changed, 136 insertions(+), 6 deletions(-)
+ dwm.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++--
+ 2 files changed, 147 insertions(+), 7 deletions(-)
diff --git a/config.def.h b/config.def.h
index 9efa774..3045af6 100644
_AT_@ -41,7 +40,7 @@ index 9efa774..3045af6 100644
/* layout(s) */
diff --git a/dwm.c b/dwm.c
-index 1443802..069ece9 100644
+index 1443802..35327af 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -85,6 +85,7 @@ typedef struct Monitor Monitor;
_AT_@ -52,7 +51,15 @@ index 1443802..069ece9 100644
float mina, maxa;
int x, y, w, h;
int oldx, oldy, oldw, oldh;
-_AT_@ -138,6 +139,7 @@ typedef struct {
+_AT_@ -121,6 +122,7 @@ struct Monitor {
+ unsigned int seltags;
+ unsigned int sellt;
+ unsigned int tagset[2];
++ char **tag_icons;
+ int showbar;
+ int topbar;
+ Client *clients;
+_AT_@ -138,6 +140,7 @@ typedef struct {
unsigned int tags;
int isfloating;
int monitor;
_AT_@ -60,7 +67,7 @@ index 1443802..069ece9 100644
} Rule;
/* function declarations */
-_AT_@ -160,6 +162,9 @@ static void destroynotify(XEvent *e);
+_AT_@ -160,6 +163,9 @@ static void destroynotify(XEvent *e);
static void detach(Client *c);
static void detachstack(Client *c);
static Monitor *dirtomon(int dir);
_AT_@ -70,7 +77,7 @@ index 1443802..069ece9 100644
static void drawbar(Monitor *m);
static void drawbars(void);
static void enternotify(XEvent *e);
-_AT_@ -283,7 +288,13 @@ applyrules(Client *c)
+_AT_@ -283,7 +289,13 @@ applyrules(Client *c)
Monitor *m;
XClassHint ch = { NULL, NULL };
_AT_@ -84,7 +91,7 @@ index 1443802..069ece9 100644
c->isfloating = 0;
c->tags = 0;
XGetClassHint(dpy, c->win, &ch);
-_AT_@ -296,6 +307,8 @@ applyrules(Client *c)
+_AT_@ -296,6 +308,8 @@ applyrules(Client *c)
&& (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance)))
{
_AT_@ -93,7 +100,43 @@ index 1443802..069ece9 100644
c->isfloating = r->isfloating;
c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next);
-_AT_@ -694,6 +707,96 @@ dirtomon(int dir)
+_AT_@ -433,7 +447,7 @@ buttonpress(XEvent *e)
+ if (ev->window == selmon->barwin) {
+ i = x = 0;
+ do
+- x += TEXTW(tags[i]);
++ x += TEXTW(m->tag_icons[i]);
+ while (ev->x >= x && ++i < LENGTH(tags));
+ if (i < LENGTH(tags)) {
+ click = ClkTagBar;
+_AT_@ -508,6 +522,12 @@ cleanupmon(Monitor *mon)
+ }
+ XUnmapWindow(dpy, mon->barwin);
+ XDestroyWindow(dpy, mon->barwin);
++
++ for (int i = 0; i < LENGTH(tags); i++) {
++ free(mon->tag_icons[i]);
++ mon->tag_icons[i] = NULL;
++ }
++
+ free(mon);
+ }
+
+_AT_@ -643,6 +663,13 @@ createmon(void)
+ m->lt[0] = &layouts[0];
+ m->lt[1] = &layouts[1 % LENGTH(layouts)];
+ strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
++
++ m->tag_icons = (char**) malloc(LENGTH(tags));
++ if (m->tag_icons == NULL) perror("dwm: malloc()");
++ for (int i = 0; i < LENGTH(tags); i++) {
++ m->tag_icons[i] = NULL;
++ }
++
+ return m;
+ }
+
+_AT_@ -694,6 +721,96 @@ dirtomon(int dir)
return m;
}
_AT_@ -190,22 +233,23 @@ index 1443802..069ece9 100644
void
drawbar(Monitor *m)
{
-_AT_@ -713,22 +816,41 @@ drawbar(Monitor *m)
+_AT_@ -713,22 +830,37 @@ drawbar(Monitor *m)
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
}
-+ char *tag_icons[LENGTH(tags)];
+ int icons_per_tag[LENGTH(tags)];
+ memset(icons_per_tag, 0, LENGTH(tags) * sizeof(int));
+
+ for (int i = 0; i < LENGTH(tags); i++) {
++ if (m->tag_icons[i]) free(m->tag_icons[i]);
++
+ /* set each tag to default value */
-+ tag_icons[i] = strndup(tags[i], strlen(tags[i]));
++ m->tag_icons[i] = strndup(tags[i], strlen(tags[i]));
+ }
+
for (c = m->clients; c; c = c->next) {
+ if (c->appicon && strlen(c->appicon) > 0) {
-+ applyappicon(tag_icons, icons_per_tag, c);
++ applyappicon(m->tag_icons, icons_per_tag, c);
+ }
+
occ |= c->tags;
_AT_@ -215,22 +259,17 @@ index 1443802..069ece9 100644
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
- w = TEXTW(tags[i]);
-+ w = TEXTW(tag_icons[i]);
++ w = TEXTW(m->tag_icons[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
- if (occ & 1 << i)
-+ drw_text(drw, x, 0, w, bh, lrpad / 2, tag_icons[i], urg & 1 << i);
++ drw_text(drw, x, 0, w, bh, lrpad / 2, m->tag_icons[i], urg & 1 << i);
+ if (occ & 1 << i && icons_per_tag[i] == 0)
drw_rect(drw, x + boxs, boxs, boxw, boxw,
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
urg & 1 << i);
x += w;
}
-+
-+ for (int i = 0; i < LENGTH(tags); i++) {
-+ free(tag_icons[i]);
-+ tag_icons[i] = NULL;
-+ }
+
w = TEXTW(m->ltsymbol);
drw_setscheme(drw, scheme[SchemeNorm]);
Received on Mon Jan 06 2025 - 14:29:46 CET
This archive was generated by hypermail 2.3.0
: Mon Jan 06 2025 - 14:36:55 CET