[hackers] [dwm] added client number printing right of layout symbol || Anselm R Garbe

From: <hg_AT_suckless.org>
Date: Thu, 9 Jul 2009 18:59:02 +0000 (UTC)

changeset: 1455:d71d573c3165
tag: tip
user: Anselm R Garbe <anselm_AT_garbe.us>
date: Thu Jul 09 19:58:58 2009 +0100
files: dwm.c
description:
added client number printing right of layout symbol

diff -r b55c7bd92fda -r d71d573c3165 dwm.c
--- a/dwm.c Thu Jul 09 11:29:01 2009 +0100
+++ b/dwm.c Thu Jul 09 19:58:58 2009 +0100
@@ -236,7 +236,7 @@
 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 */
@@ -641,11 +641,13 @@
 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;
@@ -662,10 +664,12 @@
         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;
Received on Thu Jul 09 2009 - 18:59:02 UTC

This archive was generated by hypermail 2.2.0 : Thu Jul 09 2009 - 19:00:06 UTC