Tabbar fixes

changed modern theme size

changed tabbar bg, as focused doesnt really matter
This commit is contained in:
Gokul Swaminathan 2020-11-23 16:43:05 -08:00
parent a8e60891c1
commit 429fcd26fe
2 changed files with 43 additions and 56 deletions

View File

@ -8,9 +8,7 @@ In the function themselves, the same object is refered to as "tabobj" which is w
you will often see something like: "local tabobj = some_client.bling_tabbed" at the beginning you will often see something like: "local tabobj = some_client.bling_tabbed" at the beginning
of a function. of a function.
--]] --]] local awful = require("awful")
local awful = require("awful")
local wibox = require("wibox") local wibox = require("wibox")
local gears = require("gears") local gears = require("gears")
local beautiful = require("beautiful") local beautiful = require("beautiful")
@ -18,16 +16,12 @@ local beautiful = require("beautiful")
local helpers = require(tostring(...):match(".*bling.module") .. ".helpers") local helpers = require(tostring(...):match(".*bling.module") .. ".helpers")
local bar_style = beautiful.tabbar_style or "default" local bar_style = beautiful.tabbar_style or "default"
local bar = require(tostring(...):match(".*bling") .. ".widget.tabbar." .. bar_style) local bar = require(tostring(...):match(".*bling") .. ".widget.tabbar." ..
bar_style)
local function copy_size(c, parent_client) local function copy_size(c, parent_client)
if not c or not parent_client then if not c or not parent_client then return end
return if not c.valid or not parent_client.valid then return end
end
if not c.valid or not parent_client.valid then
return
end
c.floating = parent_client.floating c.floating = parent_client.floating
c.x = parent_client.x c.x = parent_client.x
c.y = parent_client.y c.y = parent_client.y
@ -43,9 +37,7 @@ tabbed.iter = function(idx)
if not client.focus.bling_tabbed then return end if not client.focus.bling_tabbed then return end
local tabobj = client.focus.bling_tabbed local tabobj = client.focus.bling_tabbed
local new_idx = (tabobj.focused_idx + idx) % #tabobj.clients local new_idx = (tabobj.focused_idx + idx) % #tabobj.clients
if new_idx == 0 then if new_idx == 0 then new_idx = #tabobj.clients end
new_idx = #tabobj.clients
end
tabbed.switch_to(tabobj, new_idx) tabbed.switch_to(tabobj, new_idx)
end end
@ -69,7 +61,7 @@ end
tabbed.add = function(c, tabobj) tabbed.add = function(c, tabobj)
if c.bling_tabbed then return end if c.bling_tabbed then return end
copy_size(c, tabobj.clients[tabobj.focused_idx]) copy_size(c, tabobj.clients[tabobj.focused_idx])
tabobj.clients[#tabobj.clients+1] = c tabobj.clients[#tabobj.clients + 1] = c
tabobj.focused_idx = #tabobj.clients tabobj.focused_idx = #tabobj.clients
-- calls update even though switch_to calls update again -- calls update even though switch_to calls update again
-- but the new client needs to have the tabobj property -- but the new client needs to have the tabobj property
@ -89,10 +81,8 @@ tabbed.pick = function()
local output = handle:read("*a") local output = handle:read("*a")
handle:close() handle:close()
-- search the client that was picked -- search the client that was picked
for _,c in ipairs(client.get()) do for _, c in ipairs(client.get()) do
if tonumber(c.pid) == tonumber(output) then if tonumber(c.pid) == tonumber(output) then tabbed.add(c, tabobj) end
tabbed.add(c, tabobj)
end
end end
end end
@ -100,7 +90,7 @@ end
tabbed.update = function(tabobj) tabbed.update = function(tabobj)
local currently_focused_c = tabobj.clients[tabobj.focused_idx] local currently_focused_c = tabobj.clients[tabobj.focused_idx]
-- update tabobj of each client and other things -- update tabobj of each client and other things
for idx,c in ipairs(tabobj.clients) do for idx, c in ipairs(tabobj.clients) do
if c.valid then if c.valid then
c.bling_tabbed = tabobj c.bling_tabbed = tabobj
copy_size(c, currently_focused_c) copy_size(c, currently_focused_c)
@ -111,10 +101,10 @@ tabbed.update = function(tabobj)
c:connect_signal("unmanage", function(c) c:connect_signal("unmanage", function(c)
if not c.bling_tabbed then return end if not c.bling_tabbed then return end
local old_tabobj = c.bling_tabbed local old_tabobj = c.bling_tabbed
local tabobj = {clients={}, focused_idx=1} local tabobj = {clients = {}, focused_idx = 1}
for _, c_temp in ipairs(old_tabobj.clients) do for _, c_temp in ipairs(old_tabobj.clients) do
if c_temp.window ~= c.window then if c_temp.window ~= c.window then
tabobj.clients[#tabobj.clients+1] = c_temp tabobj.clients[#tabobj.clients + 1] = c_temp
end end
end end
tabbed.update(tabobj) tabbed.update(tabobj)
@ -130,7 +120,7 @@ end
tabbed.switch_to = function(tabobj, new_idx) tabbed.switch_to = function(tabobj, new_idx)
local old_focused_c = tabobj.clients[tabobj.focused_idx] local old_focused_c = tabobj.clients[tabobj.focused_idx]
tabobj.focused_idx = new_idx tabobj.focused_idx = new_idx
for idx,c in ipairs(tabobj.clients) do for idx, c in ipairs(tabobj.clients) do
if idx ~= new_idx then if idx ~= new_idx then
helpers.turn_off(c) helpers.turn_off(c)
else else
@ -148,25 +138,22 @@ end
tabbed.update_tabbar = function(tabobj) tabbed.update_tabbar = function(tabobj)
local flexlist = bar.layout() local flexlist = bar.layout()
-- itearte over all tabbed clients to create the widget tabbed list -- itearte over all tabbed clients to create the widget tabbed list
for idx,c in ipairs(tabobj.clients) do for idx, c in ipairs(tabobj.clients) do
local buttons = gears.table.join(awful.button({}, 1, function() local buttons = gears.table.join(
awful.button({}, 1, function()
tabbed.switch_to(tabobj, idx) tabbed.switch_to(tabobj, idx)
end)) end))
wid_temp = bar.create(c, (idx==tabobj.focused_idx), buttons) wid_temp = bar.create(c, (idx == tabobj.focused_idx), buttons)
flexlist:add(wid_temp) flexlist:add(wid_temp)
end end
-- add tabbar to each tabbed client (clients will be hided anyway) -- add tabbar to each tabbed client (clients will be hided anyway)
for _,c in ipairs(tabobj.clients) do for _, c in ipairs(tabobj.clients) do
local titlebar = awful.titlebar(c, { local titlebar = awful.titlebar(c, {
bg_normal = bar.bg_normal, bg = bar.bg_normal,
bg_focus = bar.bg_focus,
size = bar.size, size = bar.size,
position = bar.position position = bar.position
}) })
titlebar:setup { titlebar:setup{layout = wibox.layout.flex.horizontal, flexlist}
layout = wibox.layout.flex.horizontal,
flexlist,
}
end end
end end

View File

@ -10,7 +10,7 @@ local fg_normal = beautiful.tabbar_fg_normal or beautiful.fg_normal or "#000000"
local bg_focus = beautiful.tabbar_bg_focus or beautiful.bg_focus or "#000000" local bg_focus = beautiful.tabbar_bg_focus or beautiful.bg_focus or "#000000"
local fg_focus = beautiful.tabbar_fg_focus or beautiful.fg_focus or "#ffffff" local fg_focus = beautiful.tabbar_fg_focus or beautiful.fg_focus or "#ffffff"
local font = beautiful.tabbar_font or beautiful.font or "Hack 15" local font = beautiful.tabbar_font or beautiful.font or "Hack 15"
local size = beautiful.tabbar_size or dpi(20) local size = beautiful.tabbar_size or dpi(40)
local border_radius = local border_radius =
beautiful.mstab_border_radius or beautiful.border_radius or 6 beautiful.mstab_border_radius or beautiful.border_radius or 6
local position = beautiful.tabbar_orientation or "top" local position = beautiful.tabbar_orientation or "top"