Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show icon of occupied tab #7

Closed
andreoestereich opened this issue Aug 11, 2022 · 1 comment
Closed

Show icon of occupied tab #7

andreoestereich opened this issue Aug 11, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@andreoestereich
Copy link

Hi. Really enjoyed your patch. I made some changes in the way the bar is drawn to display the icon of the selected window for each occupied tab and I was wondering if you might want to include it in your patch. My implementation of it is shown bellow

diff --git a/dwm.c b/dwm.c
index ad04bb4..e82d8d7 100644
--- a/dwm.c
+++ b/dwm.c
@@ -760,8 +760,10 @@ drawbar(Monitor *m)
 	int x, w, tw = 0;
 	int boxs = drw->fonts->h / 9;
 	int boxw = drw->fonts->h / 6 + 2;
-	unsigned int i, occ = 0, urg = 0;
-	Client *c;
+	unsigned int i, urg = 0;
+	Client *c, *c_tags[LENGTH(tags)];
+	for (i = 0; i < LENGTH(tags); i++)
+		c_tags[i] = NULL;

 	if (!m->showbar)
 		return;
@@ -773,20 +775,24 @@ drawbar(Monitor *m)
 		drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
 	}

-	for (c = m->clients; c; c = c->next) {
-		occ |= c->tags;
+	for (c = m->stack; c; c = c->snext) {
 		if (c->isurgent)
 			urg |= c->tags;
+		for (i = 0; i < LENGTH(tags); i++)
+			if((!c_tags[i]) && ( c->tags & 1 << i))
+				c_tags[i] = c;
 	}
 	x = 0;
 	for (i = 0; i < LENGTH(tags); i++) {
-		w = TEXTW(tags[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_rect(drw, x + boxs, boxs, boxw, boxw,
-				m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
-				urg & 1 << i);
+		drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+		if (c_tags[i] && c_tags[i]->icon) {
+			w = lrpad/2 + c_tags[i]->icw;
+			drw_text(drw, x, 0, w, bh, lrpad / 2 + c_tags[i]->icw, "", urg & 1 << i);
+			drw_pic(drw, x + lrpad / 4, (bh - c_tags[i]->ich) / 2, c_tags[i]->icw, c_tags[i]->ich, c_tags[i]->icon);
+		} else {
+			w = TEXTW(tags[i]);
+			drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
+		}
 		x += w;
 	}
 	w = blw = TEXTW(m->ltsymbol);
@AdamYuan
Copy link
Owner

Thanks for your contribution, this is a great idea!
Sadly, I don't think this could be included as a "core" feature, since the display style of per-tag icons quite depends on personal preference.

@AdamYuan AdamYuan pinned this issue Aug 11, 2022
@AdamYuan AdamYuan added the enhancement New feature or request label Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants