X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=d71bb58b92b1cf6c75638a417145c523b399d363;hp=d448f5b472b794e9ab4e39d8efca723b46a7be99;hb=87526be6f05ed892083d874c27f18b6c9e21881e;hpb=3e6fe6b541bcc553e2e104a8117008af02a8c760 diff --git a/dwm.c b/dwm.c index d448f5b..d71bb58 100644 --- a/dwm.c +++ b/dwm.c @@ -66,7 +66,7 @@ typedef union { int i; unsigned int ui; float f; - void *v; + const void *v; } Arg; typedef struct { @@ -123,7 +123,7 @@ typedef struct { struct Monitor { int screen_number; float mfact; - int by, btx; /* bar geometry */ + int by; /* bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ unsigned int seltags; @@ -136,7 +136,7 @@ struct Monitor { Client *stack; Monitor *next; Window barwin; - Layout *lt[2]; + const Layout *lt[2]; }; typedef struct { @@ -236,7 +236,7 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); /* variables */ -static char stext[256]; +static char stext[256], ntext[8]; static int screen; static int sw, sh; /* X display screen geometry x, y, width, height */ static int bh, blw = 0; /* bar geometry */ @@ -275,7 +275,7 @@ struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 void applyrules(Client *c) { unsigned int i; - Rule *r; + const Rule *r; XClassHint ch = { 0 }; /* rule matching */ @@ -409,9 +409,8 @@ buttonpress(XEvent *e) { selmon = m; focus(NULL); } - if(ev->window == selmon->barwin && ev->x >= selmon->btx) { - i = 0; - x = selmon->btx; + if(ev->window == selmon->barwin) { + i = x = 0; do x += TEXTW(tags[i]); while(ev->x >= x && ++i < LENGTH(tags)); @@ -642,22 +641,18 @@ dirtomon(int dir) { void drawbar(Monitor *m) { int x; - unsigned int i, occ = 0, urg = 0; + unsigned int i, n = 0, occ = 0, urg = 0; unsigned long *col; Client *c; for(c = m->clients; c; c = c->next) { + if(ISVISIBLE(c)) + n++; occ |= c->tags; if(c->isurgent) urg |= c->tags; } dc.x = 0; - if(mons->next) { /* more than a single monitor */ - dc.w = TEXTW(monsyms[m->screen_number]); - drawtext(monsyms[m->screen_number], selmon == m ? dc.sel : dc.norm, False); - dc.x += dc.w; - } - m->btx = dc.x; for(i = 0; i < LENGTH(tags); i++) { dc.w = TEXTW(tags[i]); col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm; @@ -669,10 +664,12 @@ drawbar(Monitor *m) { if(blw > 0) { dc.w = blw; drawtext(m->lt[m->sellt]->symbol, dc.norm, False); - x = dc.x + dc.w; + dc.x += dc.w; } - else - x = dc.x; + snprintf(ntext, sizeof ntext, "%u", n); + dc.w = TEXTW(ntext); + drawtext(ntext, dc.norm, False); + x = (dc.x += dc.w); if(m == selmon) { /* status is only drawn on selected monitor */ dc.w = TEXTW(stext); dc.x = m->ww - dc.w; @@ -1726,8 +1723,8 @@ updategeom(void) { m->sellt = 0; m->tagset[0] = m->tagset[1] = 1; m->mfact = mfact; - m->showbar = SHOWBAR; - m->topbar = TOPBAR; + m->showbar = showbar; + m->topbar = topbar; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; updatebarpos(m);