From e7ad4b178025dcff94769829aa1fc84ff6417500 Mon Sep 17 00:00:00 2001 From: anakha Date: Sun, 4 Jul 2021 22:11:56 -0400 Subject: [PATCH] focusable --- methods.lua | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++-- tabs.lua | 10 ++++++++-- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/methods.lua b/methods.lua index 38648a3..659175c 100644 --- a/methods.lua +++ b/methods.lua @@ -750,6 +750,47 @@ end -------------------------------------------------------- draw_tabbar() -- ; +local widget_ix = {} + +-- client.connect_signal("property::name", function (c) +-- -- todo: need to update the other clients in the region here as well + -- this may not even be worth it as the client names kind of pollute the + -- tabs a lot making it harder to distinguish what is what. + +-- if widget_ix[c.window] then +-- for i, p in pairs(widget_ix[c.window]) do +-- if p.focused then +-- widget = widget_ix[c.window][i]:get_children_by_id(c.window)[1] +-- -- naughty.notify({preset = naughty.config.presets.critical, text=inspect(widget)}) +-- widget.widget.markup = c.name +-- end +-- end +-- end +-- end) + + +client.connect_signal("focus", function (c) + if widget_ix[c.window] then + for i, p in pairs(widget_ix[c.window]) do + if p.focused then + widget = widget_ix[c.window][i]:get_children_by_id(c.window)[1] + widget.bg = "#43417a" + end + end + end +end) + +client.connect_signal("unfocus", function (c) + if widget_ix[c.window] then + for i, p in pairs(widget_ix[c.window]) do + if p.focused then + widget = widget_ix[c.window][i]:get_children_by_id(c.window)[1] + widget.bg = "#292929" + end + end + end +end) + function draw_tabbar(region_ix) local flexlist = tabs.layout() local tablist = get_tiled_clients(region_ix) @@ -766,11 +807,14 @@ function draw_tabbar(region_ix) for c_ix, c in ipairs(tablist) do local flexlist = tabs.layout() + widget_ix[c.window] = {} for cc_ix, cc in ipairs(tablist) do local buttons = gears.table.join(awful.button({}, 1, function() end)) - wid_temp = tabs.create(cc, (cc == c), buttons, c_ix) - flexlist:add(wid_temp) + -- wid_temp + widget_ix[c.window][cc_ix] = tabs.create(cc, (cc == c), buttons, c_ix) + + flexlist:add(widget_ix[c.window][cc_ix]) flexlist.max_widget_size = 120 end @@ -882,6 +926,15 @@ client.connect_signal("property::floating", floating_signal) client.connect_signal("tabbar_draw", draw_tabbar) --[[+] experimental signalling ]] +-- client:connect_signal("property::name", function(c) +-- if widget_ix[c.window] then +-- local widget = widget_ix[c.window]:get_children_by_id(c.window) + +-- text_temp.markup = "" .. title_temp.. "" +-- end +-- end) + + client.connect_signal("unmanage", unmanage_signal) --[[+] when removing a tiled client we must update the tabbars diff --git a/tabs.lua b/tabs.lua index 4b1f360..d31bf0b 100644 --- a/tabs.lua +++ b/tabs.lua @@ -25,10 +25,15 @@ local function create(c, focused_bool, buttons, idx) local fg_temp = fg_normal if focused_bool then - bg_temp = bg_active + bg_temp = bg_focus fg_temp = fg_focus end + if client.focus == c and focused_bool then + bg_temp = bg_active + end --|when the client is maximized and then minimized, bg + --|color should be active + local text_temp = wibox.widget.textbox() text_temp.align = "center" @@ -41,10 +46,11 @@ local function create(c, focused_bool, buttons, idx) if focused_bool then text_temp.focused = true end local wid_temp = wibox.widget({ - id = c.window..idx, + id = c.window, text_temp, buttons = buttons, bg = bg_temp, + focused = focused_bool, widget = wibox.container.background() })