[wiki] [sites] [dwm][fancybarclickable] Fix spaces || Ivan Tham

From: <git_AT_suckless.org>
Date: Sat, 26 Sep 2015 16:47:42 +0200

commit 5a626059e826442070c3c05a9c87d88341de8722
Author: Ivan Tham <pickfire_AT_riseup.net>
Date: Sat Sep 26 22:47:33 2015 +0800

    [dwm][fancybarclickable] Fix spaces

diff --git a/dwm.suckless.org/patches/dwm-6.1-fancybarclickable.diff b/dwm.suckless.org/patches/dwm-6.1-fancybarclickable.diff
index 8df0b4a..3353366 100755
--- a/dwm.suckless.org/patches/dwm-6.1-fancybarclickable.diff
+++ b/dwm.suckless.org/patches/dwm-6.1-fancybarclickable.diff
_AT_@ -6,7 +6,7 @@ index 875885b..05865bb 100644
          /* click event mask button function argument */
          { ClkLtSymbol, 0, Button1, setlayout, {0} },
          { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
-+ { ClkWinTitle, 0, Button1, focusonclick, {0} },
++ { ClkWinTitle, 0, Button1, focusonclick, {0} },
          { ClkWinTitle, 0, Button2, zoom, {0} },
          { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
          { ClkClientWin, MODKEY, Button1, movemouse, {0} },
_AT_@ -18,8 +18,8 @@ index f896170..cc2a4f2 100644
          Monitor *next;
          Window barwin;
          const Layout *lt[2];
-+ int titlebarbegin;
-+ int titlebarend;
++ int titlebarbegin;
++ int titlebarend;
  };
  
  typedef struct {
_AT_@ -44,9 +44,9 @@ index f896170..cc2a4f2 100644
                          click = ClkStatusText;
 - else
 + else {
-+ arg.ui = ev->x;
++ arg.ui = ev->x;
                          click = ClkWinTitle;
-+ }
++ }
          }
          else if((c = wintoclient(ev->window))) {
                  focus(c);
_AT_@ -67,13 +67,13 @@ index f896170..cc2a4f2 100644
 - unsigned int i, occ = 0, urg = 0;
 - Client *c;
 + int x, xx, w, ow, mw = 0, extra, tw, a = 0, s = 0;
-+ char posbuf[10];
++ char posbuf[10];
 + unsigned int i, occ = 0, urg = 0, n = 0;
 + Client *c, *firstvis, *lastvis = NULL;
  
          for(c = m->clients; c; c = c->next) {
-+ if(ISVISIBLE(c))
-+ n++;
++ if(ISVISIBLE(c))
++ n++;
                  occ |= c->tags;
                  if(c->isurgent)
                          urg |= c->tags;
_AT_@ -82,36 +82,35 @@ index f896170..cc2a4f2 100644
          xx = x;
          if(m == selmon) { /* status is only drawn on selected monitor */
 - w = TEXTW(stext);
-+ if(m->lt[m->sellt]->arrange == monocle){
-+ x = xx;
-+ for(c = nexttiled(m->clients), a = 0, s = 0; c; c = nexttiled(c->next), a++) {
-+ if(c == m->stack)
-+ s = a;
-+ }
-+ if(!s && a)
-+ s = a;
-+ snprintf(posbuf, LENGTH(posbuf), "[%d/%d]", s, a);
-+ w = TEXTW(posbuf);
-+ drw_text(drw, x, 0, w, bh, posbuf, 0);
-+ xx = x + w;
-+ }
++ if(m->lt[m->sellt]->arrange == monocle){
++ x = xx;
++ for(c = nexttiled(m->clients), a = 0, s = 0; c; c = nexttiled(c->next), a++) {
++ if(c == m->stack)
++ s = a;
++ }
++ if(!s && a)
++ s = a;
++ snprintf(posbuf, LENGTH(posbuf), "[%d/%d]", s, a);
++ w = TEXTW(posbuf);
++ drw_text(drw, x, 0, w, bh, posbuf, 0);
++ xx = x + w;
++ }
 +
-+ /*
-+ char *buf = stext, *ptr = buf;
-+ while (*ptr) {
-+ for (i = 0; *ptr < 0; i++, ptr++);
-+ w 2+= drw_font_getexts_width(drw->font, buf, i);
-+ w += TEXTW(buf);
-+ buf=++ptr;
-+ }*/
-+ w = TEXTW(stext);
++ /* char *buf = stext, *ptr = buf;
++ while (*ptr) {
++ for (i = 0; *ptr < 0; i++, ptr++);
++ w 2+= drw_font_getexts_width(drw->font, buf, i);
++ w += TEXTW(buf);
++ buf=++ptr;
++ } */
++ w = TEXTW(stext);
 +
                  x = m->ww - w;
                  if(x < xx) {
                          x = xx;
                          w = m->ww - xx;
                  }
-+ m->titlebarend=x;
++ m->titlebarend=x;
                  drw_text(drw, x, 0, w, bh, stext, 0);
          }
 - else
_AT_@ -125,72 +124,72 @@ index f896170..cc2a4f2 100644
 - drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating, 0);
 - }
 - else {
-+ m->titlebarbegin=x;
-+ }
-+ for(c = m->clients; c && !ISVISIBLE(c); c = c->next);
-+ firstvis = c;
++ m->titlebarbegin=x;
++ }
++ for(c = m->clients; c && !ISVISIBLE(c); c = c->next);
++ firstvis = c;
 +
-+ drw_setscheme(drw, m == selmon ? &scheme[SchemeSel] : &scheme[SchemeNorm]);
-+ w = x - xx;
-+ x = xx;
++ drw_setscheme(drw, m == selmon ? &scheme[SchemeSel] : &scheme[SchemeNorm]);
++ w = x - xx;
++ x = xx;
 +
-+ if(n > 0) {
-+ mw = w / n;
-+ extra = 0;
-+ i = 0;
++ if(n > 0) {
++ mw = w / n;
++ extra = 0;
++ 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);
-+ }
++ 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);
++ }
 +
-+ if(i > 0) mw += extra / i;
++ if(i > 0) mw += extra / i;
 +
-+ c = firstvis;
-+ xx = x;
-+ }
-+ m->titlebarbegin=x;
-+ while(w > bh) {
-+ if(c) {
-+ ow = w;
-+ tw = TEXTW(c->name);
-+ w = MIN(ow, tw);
++ c = firstvis;
++ xx = x;
++ }
++ m->titlebarbegin=x;
++ while(w > bh) {
++ if(c) {
++ ow = w;
++ tw = TEXTW(c->name);
++ w = MIN(ow, tw);
 +
-+ if(w > mw) w = mw;
-+ if(c == lastvis) w = ow;
++ if(w > mw) w = mw;
++ if(c == lastvis) w = ow;
 +
-+ drw_text(drw, x, 0, w, bh, c->name, False);
-+ if(c != firstvis) drawline(x, 0);
-+ drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating, True);
++ drw_text(drw, x, 0, w, bh, c->name, False);
++ if(c != firstvis) drawline(x, 0);
++ drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating, True);
 +
-+ x += w;
-+ w = ow - w;
-+ for(c = c->next; c && !ISVISIBLE(c); c = c->next);
++ x += w;
++ w = ow - w;
++ for(c = c->next; c && !ISVISIBLE(c); c = c->next);
 + } else {
                          drw_setscheme(drw, &scheme[SchemeNorm]);
                          drw_text(drw, x, 0, w, bh, NULL, 0);
-+ break;
++ break;
                  }
          }
 +
-+ if(m == selmon && m->sel && ISVISIBLE(m->sel)) {
-+ drw_text(drw, x, 0, w, bh, m->sel->name, True);
-+ drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating, True);
-+ }
++ if(m == selmon && m->sel && ISVISIBLE(m->sel)) {
++ drw_text(drw, x, 0, w, bh, m->sel->name, True);
++ drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating, True);
++ }
 +
          drw_map(drw, m->barwin, 0, 0, m->ww, bh);
  }
  
  void
 +drawline(int x, int y) {
-+ XGCValues gcv;
++ XGCValues gcv;
 +
-+ gcv.foreground = drw->scheme->fg->rgb;
++ gcv.foreground = drw->scheme->fg->rgb;
 +
-+ XChangeGC(dpy, drw->gc, GCForeground, &gcv);
-+ XDrawLine(dpy, drw->drawable, drw->gc, x, y, x, y + (drw->font->ascent + drw->font->descent + 2));
++ XChangeGC(dpy, drw->gc, GCForeground, &gcv);
++ XDrawLine(dpy, drw->drawable, drw->gc, x, y, x, y + (drw->font->ascent + drw->font->descent + 2));
 +}
 +
 +void
_AT_@ -202,47 +201,47 @@ index f896170..cc2a4f2 100644
  
  void
 +focusonclick(const Arg *arg) {
-+ int x, w, mw = 0, tw, n = 0, i = 0, extra = 0;
-+ Monitor *m = selmon;
-+ Client *c, *firstvis;
++ int x, w, mw = 0, tw, n = 0, i = 0, extra = 0;
++ Monitor *m = selmon;
++ Client *c, *firstvis;
 +
-+ for(c = m->clients; c && !ISVISIBLE(c); c = c->next);
-+ firstvis = c;
++ for(c = m->clients; c && !ISVISIBLE(c); c = c->next);
++ firstvis = c;
 +
-+ for(c = m->clients; c; c = c->next)
-+ if (ISVISIBLE(c))
-+ n++;
++ for(c = m->clients; c; c = c->next)
++ if (ISVISIBLE(c))
++ n++;
 +
-+ if(n > 0) {
-+ mw = (m->titlebarend - m->titlebarbegin) / n;
-+ c = firstvis;
-+ while(c) {
-+ tw = TEXTW(c->name);
-+ if(tw < mw) extra += (mw - tw); else i++;
-+ for(c = c->next; c && !ISVISIBLE(c); c = c->next);
-+ }
-+ if(i > 0) mw += extra / i;
-+ }
++ if(n > 0) {
++ mw = (m->titlebarend - m->titlebarbegin) / n;
++ c = firstvis;
++ while(c) {
++ tw = TEXTW(c->name);
++ if(tw < mw) extra += (mw - tw); else i++;
++ for(c = c->next; c && !ISVISIBLE(c); c = c->next);
++ }
++ if(i > 0) mw += extra / i;
++ }
 +
-+ x=m->titlebarbegin;
++ x=m->titlebarbegin;
 +
-+ c = firstvis;
-+ while(x < m->titlebarend) {
-+ if(c) {
-+ w=MIN(TEXTW(c->name), mw);
-+ if (x < arg->i && x+w > arg->i) {
-+ focus(c);
-+ restack(selmon);
-+ break;
-+ } else {
-+ x+=w;
-+ }
++ c = firstvis;
++ while(x < m->titlebarend) {
++ if(c) {
++ w=MIN(TEXTW(c->name), mw);
++ if (x < arg->i && x+w > arg->i) {
++ focus(c);
++ restack(selmon);
++ break;
++ } else {
++ x+=w;
++ }
 +
-+ for(c = c->next; c && !ISVISIBLE(c); c = c->next);
-+ } else {
-+ break;
-+ }
-+ }
++ for(c = c->next; c && !ISVISIBLE(c); c = c->next);
++ } else {
++ break;
++ }
++ }
 +}
 +
 +void
_AT_@ -255,7 +254,7 @@ index f896170..cc2a4f2 100644
                          updatetitle(c);
 - if(c == c->mon->sel)
 - drawbar(c->mon);
-+ drawbar(c->mon);
++ drawbar(c->mon);
                  }
                  if(ev->atom == netatom[NetWMWindowType])
                          updatewindowtype(c);
Received on Sat Sep 26 2015 - 16:47:42 CEST

This archive was generated by hypermail 2.3.0 : Sat Sep 26 2015 - 16:48:10 CEST