Add highlighting to altTab
This commit is contained in:
parent
f461d0316a
commit
03578bc71e
|
@ -1,12 +1,13 @@
|
||||||
local setmetatable,type = setmetatable, type
|
local setmetatable,type = setmetatable, type
|
||||||
local ipairs, pairs = ipairs, pairs
|
local ipairs, pairs = ipairs, pairs
|
||||||
local button = require( "awful.button" )
|
local button = require( "awful.button" )
|
||||||
local beautiful = require( "beautiful" )
|
local beautiful = require( "beautiful" )
|
||||||
local tag = require( "awful.tag" )
|
local tag = require( "awful.tag" )
|
||||||
local client2 = require( "awful.client" )
|
local client2 = require( "awful.client" )
|
||||||
local radical = require( "radical" )
|
local radical = require( "radical" )
|
||||||
local util = require( "awful.util" )
|
local util = require( "awful.util" )
|
||||||
local wibox = require( "wibox" )
|
local wibox = require( "wibox" )
|
||||||
|
local tag_list = require( "radical.impl.taglist" )
|
||||||
local capi = { client = client, mouse = mouse, screen = screen}
|
local capi = { client = client, mouse = mouse, screen = screen}
|
||||||
|
|
||||||
local module,pause_monitoring = {},false
|
local module,pause_monitoring = {},false
|
||||||
|
@ -66,6 +67,27 @@ local function is_in_tag(t,c)
|
||||||
return false
|
return false
|
||||||
end
|
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 function new(args)
|
||||||
local histo = get_history(--[[screen]])
|
local histo = get_history(--[[screen]])
|
||||||
if #histo == o then
|
if #histo == o then
|
||||||
|
@ -105,6 +127,8 @@ local function new(args)
|
||||||
currentMenu:add_key_hook({}, "Shift_L", "press", function()
|
currentMenu:add_key_hook({}, "Shift_L", "press", function()
|
||||||
currentMenu._current_item.checked = not currentMenu._current_item.checked
|
currentMenu._current_item.checked = not currentMenu._current_item.checked
|
||||||
client2.toggletag (t, currentMenu._current_item.client)
|
client2.toggletag (t, currentMenu._current_item.client)
|
||||||
|
reload_underlay(currentMenu._current_item.client,currentMenu._current_item)
|
||||||
|
reload_highlight(currentMenu._current_item)
|
||||||
return true
|
return true
|
||||||
end)
|
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 = "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 }))
|
l:add( button_group({client = v, field = "close" , focus = false, checked = function() return false end, onclick = function() v:kill() end }))
|
||||||
|
|
||||||
local underlays = {}
|
local underlays = reload_underlay(v)
|
||||||
for k,v in ipairs(v:tags()) do
|
|
||||||
underlays[#underlays+1] = v.name
|
|
||||||
end
|
|
||||||
|
|
||||||
l.fit = function (s,w,h) return 5*h,h end
|
l.fit = function (s,w,h) return 5*h,h end
|
||||||
currentMenu:add_item({
|
local i = currentMenu:add_item({
|
||||||
text = v.name,
|
text = v.name,
|
||||||
icon = v.icon or module.default_icon,
|
icon = v.icon or module.default_icon,
|
||||||
suffix_widget = not auto_release and l or nil,
|
suffix_widget = not auto_release and l or nil,
|
||||||
|
@ -140,7 +161,10 @@ local function new(args)
|
||||||
v:raise()
|
v:raise()
|
||||||
currentMenu.visible = false
|
currentMenu.visible = false
|
||||||
end,
|
end,
|
||||||
}).client = v
|
})
|
||||||
|
i.client = v
|
||||||
|
|
||||||
|
i:connect_signal("selected::changed",reload_highlight)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -154,7 +178,11 @@ local function new(args)
|
||||||
|
|
||||||
pause_monitoring,currentMenu.visible = true, true
|
pause_monitoring,currentMenu.visible = true, true
|
||||||
currentMenu:connect_signal("visible::changed",function(m)
|
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)
|
end)
|
||||||
return currentMenu
|
return currentMenu
|
||||||
end
|
end
|
||||||
|
|
|
@ -179,17 +179,22 @@ local function init()
|
||||||
is_init = true
|
is_init = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local highlighted = nil
|
local highlighted = {}
|
||||||
function module.highlight(t)
|
function module.highlight(t)
|
||||||
|
local tp = type(t)
|
||||||
if highlighted and highlighted ~= t then
|
if highlighted and highlighted ~= t then
|
||||||
highlighted.state[HIGHLIGHTED] = nil
|
for k,v in ipairs(highlighted) do
|
||||||
highlighted = nil
|
v.state[HIGHLIGHTED] = nil
|
||||||
|
end
|
||||||
|
highlighted = {}
|
||||||
end
|
end
|
||||||
if t then
|
if t then
|
||||||
local item = cache[t]
|
for k,v in ipairs(tp == "table" and t or {t}) do
|
||||||
if item then
|
local item = cache[v]
|
||||||
highlighted = item
|
if item then
|
||||||
highlighted.state[HIGHLIGHTED] = true
|
highlighted[#highlighted+1] = item
|
||||||
|
item.state[HIGHLIGHTED] = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -261,6 +261,12 @@ local function create_item(item,data,args)
|
||||||
-- Setup events
|
-- Setup events
|
||||||
module.setup_event(data,item)
|
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
|
if item.buttons then
|
||||||
bg:buttons(item.buttons)
|
bg:buttons(item.buttons)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue