Add highlighting to altTab

This commit is contained in:
Emmanuel Lepage Vallee 2014-03-28 02:13:12 -04:00
parent f461d0316a
commit 03578bc71e
3 changed files with 60 additions and 21 deletions

View File

@ -1,12 +1,13 @@
local setmetatable,type = setmetatable, type
local ipairs, pairs = ipairs, pairs
local button = require( "awful.button" )
local beautiful = require( "beautiful" )
local tag = require( "awful.tag" )
local client2 = require( "awful.client" )
local radical = require( "radical" )
local util = require( "awful.util" )
local wibox = require( "wibox" )
local button = require( "awful.button" )
local beautiful = require( "beautiful" )
local tag = require( "awful.tag" )
local client2 = require( "awful.client" )
local radical = require( "radical" )
local util = require( "awful.util" )
local wibox = require( "wibox" )
local tag_list = require( "radical.impl.taglist" )
local capi = { client = client, mouse = mouse, screen = screen}
local module,pause_monitoring = {},false
@ -66,6 +67,27 @@ local function is_in_tag(t,c)
return false
end
local function reload_underlay(client,item)
local underlays = {}
for k,v in ipairs(client:tags()) do
underlays[#underlays+1] = v.name
end
if item then
item.underlay = underlays
end
return underlays
end
local function reload_highlight(i)
if i.selected then
local hl = {}
for k,v in ipairs(i.client:tags()) do
hl[#hl+1] = v
end
tag_list.highlight(hl)
end
end
local function new(args)
local histo = get_history(--[[screen]])
if #histo == o then
@ -105,6 +127,8 @@ local function new(args)
currentMenu:add_key_hook({}, "Shift_L", "press", function()
currentMenu._current_item.checked = not currentMenu._current_item.checked
client2.toggletag (t, currentMenu._current_item.client)
reload_underlay(currentMenu._current_item.client,currentMenu._current_item)
reload_highlight(currentMenu._current_item)
return true
end)
@ -118,13 +142,10 @@ local function new(args)
l:add( button_group({client = v, field = "ontop" , focus = false, checked = function() return v.ontop end, onclick = function() v.ontop = not v.ontop end }))
l:add( button_group({client = v, field = "close" , focus = false, checked = function() return false end, onclick = function() v:kill() end }))
local underlays = {}
for k,v in ipairs(v:tags()) do
underlays[#underlays+1] = v.name
end
local underlays = reload_underlay(v)
l.fit = function (s,w,h) return 5*h,h end
currentMenu:add_item({
local i = currentMenu:add_item({
text = v.name,
icon = v.icon or module.default_icon,
suffix_widget = not auto_release and l or nil,
@ -140,7 +161,10 @@ local function new(args)
v:raise()
currentMenu.visible = false
end,
}).client = v
})
i.client = v
i:connect_signal("selected::changed",reload_highlight)
end
end
@ -154,7 +178,11 @@ local function new(args)
pause_monitoring,currentMenu.visible = true, true
currentMenu:connect_signal("visible::changed",function(m)
if not m.visible then pause_monitoring = false;push_focus(capi.client.focus) end
if not m.visible then
pause_monitoring = false
push_focus(capi.client.focus)
tag_list.highlight()
end
end)
return currentMenu
end

View File

@ -179,17 +179,22 @@ local function init()
is_init = true
end
local highlighted = nil
local highlighted = {}
function module.highlight(t)
local tp = type(t)
if highlighted and highlighted ~= t then
highlighted.state[HIGHLIGHTED] = nil
highlighted = nil
for k,v in ipairs(highlighted) do
v.state[HIGHLIGHTED] = nil
end
highlighted = {}
end
if t then
local item = cache[t]
if item then
highlighted = item
highlighted.state[HIGHLIGHTED] = true
for k,v in ipairs(tp == "table" and t or {t}) do
local item = cache[v]
if item then
highlighted[#highlighted+1] = item
item.state[HIGHLIGHTED] = true
end
end
end
end

View File

@ -261,6 +261,12 @@ local function create_item(item,data,args)
-- Setup events
module.setup_event(data,item)
-- Setup dynamic underlay
-- Setup dynamic underlay
item:connect_signal("underlay::changed",function(_,udl)
bg:emit_signal("widget::updated")
end)
if item.buttons then
bg:buttons(item.buttons)
end