diff --git a/client.c b/client.c index 094fca0f..45697fe8 100644 --- a/client.c +++ b/client.c @@ -110,6 +110,36 @@ window_hasproto(xcb_window_t win, xcb_atom_t atom) return ret; } +/** Change the clients urgency flag. + * \param c The client + * \param urgent The new flag state + */ +void +client_seturgent(client_t *c, bool urgent) +{ + if(c->isurgent != urgent) + { + xcb_get_property_cookie_t hints = + xcb_get_wm_hints_unchecked(globalconf.connection, c->win); + + c->isurgent = urgent; + ewmh_client_update_hints(c); + + /* update ICCCM hints */ + xcb_wm_hints_t wmh; + xcb_get_wm_hints_reply(globalconf.connection, hints, &wmh, NULL); + + if(urgent) + wmh.flags |= XCB_WM_HINT_X_URGENCY; + else + wmh.flags &= ~XCB_WM_HINT_X_URGENCY; + + xcb_set_wm_hints(globalconf.connection, c->win, &wmh); + + hooks_property(c, "urgent"); + } +} + /** Returns true if a client is tagged * with one of the tags of the specified screen. * \param c The client to check. @@ -296,6 +326,9 @@ client_focus(client_t *c) luaA_dofunction(globalconf.L, globalconf.hooks.focus, 1, 0); } + /* according to EWMH, we have to remove the urgent state from a client */ + client_seturgent(c, false); + ewmh_update_net_active_window(c->phys_screen); } diff --git a/client.h b/client.h index 657c4e11..780bff24 100644 --- a/client.h +++ b/client.h @@ -66,6 +66,7 @@ void client_setmaxhoriz(client_t *, bool); void client_setmaxvert(client_t *, bool); void client_setminimized(client_t *, bool); void client_setborder(client_t *, int); +void client_seturgent(client_t *, bool); void client_focus(client_t *); int luaA_client_newindex(lua_State *); diff --git a/ewmh.c b/ewmh.c index e00c46ca..81dd8e14 100644 --- a/ewmh.c +++ b/ewmh.c @@ -347,14 +347,11 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) else if(state == _NET_WM_STATE_DEMANDS_ATTENTION) { if(set == _NET_WM_STATE_REMOVE) - c->isurgent = false; + client_seturgent(c, false); else if(set == _NET_WM_STATE_ADD) - c->isurgent = true; + client_seturgent(c, true); else if(set == _NET_WM_STATE_TOGGLE) - c->isurgent = !c->isurgent; - - /* execute hook */ - hooks_property(c, "urgent"); + client_seturgent(c, !c->isurgent); } } diff --git a/property.c b/property.c index b3002ed7..bf08c288 100644 --- a/property.c +++ b/property.c @@ -172,12 +172,7 @@ property_update_wm_hints(client_t *c, xcb_get_property_reply_t *reply) } bool isurgent = xcb_wm_hints_get_urgency(&wmh); - if(isurgent != c->isurgent) - { - c->isurgent = isurgent; - /* execute hook */ - hooks_property(c, "urgent"); - } + client_seturgent(c, isurgent); if(wmh.flags & XCB_WM_HINT_STATE && wmh.initial_state == XCB_WM_STATE_WITHDRAWN) client_setborder(c, 0);