On Thu, Dec 4, 2008 at 11:19 PM, yy <[EMAIL PROTECTED]> wrote:
> 2008/12/4 Tinou <[EMAIL PROTECTED]>:
>> On Thu, Dec 4, 2008 at 9:31 PM, yy <[EMAIL PROTECTED]> wrote:
>> Besides the border color, I think this patch is really useful when using
>> the monocle layout. As clearing the urgent flag one could miss that not
>> visible urgent window. Though it's only visible viewing another tag...
>
> Not really. Maybe I didn't explain myself very well in my last mail,
> but although you remove the border color from the patch I submitted
> you will still be able to see it in the status bar. In fact, no code
> needs to be added to current dwm to do this, since what it does is
> invert the color. Leaving the flag set until the window is focused is
> everything you need.
> Of course, the inverted color in the tag label doesn't give you so
> much information as your taskbar idea (which looks nice), but is
> probably more than enough for the common use case.
>
>
> --
>
>
> - yiyus || JGL .
>
>


Reading your mail, I thought I misread the code, but I just tested with
the new 5.3: urgent flag is cleared once the tag is viewed (being viewed
or switched to) even in monocle when the urgent window isn't visible.

Since I'm having trouble falling asleep, here's a (maybe too big :-S)
patch that adds border color, as you sent, and taskbar, as I promised
:-)

Regards,

-- 
Tinou
diff -Naur dwm-5.3/config.def.h 5.3-taskbar/config.def.h
--- dwm-5.3/config.def.h        2008-12-04 21:22:37.000000000 +0100
+++ 5.3-taskbar/config.def.h    2008-12-05 02:29:24.000000000 +0100
@@ -8,6 +8,7 @@
 static const char selbordercolor[]  = "#0066ff";
 static const char selbgcolor[]      = "#0066ff";
 static const char selfgcolor[]      = "#ffffff";
+static const char urgentbordercolor[]      = "#ff0000";
 static unsigned int borderpx        = 1;        /* border pixel of windows */
 static unsigned int snap            = 32;       /* snap pixel */
 static Bool showbar                 = True;     /* False means no bar */
diff -Naur dwm-5.3/dwm.c 5.3-taskbar/dwm.c
--- dwm-5.3/dwm.c       2008-12-04 21:22:37.000000000 +0100
+++ 5.3-taskbar/dwm.c   2008-12-05 02:36:32.000000000 +0100
@@ -138,7 +138,7 @@
 static void buttonpress(XEvent *e);
 static void checkotherwm(void);
 static void cleanup(void);
-static void clearurgent(void);
+static void clearurgent(Client *c);
 static void configure(Client *c);
 static void configurenotify(XEvent *e);
 static void configurerequest(XEvent *e);
@@ -214,6 +214,7 @@
 static unsigned int seltags = 0, sellt = 0;
 static int (*xerrorxlib)(Display *, XErrorEvent *);
 static unsigned int numlockmask = 0;
+static unsigned long urgentcolor;
 static void (*handler[LASTEvent]) (XEvent *) = {
        [ButtonPress] = buttonpress,
        [ConfigureRequest] = configurerequest,
@@ -366,20 +367,16 @@
 }
 
 void
-clearurgent(void) {
+clearurgent(Client *c) {
        XWMHints *wmh;
-       Client *c;
-
-       for(c = clients; c; c = c->next)
-               if(ISVISIBLE(c) && c->isurgent) {
-                       c->isurgent = False;
-                       if (!(wmh = XGetWMHints(dpy, c->win)))
-                               continue;
-
-                       wmh->flags &= ~XUrgencyHint;
-                       XSetWMHints(dpy, c->win, wmh);
-                       XFree(wmh);
-               }
+       if(c && c->isurgent) {
+               c->isurgent = False;
+               if (!(wmh = XGetWMHints(dpy, c->win)))
+                       return;
+               wmh->flags &= ~XUrgencyHint;
+               XSetWMHints(dpy, c->win, wmh);
+               XFree(wmh);
+       }
 }
 
 void
@@ -493,7 +490,7 @@
 
 void
 drawbar(void) {
-       int x;
+       int x, ntaskbarclients = 0;
        unsigned int i, occ = 0, urg = 0;
        unsigned long *col;
        Client *c;
@@ -526,7 +523,29 @@
                dc.w = ww - x;
        }
        drawtext(stext, dc.norm, False);
-       if((dc.w = dc.x - x) > bh) {
+       if (lt[sellt]->arrange == monocle && !(sel && sel->isfloating))
+       {
+               for(c = clients; c; c = c->next)
+                       if(ISVISIBLE(c) && !c->isfloating)
+                               ntaskbarclients++;
+               if((dc.w = ntaskbarclients > 0 ? (dc.x - x) / ntaskbarclients : 
dc.x - x) > bh) {
+                       dc.x = x;
+                       if (lt[sellt]->arrange == monocle)
+                       {
+                               if(sel)
+                                       for(c = clients; c; c = c->next) {
+                                               if(ISVISIBLE(c) && 
!c->isfloating) {
+                                                       drawtext(c->name, c == 
sel ? dc.sel : dc.norm, c->isurgent);
+                                                       drawsquare(c->isfixed, 
c->isfloating, c->isurgent, c == sel ? dc.sel : dc.norm);
+                                                       dc.x += dc.w;
+                                               }
+                                       }
+                       }
+               }
+               if(ntaskbarclients == 0)
+                       drawtext(NULL, dc.norm, False);
+       }
+       else if((dc.w = dc.x - x) > bh) {
                dc.x = x;
                if(sel) {
                        drawtext(sel->name, dc.sel, False);
@@ -618,6 +637,7 @@
                XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
        }
        if(c) {
+               clearurgent(c);
                detachstack(c);
                attachstack(c);
                grabbuttons(c, True);
@@ -1339,6 +1359,7 @@
        dc.sel[ColBorder] = getcolor(selbordercolor);
        dc.sel[ColBG] = getcolor(selbgcolor);
        dc.sel[ColFG] = getcolor(selfgcolor);
+       urgentcolor = getcolor(urgentbordercolor);
        dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, 
DefaultDepth(dpy, screen));
        dc.gc = XCreateGC(dpy, root, 0, 0);
        XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
@@ -1503,7 +1524,6 @@
 
        if(mask) {
                tagset[seltags] = mask;
-               clearurgent();
                arrange();
        }
 }
@@ -1658,13 +1678,17 @@
        XWMHints *wmh;
 
        if((wmh = XGetWMHints(dpy, c->win))) {
-               if(ISVISIBLE(c) && wmh->flags & XUrgencyHint) {
+               if(ISVISIBLE(c) && !(lt[sellt]->arrange == monocle && 
!c->isfloating && c != sel) && wmh->flags & XUrgencyHint) {
+
                        wmh->flags &= ~XUrgencyHint;
                        XSetWMHints(dpy, c->win, wmh);
                }
                else
                        c->isurgent = (wmh->flags & XUrgencyHint) ? True : 
False;
 
+               c->isurgent = (c != sel && wmh->flags & XUrgencyHint) ? True : 
False;
+               if(c->isurgent)
+                       XSetWindowBorder(dpy, c->win, urgentcolor);
                XFree(wmh);
        }
 }
@@ -1676,7 +1700,6 @@
        seltags ^= 1; /* toggle sel tagset */
        if(arg->ui & TAGMASK)
                tagset[seltags] = arg->ui & TAGMASK;
-       clearurgent();
        arrange();
 }
 

Reply via email to