sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 229e76a9264bed47cd5e281a3eee5abfeab397d4
parent bf3006154186d82b4bd9bea00e2a037becd3a85f
Author: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date:   Mon,  9 Nov 2015 21:40:39 +0100

[dwm][fancybar] Update patch

Diffstat:
Ddwm.suckless.org/patches/dwm-35db6d8-fancybar.diff | 69---------------------------------------------------------------------
Adwm.suckless.org/patches/dwm-6.1-fancybar.diff | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ddwm.suckless.org/patches/fancybar-c794a9f5ae5e.patch | 124-------------------------------------------------------------------------------
Ddwm.suckless.org/patches/fancybar-r1496.diff | 126-------------------------------------------------------------------------------
Mdwm.suckless.org/patches/fancybar.md | 4+---
5 files changed, 71 insertions(+), 322 deletions(-)

diff --git a/dwm.suckless.org/patches/dwm-35db6d8-fancybar.diff b/dwm.suckless.org/patches/dwm-35db6d8-fancybar.diff @@ -1,69 +0,0 @@ -diff --git a/dwm.c b/dwm.c -index f896170..3da4cf2 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -692,11 +692,13 @@ dirtomon(int dir) { - - void - drawbar(Monitor *m) { -- int x, xx, w; -- unsigned int i, occ = 0, urg = 0; -+ int x, xx, w, tw, mw; -+ unsigned int i, occ = 0, urg = 0, n = 0, extra = 0; - Client *c; - - for(c = m->clients; c; c = c->next) { -+ if(ISVISIBLE(c)) -+ n++; - occ |= c->tags; - if(c->isurgent) - urg |= c->tags; -@@ -728,15 +730,40 @@ drawbar(Monitor *m) { - x = m->ww; - if((w = x - xx) > bh) { - x = xx; -- if(m->sel) { -- drw_setscheme(drw, m == selmon ? &scheme[SchemeSel] : &scheme[SchemeNorm]); -- drw_text(drw, x, 0, w, bh, m->sel->name, 0); -- drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating, 0); -- } -- else { -- drw_setscheme(drw, &scheme[SchemeNorm]); -- drw_text(drw, x, 0, w, bh, NULL, 0); -+ if(n > 0) { -+ tw = m->sel->name ? TEXTW(m->sel->name) : 0; -+ mw = (tw >= w || n == 1) ? 0 : (w - tw) / (n - 1); -+ -+ i = 0; -+ for(c = m->clients; c; c = c->next) { -+ if(!ISVISIBLE(c) || c == m->sel) -+ continue; -+ tw = TEXTW(c->name); -+ if(tw < mw) -+ extra += (mw - tw); -+ else -+ i++; -+ } -+ if(i > 0) -+ mw += extra / i; -+ -+ for(c = m->clients; c; c = c->next) { -+ if(!ISVISIBLE(c)) -+ continue; -+ xx = x + w; -+ tw = TEXTW(c->name); -+ w = MIN(m->sel == c ? w : mw, tw); -+ -+ drw_setscheme(drw, m->sel == c ? &scheme[SchemeSel] : &scheme[SchemeNorm]); -+ drw_text(drw, x, 0, w, bh, c->name, 0); -+ drw_rect(drw, x, 0, w, bh, c->isfixed, c->isfloating, 0); -+ -+ x += w; -+ w = xx - x; -+ } - } -+ drw_setscheme(drw, &scheme[SchemeNorm]); -+ drw_text(drw, x, 0, w, bh, NULL, 0); - } - drw_map(drw, m->barwin, 0, 0, m->ww, bh); - } diff --git a/dwm.suckless.org/patches/dwm-6.1-fancybar.diff b/dwm.suckless.org/patches/dwm-6.1-fancybar.diff @@ -0,0 +1,70 @@ +diff --git a/dwm.c b/dwm.c +index 0362114..b74e787 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -704,13 +704,15 @@ dirtomon(int dir) + void + drawbar(Monitor *m) + { +- int x, xx, w, dx; +- unsigned int i, occ = 0, urg = 0; ++ int x, xx, w, dx, tw, mw; ++ unsigned int i, occ = 0, urg = 0, n = 0, extra = 0; + Client *c; + + dx = (drw->fonts[0]->ascent + drw->fonts[0]->descent + 2) / 4; + + for (c = m->clients; c; c = c->next) { ++ if (ISVISIBLE(c)) ++ n++; + occ |= c->tags; + if (c->isurgent) + urg |= c->tags; +@@ -741,14 +743,40 @@ drawbar(Monitor *m) + x = m->ww; + if ((w = x - xx) > bh) { + x = xx; +- if (m->sel) { +- drw_setscheme(drw, m == selmon ? &scheme[SchemeSel] : &scheme[SchemeNorm]); +- drw_text(drw, x, 0, w, bh, m->sel->name, 0); +- drw_rect(drw, x + 1, 1, dx, dx, m->sel->isfixed, m->sel->isfloating, 0); +- } else { +- drw_setscheme(drw, &scheme[SchemeNorm]); +- drw_rect(drw, x, 0, w, bh, 1, 0, 1); ++ if (n > 0) { ++ tw = m->sel->name ? TEXTW(m->sel->name) : 0; ++ mw = (tw >= w || n == 1) ? 0 : (w - tw) / (n - 1); ++ ++ i = 0; ++ for (c = m->clients; c; c = c->next) { ++ if (!ISVISIBLE(c) || c == m->sel) ++ continue; ++ tw = TEXTW(c->name); ++ if(tw < mw) ++ extra += (mw - tw); ++ else ++ i++; ++ } ++ if (i > 0) ++ mw += extra / i; ++ ++ for (c = m->clients; c; c = c->next) { ++ if (!ISVISIBLE(c)) ++ continue; ++ xx = x + w; ++ tw = TEXTW(c->name); ++ w = MIN(m->sel == c ? w : mw, tw); ++ ++ drw_setscheme(drw, m->sel == c ? &scheme[SchemeSel] : &scheme[SchemeNorm]); ++ drw_text(drw, x, 0, w, bh, c->name, 0); ++ drw_rect(drw, x + 1, 1, dx, dx, c->isfixed, c->isfloating, 0); ++ ++ x += w; ++ w = xx - x; ++ } + } ++ drw_setscheme(drw, &scheme[SchemeNorm]); ++ drw_rect(drw, x, 0, w, bh, 1, 0, 1); + } + drw_map(drw, m->barwin, 0, 0, m->ww, bh); + } diff --git a/dwm.suckless.org/patches/fancybar-c794a9f5ae5e.patch b/dwm.suckless.org/patches/fancybar-c794a9f5ae5e.patch @@ -1,124 +0,0 @@ ---- dwm.c.orig 2012-09-30 16:19:00.251353990 -0400 -+++ dwm.c 2012-09-30 16:18:06.436026937 -0400 -@@ -179,6 +179,7 @@ - static Monitor *dirtomon(int dir); - static void drawbar(Monitor *m); - static void drawbars(void); -+static void drawline(unsigned long col[ColLast]); - static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]); - static void drawtext(const char *text, unsigned long col[ColLast], Bool invert); - static void enternotify(XEvent *e); -@@ -721,12 +722,15 @@ - - void - drawbar(Monitor *m) { -- int x; -- unsigned int i, occ = 0, urg = 0; -+ int x, ow, mw = 0, extra, tw; -+ unsigned int i, n = 0, occ = 0, urg = 0; - unsigned long *col; -- Client *c; -+ Client *c, *firstvis, *lastvis = NULL; -+ DC seldc; - - for(c = m->clients; c; c = c->next) { -+ if(ISVISIBLE(c)) -+ n++; - occ |= c->tags; - if(c->isurgent) - urg |= c->tags; -@@ -755,16 +759,61 @@ - } - else - dc.x = m->ww; -- if((dc.w = dc.x - x) > bh) { -- dc.x = x; -- if(m->sel) { -- col = m == selmon ? dc.sel : dc.norm; -- drawtext(m->sel->name, col, False); -- drawsquare(m->sel->isfixed, m->sel->isfloating, False, col); -+ for(c = m->clients; c && !ISVISIBLE(c); c = c->next); -+ firstvis = c; -+ -+ col = m == selmon ? dc.sel : dc.norm; -+ dc.w = dc.x - x; -+ dc.x = x; -+ -+ if(n > 0) { -+ mw = dc.w / n; -+ extra = 0; -+ seldc = dc; -+ i = 0; -+ -+ while(c) { -+ lastvis = c; -+ tw = TEXTW(c->name); -+ if(tw < mw) extra += (mw - tw); else i++; -+ for(c = c->next; c && !ISVISIBLE(c); c = c->next); - } -- else -+ -+ if(i > 0) mw += extra / i; -+ -+ c = firstvis; -+ x = dc.x; -+ } -+ -+ while(dc.w > bh) { -+ if(c) { -+ ow = dc.w; -+ tw = TEXTW(c->name); -+ dc.w = MIN(ow, tw); -+ -+ if(dc.w > mw) dc.w = mw; -+ if(m->sel ==c) seldc = dc; -+ if(c == lastvis) dc.w = ow; -+ -+ drawtext(c->name, col, False); -+ if(c != firstvis) drawline(col); -+ drawsquare(c->isfixed, c->isfloating, False, col); -+ -+ dc.x += dc.w; -+ dc.w = ow - dc.w; -+ for(c = c->next; c&& !ISVISIBLE(c); c = c->next); -+ } else { - drawtext(NULL, dc.norm, False); -+ break; -+ } - } -+ -+ if(m == selmon && m->sel && ISVISIBLE(m->sel)) { -+ dc = seldc; -+ drawtext(m->sel->name, col, True); -+ drawsquare(m->sel->isfixed, m->sel->isfloating, True, col); -+ } -+ - XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0); - XSync(dpy, False); - } -@@ -778,6 +827,15 @@ - } - - void -+drawline(unsigned long col[ColLast]) { -+ XGCValues gcv; -+ -+ gcv.foreground = col[ColFG]; -+ XChangeGC(dpy, dc.gc, GCForeground, &gcv); -+ XDrawLine(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.x, dc.y + (dc.font.ascent + dc.font.descent + 2)); -+} -+ -+void - drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) { - int x; - -@@ -1327,8 +1385,7 @@ - } - if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { - updatetitle(c); -- if(c == c->mon->sel) -- drawbar(c->mon); -+ drawbar(c->mon); - } - if(ev->atom == netatom[NetWMWindowType]) - updatewindowtype(c); diff --git a/dwm.suckless.org/patches/fancybar-r1496.diff b/dwm.suckless.org/patches/fancybar-r1496.diff @@ -1,126 +0,0 @@ -diff -r de4a2998e1f5 dwm.c ---- a/dwm.c Tue Sep 22 09:53:11 2009 +0100 -+++ b/dwm.c Tue Sep 22 12:32:15 2009 +0200 -@@ -171,6 +171,7 @@ - static Monitor *dirtomon(int dir); - static void drawbar(Monitor *m); - static void drawbars(void); -+static void drawvline(unsigned long col[ColLast]); - static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]); - static void drawtext(const char *text, unsigned long col[ColLast], Bool invert); - static void enternotify(XEvent *e); -@@ -668,12 +669,15 @@ - - void - drawbar(Monitor *m) { -- int x; -- unsigned int i, occ = 0, urg = 0; -+ int x, ow, mw = 0, extra, tw; -+ unsigned int i, n = 0, occ = 0, urg = 0; - unsigned long *col; -- Client *c; -+ Client *c, *firstvis, *lastvis = NULL; -+ DC seldc; - - for(c = m->clients; c; c = c->next) { -+ if(ISVISIBLE(c)) -+ n++; - occ |= c->tags; - if(c->isurgent) - urg |= c->tags; -@@ -702,16 +706,62 @@ - } - else - dc.x = m->ww; -- if((dc.w = dc.x - x) > bh) { -- dc.x = x; -- if(m->sel) { -- col = m == selmon ? dc.sel : dc.norm; -- drawtext(m->sel->name, col, False); -- drawsquare(m->sel->isfixed, m->sel->isfloating, False, col); -+ -+ for(c = m->clients; c && !ISVISIBLE(c); c = c->next); -+ firstvis = c; -+ -+ col = m == selmon ? dc.sel : dc.norm; -+ dc.w = dc.x - x; -+ dc.x = x; -+ -+ if(n > 0) { -+ mw = dc.w / n; -+ extra = 0; -+ seldc = dc; -+ i = 0; -+ -+ while(c) { -+ lastvis = c; -+ tw = TEXTW(c->name); -+ if(tw < mw) extra += (mw - tw); else i++; -+ for(c = c->next; c && !ISVISIBLE(c); c = c->next); - } -- else -+ -+ if(i > 0) mw += extra / i; -+ -+ c = firstvis; -+ x = dc.x; -+ } -+ -+ while(dc.w > bh) { -+ if(c) { -+ ow = dc.w; -+ tw = TEXTW(c->name); -+ dc.w = MIN(ow, tw); -+ -+ if(dc.w > mw) dc.w = mw; -+ if(m->sel == c) seldc = dc; -+ if(c == lastvis) dc.w = ow; -+ -+ drawtext(c->name, col, False); -+ if(c != firstvis) drawvline(col); -+ drawsquare(c->isfixed, c->isfloating, False, col); -+ -+ dc.x += dc.w; -+ dc.w = ow - dc.w; -+ for(c = c->next; c && !ISVISIBLE(c); c = c->next); -+ } else { - drawtext(NULL, dc.norm, False); -+ break; -+ } - } -+ -+ if(m == selmon && m->sel && ISVISIBLE(m->sel)) { -+ dc = seldc; -+ drawtext(m->sel->name, col, True); -+ drawsquare(m->sel->isfixed, m->sel->isfloating, True, col); -+ } -+ - XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0); - XSync(dpy, False); - } -@@ -725,6 +775,15 @@ - } - - void -+drawvline(unsigned long col[ColLast]) { -+ XGCValues gcv; -+ -+ gcv.foreground = col[ColFG]; -+ XChangeGC(dpy, dc.gc, GCForeground, &gcv); -+ XDrawLine(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.x, dc.y + (dc.font.ascent + dc.font.descent + 2)); -+} -+ -+void - drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) { - int x; - XGCValues gcv; -@@ -1274,8 +1333,7 @@ - } - if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { - updatetitle(c); -- if(c == c->mon->sel) -- drawbar(c->mon); -+ drawbar(c->mon); - } - } - } diff --git a/dwm.suckless.org/patches/fancybar.md b/dwm.suckless.org/patches/fancybar.md @@ -13,9 +13,7 @@ fit, they're cropped. The title of the selected window is inverted. ## Download * [fancybar-5.6.1.diff](historical/fancybar-5.6.1.diff) (dwm 5.6.1) (20090824) - * [fancybar-r1496.diff](fancybar-r1496.diff) (dwm 5.7) (20090922) - * [fancybar-c794a9f5ae5e.patch](fancybar-c794a9f5ae5e.patch) (20120708) - * [dwm-35db6d8-fancybar.diff](dwm-35db6d8-fancybar.diff) (20150105) + * [dwm-6.1-fancybar.diff](dwm-6.1-fancybar.diff) (20151109) ## Author