wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 2ddd734ab030ce3a38a623efb02c785e73da004d
parent 4f951ec859d71bf0695957be7b8ea39f3db710d8
Author: Kris Maglione <jg@suckless.org>
Date:   Sun, 11 Feb 2007 00:11:10 -0500

Color drag boxes based on urgency and provide events in /client/n/ctl (Urgent, NotUrgent) to toggle it


Diffstat:
client.c | 57+++++++++++++++++++++++++++++++++++++++++++++------------
frame.c | 2++
2 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/client.c b/client.c @@ -250,6 +250,41 @@ kill_client(Client * c) { XKillClient(blz.dpy, c->win); } +static void +set_urgent(Client *c, Bool urgent, Bool write) { + XWMHints *wmh; + char *cwrite; + + if(write) + cwrite = "Client"; + else + cwrite = "Manager"; + + if(urgent != c->urgent) { + if(urgent) + write_event("Urgent 0x%x %s\n", client->win, cwrite); + else + write_event("NotUrgent 0x%x %s\n", client->win, cwrite); + c->urgent = urgent; + if(c->sel && c->sel->view == screen->sel) { + update_frame_widget_colors(c->sel); + draw_frame(c->sel); + } + } + + if(write) { + wmh = XGetWMHints(blz.dpy, c->win); + if(!wmh) + return; + if(urgent) + wmh->flags |= XUrgencyHint; + else + wmh->flags &= ~XUrgencyHint; + XSetWMHints(blz.dpy, c->win, wmh); + XFree(wmh); + } +} + void prop_client(Client *c, XPropertyEvent *e) { XWMHints *wmh; @@ -276,14 +311,8 @@ prop_client(Client *c, XPropertyEvent *e) { break; case XA_WM_HINTS: wmh = XGetWMHints(blz.dpy, c->win); - if(wmh->flags&XUrgencyHint && !client->urgent) { - write_event("Urgent 0x%x\n", client->win); - client->urgent = True; - } - else if(!(wmh->flags&XUrgencyHint) && client->urgent) { - write_event("NotUrgent 0x%x\n", client->win); - client->urgent = False; - } + set_urgent(c, (wmh->flags & XUrgencyHint), False); + XFree(wmh); break; } if(e->atom == XA_WM_NAME || e->atom == net_atom[NetWMName]) { @@ -713,9 +742,13 @@ apply_rules(Client *c) { char * message_client(Client *c, char *message) { - if(!strncmp(message, "kill", 5)) { + if(!strncmp(message, "kill", 5)) kill_client(c); - return nil; - } - return Ebadcmd; + if(!strncmp(message, "Urgent", 7)) + set_urgent(c, True, True); + if(!strncmp(message, "NotUrgent", 10)) + set_urgent(c, False, True); + else + return Ebadcmd; + return nil; } diff --git a/frame.c b/frame.c @@ -206,6 +206,8 @@ update_frame_widget_colors(Frame *f) { } else f->grabbox.color = f->tile.color = f->titlebar.color = def.normcolor; + if(f->client->urgent) + f->grabbox.color.bg = f->grabbox.color.fg; } void