Hi, I've written a patch for ticket #719 [1]. At this point this is more or less just a prototype to see if this feature is usefull or not. So please let me know if this is a sane approach for this and what needs to be done to get accepted.
greetings, Sascha Kruse [1] http://bugs.i3wm.org/report/ticket/719
>From 47292b73d755b22a3d103fedf67ecf609db05d29 Mon Sep 17 00:00:00 2001 From: Sascha Kruse <[email protected]> Date: Sat, 18 Aug 2012 13:58:22 +0200 Subject: [PATCH] Make parents of urgent container also urgent --- include/con.h | 6 ++++++ src/con.c | 20 ++++++++++++++++++++ src/x.c | 11 +++++++++++ 3 files changed, 37 insertions(+) diff --git a/include/con.h b/include/con.h index b14c477..7f00986 100644 --- a/include/con.h +++ b/include/con.h @@ -86,6 +86,12 @@ Con *con_inside_floating(Con *con); bool con_inside_focused(Con *con); /** + * Checks if the given container has a urgent child. + * + */ +bool con_has_urgent_child(Con *con); + +/** * Returns the container with the given client window ID or NULL if no such * container exists. * diff --git a/src/con.c b/src/con.c index c24a379..355b1a3 100644 --- a/src/con.c +++ b/src/con.c @@ -1132,3 +1132,23 @@ Rect con_minimum_size(Con *con) { con->type, con->layout, con->orientation); assert(false); } + +/* + * Checks if the given container has a urgent child. + * + */ + +bool con_has_urgent_child(Con *con) { + Con *child; + + if (con_is_leaf(con)) + return con->urgent; + + TAILQ_FOREACH(child, &(con->nodes_head), nodes) { + if (con_has_urgent_child(child)) { + return true; + } + } + + return false; +} diff --git a/src/x.c b/src/x.c index 08eb8fe..590b2f4 100644 --- a/src/x.c +++ b/src/x.c @@ -325,6 +325,16 @@ void x_draw_decoration(Con *con) { /* 1: build deco_params and compare with cache */ struct deco_render_params *p = scalloc(sizeof(struct deco_render_params)); + /* set urgent flag if container has urgent children */ + bool urgency_changed = false; + if (!con_is_leaf(con)) { + bool has_urgent_child = con_has_urgent_child(con); + if (has_urgent_child != con->urgent) { + con->urgent = has_urgent_child; + urgency_changed = true; + } + } + /* find out which colors to use */ if (con->urgent) p->color = &config.client.urgent; @@ -349,6 +359,7 @@ void x_draw_decoration(Con *con) { (con->window == NULL || !con->window->name_x_changed) && !parent->pixmap_recreated && !con->pixmap_recreated && + !urgency_changed && memcmp(p, con->deco_render_params, sizeof(struct deco_render_params)) == 0) { free(p); goto copy_pixmaps; -- 1.7.11.5
