adamyuan / dwm-winicon Goto Github PK
View Code? Open in Web Editor NEWA patch adding window icons to DWM
License: MIT License
A patch adding window icons to DWM
License: MIT License
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);
Hi.
I'm trying to patch dwm 6.4 with fullgaps, alpha and winicon. It patches with just fullgaps + winicon, but fails with alpha + winicon and fullgaps + alpha + winicon. Here is the patch output:
$ patch <dwm-winicon-6.3-v2.1.diff
patching file config.def.h
Hunk #1 succeeded at 5 with fuzz 1.
patching file config.mk
Hunk #1 FAILED at 22.
1 out of 1 hunk FAILED -- saving rejects to file config.mk.rej
patching file drw.c
Hunk #2 FAILED at 72.
Hunk #3 FAILED at 86.
Hunk #4 succeeded at 226 (offset -11 lines).
Hunk #5 succeeded at 447 (offset 6 lines).
2 out of 5 hunks FAILED -- saving rejects to file drw.c.rej
patching file drw.h
Hunk #1 succeeded at 24 with fuzz 2 (offset 3 lines).
Hunk #2 succeeded at 54 (offset 4 lines).
patching file dwm.c
Hunk #2 succeeded at 66 (offset 4 lines).
Hunk #3 succeeded at 99 (offset 4 lines).
Hunk #4 succeeded at 177 (offset 4 lines).
Hunk #5 succeeded at 222 (offset 4 lines).
Hunk #6 succeeded at 234 (offset 4 lines).
Hunk #7 succeeded at 754 (offset 13 lines).
Hunk #8 succeeded at 895 (offset 13 lines).
Hunk #9 succeeded at 1113 (offset 11 lines).
Hunk #10 succeeded at 1320 (offset 7 lines).
Hunk #11 succeeded at 1642 (offset 8 lines).
Hunk #12 succeeded at 1831 (offset 4 lines).
Hunk #13 succeeded at 1861 (offset 4 lines).
Hunk #14 succeeded at 2100 (offset 8 lines).
Hello I was going to 'implement' this (it would take me months since im still learning about xlib) but just in case, I search it on github and found this.
I wanna know if you have any ideas on making the icons compatible with the dwm alpha patch.
Its a little annoyance i know; I tried having the icon its own scheme, putting a rectangle behind it but the opacity doesnt seem to care.
Anyway, now thanks to you I have icons!
Hi Adam,
I am trying to figure out how to patch winicon with awesomebar, alpha, and systray. Here is my code for drawbar
which is where the main conflict is.
drawbar(Monitor *m)
{
int x, w, sw = 0, stw = 0, n = 0, scm;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
Client *c;
if (showsystray && m == systraytomon(m) && !systrayonleft)
stw = getsystraywidth();
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
drw_setscheme(drw, scheme[SchemeNorm]);
sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
drw_text(drw, m->ww - sw - stw, 0, sw, bh, 0, stext, 0);
}
for (c = m->clients; c; c = c->next) {
if (ISVISIBLE(c))
n++;
occ |= c->tags;
if (c->isurgent)
urg |= c->tags;
}
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);
x += w;
}
w = blw = TEXTW(m->ltsymbol);
drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - sw - stw - x) > bh) {
if (n > 0) {
int remainder = w % n;
int tabw = (1.0 / (double)n) * w + 1;
for (c = m->clients; c; c = c->next) {
if (!ISVISIBLE(c))
continue;
if (m->sel == c)
scm = SchemeSel;
else if (HIDDEN(c))
scm = SchemeHid;
else
scm = SchemeNorm;
drw_setscheme(drw, scheme[scm]);
if (remainder >= 0) {
if (remainder == 0) {
tabw--;
}
remainder--;
}
drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0);
x += tabw;
}
} else {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
}
}
m->bt = n;
m->btw = w;
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
}
Here is the diff dwm.c.rej
if ((w = m->ww - sw - x) > bh) {
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
+ drw_text(drw, x, 0, w, bh, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0), m->sel->name, 0);
+ if (m->sel->icon) drw_pic(drw, x + lrpad / 2, (bh - m->sel->ich) / 2, m->sel->icw, m->sel->ich, m->sel->icon);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.