diff --git a/ewmh.c b/ewmh.c index e2e1ccf3..9d6411b7 100755 --- a/ewmh.c +++ b/ewmh.c @@ -346,12 +346,18 @@ 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) - client_set_urgent(L, -1, false); - else if(set == _NET_WM_STATE_ADD) - client_set_urgent(L, -1, true); - else if(set == _NET_WM_STATE_TOGGLE) - client_set_urgent(L, -1, !c->urgent); + if(set == _NET_WM_STATE_REMOVE) { + lua_pushboolean(L, false); + luaA_object_emit_signal(L, -2, "request::urgent", 1); + } + else if(set == _NET_WM_STATE_ADD) { + lua_pushboolean(L, true); + luaA_object_emit_signal(L, -2, "request::urgent", 1); + } + else if(set == _NET_WM_STATE_TOGGLE) { + lua_pushboolean(L, !c->urgent); + luaA_object_emit_signal(L, -2, "request::urgent", 1); + } } lua_pop(L, 1); diff --git a/lib/awful/ewmh.lua.in b/lib/awful/ewmh.lua.in index a347995c..d3dd608c 100644 --- a/lib/awful/ewmh.lua.in +++ b/lib/awful/ewmh.lua.in @@ -10,6 +10,7 @@ local screen = screen local ipairs = ipairs local math = math local atag = require("awful.tag") +local aclient = require("awful.client") --- Implements EWMH requests handling. -- awful.ewmh @@ -158,8 +159,15 @@ function ewmh.tag(c, t) end end +function ewmh.urgent(c, urgent) + if c ~= client.focus and not aclient.property.get(c,"ignore_urgent") then + c.urgent = urgent + end +end + client.connect_signal("request::activate", ewmh.activate) client.connect_signal("request::tag", ewmh.tag) +client.connect_signal("request::urgent", ewmh.urgent) client.connect_signal("request::maximized_horizontal", maximized_horizontal) client.connect_signal("request::maximized_vertical", maximized_vertical) client.connect_signal("request::fullscreen", fullscreen) diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in index eee7c233..b1ddca30 100644 --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -632,7 +632,40 @@ capi.client.connect_signal("manage", function(c) c:connect_signal("property::screen", tag.withcurrent) end) +-- Keep track of the number of urgent clients. +local function update_urgent(c,t) + local modif = c.urgent == true and 1 or -1 + local count = tag.getproperty(t,"urgent_count") or 0 + count = (count + modif) >= 0 and (count + modif) or 0 + tag.setproperty(t,"urgent" , count > 0) + tag.setproperty(t,"urgent_count", count ) +end + +-- Update the urgent counter when a client is tagged. +local function client_tagged(c,t) + if c.urgent then + update_urgent(c,t) + end +end + +-- Update the urgent counter when a client is untagged. +local function client_untagged(c,t) + if c.urgent then + update_urgent(c,t) + end +end + +-- Count the urgent clients. +local function urgent_callback(c) + for k,t in ipairs(c:tags()) do + update_urgent(c,t) + end +end + +capi.client.connect_signal("property::urgent", urgent_callback) capi.client.connect_signal("manage", tag.withcurrent) +capi.client.connect_signal("untagged", client_untagged) +capi.client.connect_signal("tagged", client_tagged) capi.tag.connect_signal("request::select", tag.viewonly) capi.tag.add_signal("property::hide") @@ -644,6 +677,8 @@ capi.tag.add_signal("property::nmaster") capi.tag.add_signal("property::windowfact") capi.tag.add_signal("property::screen") capi.tag.add_signal("property::index") +capi.tag.add_signal("property::urgent") +capi.tag.add_signal("property::urgent_count") capi.screen.add_signal("tag::history::update") for s = 1, capi.screen.count() do diff --git a/lib/awful/widget/taglist.lua.in b/lib/awful/widget/taglist.lua.in index 35ae36dd..be783268 100644 --- a/lib/awful/widget/taglist.lua.in +++ b/lib/awful/widget/taglist.lua.in @@ -85,12 +85,9 @@ function taglist.taglist_label(t, args) if bg_empty then bg_color = bg_empty end if fg_empty then fg_color = fg_empty end end - for k, c in pairs(cls) do - if c.urgent then - if bg_urgent then bg_color = bg_urgent end - if fg_urgent then fg_color = fg_urgent end - break - end + if tag.getproperty(t, "urgent") then + if bg_urgent then bg_color = bg_urgent end + if fg_urgent then fg_color = fg_urgent end end end if t.selected then @@ -176,7 +173,7 @@ function taglist.new(screen, filter, buttons, style, update_function, base_widge tag.attached_connect_signal(screen, "property::activated", ut) tag.attached_connect_signal(screen, "property::screen", ut) tag.attached_connect_signal(screen, "property::index", ut) - capi.client.connect_signal("property::urgent", uc) + tag.attached_connect_signal(screen, "property::urgent", ut) capi.client.connect_signal("property::screen", function(c) -- If client change screen, refresh it anyway since we don't from -- which screen it was coming :-) diff --git a/objects/client.c b/objects/client.c index 8b7c7d6b..9c2dfec6 100644 --- a/objects/client.c +++ b/objects/client.c @@ -2537,6 +2537,7 @@ client_class_setup(lua_State *L) signal_add(&client_class.signals, "request::maximized_horizontal"); signal_add(&client_class.signals, "request::maximized_vertical"); signal_add(&client_class.signals, "request::tag"); + signal_add(&client_class.signals, "request::urgent"); signal_add(&client_class.signals, "tagged"); signal_add(&client_class.signals, "unfocus"); signal_add(&client_class.signals, "unmanage"); diff --git a/property.c b/property.c index c866c317..5fcd8f66 100644 --- a/property.c +++ b/property.c @@ -198,7 +198,9 @@ property_update_wm_hints(client_t *c, xcb_get_property_cookie_t cookie) return; luaA_object_push(L, c); - client_set_urgent(L, -1, xcb_icccm_wm_hints_get_urgency(&wmh)); + + lua_pushboolean(L, xcb_icccm_wm_hints_get_urgency(&wmh)); + luaA_object_emit_signal(L, -2, "request::urgent", 1); if(wmh.flags & XCB_ICCCM_WM_HINT_INPUT) c->nofocus = !wmh.input;