From d688ebe6cdc869e9e175c5cbb824f88a24ad356f Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 16 Apr 2014 00:32:44 -0400 Subject: [PATCH 1/3] Add new request::urgent signal This fix two things: (1) Clients asking to be urgent while focussed, this have been reported a few time for urxvt and I usually link a patch that fix this. This may not be considered a bug by some, but I think it is. (2) Add the ability to stop noisy clients from setting the urgent state themselves. --- ewmh.c | 18 ++++++++++++------ lib/awful/ewmh.lua.in | 8 ++++++++ objects/client.c | 1 + property.c | 4 +++- property.h | 0 5 files changed, 24 insertions(+), 7 deletions(-) mode change 100644 => 100755 objects/client.c mode change 100644 => 100755 property.h 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/objects/client.c b/objects/client.c old mode 100644 new mode 100755 index 1e2ea4f8..c5ef8798 --- a/objects/client.c +++ b/objects/client.c @@ -2524,6 +2524,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; diff --git a/property.h b/property.h old mode 100644 new mode 100755 From b292b09328137a8e8822ea6bc370ebf7d83a64ae Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 1 Nov 2014 18:19:12 -0400 Subject: [PATCH 2/3] Add 'urgent' property to tags --- lib/awful/tag.lua.in | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) mode change 100644 => 100755 lib/awful/tag.lua.in diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in old mode 100644 new mode 100755 index cfb3b105..c1f7607b --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -630,7 +630,40 @@ capi.client.connect_signal("manage", function(c) c:connect_signal("property::screen", tag.withcurrent) end) +-- Keep track of the number of urgent client +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.add_signal("untagged", client_untagged) +capi.client.add_signal("tagged", client_tagged) capi.tag.connect_signal("request::select", tag.viewonly) capi.tag.add_signal("property::hide") @@ -642,6 +675,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 From 1306a543c287cf8e8cbe5c9f26e313a6bc9c2112 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 20 Apr 2014 02:25:54 -0400 Subject: [PATCH 3/3] Use tag urgent::property instead of looping every clients in awful.widgets.taglist --- lib/awful/widget/taglist.lua.in | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) mode change 100644 => 100755 lib/awful/widget/taglist.lua.in diff --git a/lib/awful/widget/taglist.lua.in b/lib/awful/widget/taglist.lua.in old mode 100644 new mode 100755 index 97c0ab8a..d08c329d --- 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 @@ -175,7 +172,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 :-)