From a6aa4edbd7cdf1199d3b35aa638ab6985cb71b62 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Thu, 26 Jan 2012 02:58:19 +0100 Subject: [PATCH] Add urgent tag support, tags_urgent/fg/bg/statusline in conf --- src/client.c | 2 +- src/client.h | 1 + src/config.c | 5 +++++ src/event.c | 23 ++++++++++++++--------- src/infobar.c | 8 ++++++++ src/tag.c | 3 +++ src/tag.h | 2 -- src/wmfs.h | 5 +++-- wmfsrc | 4 ++++ 9 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/client.c b/src/client.c index 669e091..5ec51d9 100644 --- a/src/client.c +++ b/src/client.c @@ -668,7 +668,7 @@ uicb_client_close(Uicb cmd) client_close(W->client); } -static void +void client_get_sizeh(struct client *c) { long msize; diff --git a/src/client.h b/src/client.h index 33b551a..9401f5d 100644 --- a/src/client.h +++ b/src/client.h @@ -32,6 +32,7 @@ void client_get_name(struct client *c); void client_close(struct client *c); void uicb_client_close(Uicb cmd); struct client *client_new(Window w, XWindowAttributes *wa, bool scan); +void client_get_sizeh(struct client *c); bool client_winsize(struct client *c, struct geo *geo); bool client_moveresize(struct client *c, struct geo *g); void client_maximize(struct client *c); diff --git a/src/config.c b/src/config.c index f5b7c27..5b6381c 100644 --- a/src/config.c +++ b/src/config.c @@ -78,6 +78,8 @@ config_theme(void) t->tags_s.bg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "tags_sel_bg").str); t->tags_o.fg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "tags_occupied_fg").str); t->tags_o.bg = color_atoh(fetch_opt_first(ks[i], "#444444", "tags_occupied_bg").str); + t->tags_u.fg = color_atoh(fetch_opt_first(ks[i], "#444444", "tags_urgent_fg").str); + t->tags_u.bg = color_atoh(fetch_opt_first(ks[i], "#CC4444", "tags_urgent_bg").str); t->tags_border_col = color_atoh(fetch_opt_first(ks[i], "#888888", "tags_border_color").str); t->tags_border_width = fetch_opt_first(ks[i], "0", "tags_border_width").num; @@ -86,6 +88,7 @@ config_theme(void) t->tags_n_sl = status_new_ctx(NULL, t); t->tags_s_sl = status_new_ctx(NULL, t); t->tags_o_sl = status_new_ctx(NULL, t); + t->tags_u_sl = status_new_ctx(NULL, t); if((t->tags_n_sl.status = xstrdup(fetch_opt_first(ks[i], "", "tags_normal_statusline").str))) status_parse(&t->tags_n_sl); @@ -93,6 +96,8 @@ config_theme(void) status_parse(&t->tags_s_sl); if((t->tags_o_sl.status = xstrdup(fetch_opt_first(ks[i], "", "tags_occupied_statusline").str))) status_parse(&t->tags_o_sl); + if((t->tags_u_sl.status = xstrdup(fetch_opt_first(ks[i], "", "tags_urgent_statusline").str))) + status_parse(&t->tags_u_sl); /* Client / frame */ t->client_n.fg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "client_normal_fg").str); diff --git a/src/event.c b/src/event.c index 4df06be..e98d73d 100644 --- a/src/event.c +++ b/src/event.c @@ -11,6 +11,7 @@ #include "barwin.h" #include "screen.h" #include "systray.h" +#include "infobar.h" #define EVDPY(e) (e)->xany.display @@ -214,6 +215,7 @@ static void event_propertynotify(XEvent *e) { XPropertyEvent *ev = &e->xproperty; + XWMHints *h; struct client *c; struct _systray *s; @@ -226,20 +228,23 @@ event_propertynotify(XEvent *e) { case XA_WM_TRANSIENT_FOR: break; - case XA_WM_NORMAL_HINTS: - /* client_get_size_hints(c); */ - break; - case XA_WM_HINTS: - /* - XWMHints *h; - if((h = XGetWMHints(EVDPY, c->win)) && (h->flags & XUrgencyHint) && c != sel) + case XA_WM_NORMAL_HINTS: + client_get_sizeh(c); + break; + + case XA_WM_HINTS: + if((h = XGetWMHints(EVDPY(e), c->win)) + && (h->flags & XUrgencyHint) + && c->tag != W->screen->seltag) { - client_urgent(c, True); + c->tag->flags |= TAG_URGENT; + infobar_elem_screen_update(c->screen, ElemTag); XFree(h); } - */ + break; + default: if(ev->atom == XA_WM_NAME || ev->atom == W->net_atom[net_wm_name]) client_get_name(c); diff --git a/src/infobar.c b/src/infobar.c index 049d5e4..8389eb1 100644 --- a/src/infobar.c +++ b/src/infobar.c @@ -110,12 +110,20 @@ infobar_elem_tag_update(struct element *e) } else { + /* Normal tag */ if(SLIST_EMPTY(&t->clients)) { b->fg = e->infobar->theme->tags_n.fg; b->bg = e->infobar->theme->tags_n.bg; e->statusctx = &e->infobar->theme->tags_n_sl; } + /* Urgent tag */ + else if(t->flags & TAG_URGENT) + { + b->fg = e->infobar->theme->tags_u.fg; + b->bg = e->infobar->theme->tags_u.bg; + e->statusctx = &e->infobar->theme->tags_u_sl; + } /* Occupied tag */ else { diff --git a/src/tag.c b/src/tag.c index 193d3f1..8f86433 100644 --- a/src/tag.c +++ b/src/tag.c @@ -56,6 +56,9 @@ tag_screen(struct screen *s, struct tag *t) if(!SLIST_EMPTY(&t->clients) && !(W->flags & WMFS_SCAN)) client_focus( client_tab_next(t->sel)); + if(t->flags & TAG_URGENT) + t->flags ^= TAG_URGENT; + infobar_elem_screen_update(s, ElemTag); ewmh_update_wmfs_props(); diff --git a/src/tag.h b/src/tag.h index 1e316f5..c7f604d 100644 --- a/src/tag.h +++ b/src/tag.h @@ -8,7 +8,6 @@ #include "wmfs.h" - static inline struct tag* tag_gb_id(struct screen *s, int id) { @@ -34,5 +33,4 @@ void uicb_tag_move_client_next(Uicb cmd); void uicb_tag_move_client_prev(Uicb cmd); void uicb_tag_click(Uicb cmd); - #endif /* TAG_H */ diff --git a/src/wmfs.h b/src/wmfs.h index 5c8ed9b..a8ffd3a 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -165,6 +165,7 @@ struct tag struct tag *prev; char *name; int id; +#define TAG_URGENT 0x01 Flags flags; SLIST_HEAD(, client) clients; TAILQ_HEAD(ssub, layout_set) sets; @@ -245,8 +246,8 @@ struct theme int bars_width; /* struct elements */ - struct colpair tags_n, tags_s, tags_o; /* normal / selected / occupied */ - struct status_ctx tags_n_sl, tags_s_sl, tags_o_sl; /* status line */ + struct colpair tags_n, tags_s, tags_o, tags_u; /* normal / selected / occupied */ + struct status_ctx tags_n_sl, tags_s_sl, tags_o_sl, tags_u_sl; /* status line */ int tags_border_width; Color tags_border_col; diff --git a/wmfsrc b/wmfsrc index 282dd45..d60f42f 100644 --- a/wmfsrc +++ b/wmfsrc @@ -32,6 +32,10 @@ tags_occupied_bg = "#445544" tags_occupied_statusline = "\R[0;0;3;3;#AABBAA]" + tags_urgent_fg = "#223322" + tags_urgent_bg = "#CC5544" + # tags_urgent_statusline = "" + tags_border_color = "#112211" tags_border_width = 1