taglist: Use Awesome official tag index.
No more hacks, all it caused was hidding issues deeper and having asserts() after a few weeks of runtime. Awesome tag.index is still buggy, but I will fix it and write the proper tests so it stay fixed. No more hacks.
This commit is contained in:
parent
5e0a9b87b1
commit
d6d34433f6
|
@ -15,8 +15,8 @@ local wibox = require( "wibox" )
|
|||
local awful = require( "awful" )
|
||||
local theme = require( "radical.theme")
|
||||
local surface = require( "gears.surface" )
|
||||
local tracker = require( "radical.impl.taglist.tracker" )
|
||||
local tag_menu = require( "radical.impl.taglist.tag_menu" )
|
||||
local timer = require("gears.timer")
|
||||
|
||||
local HIGHLIGHTED = -2
|
||||
local EMPTY = 412345
|
||||
|
@ -94,6 +94,25 @@ local function create_item(t,s)
|
|||
w:add(w2)
|
||||
end
|
||||
|
||||
if not beautiful.taglist_disable_index then
|
||||
item:connect_signal("index::changed", function()
|
||||
print("INDEX", item.index, table.concat {
|
||||
(menu.index_prefix or " <b>#"),
|
||||
(item.index or 00),
|
||||
(menu.index_suffix or "</b>: ")
|
||||
})
|
||||
if item.tw then
|
||||
item.tw:set_markup(
|
||||
table.concat {
|
||||
(menu.index_prefix or " <b>#"),
|
||||
(item.index or 00),
|
||||
(menu.index_suffix or "</b>: ")
|
||||
}
|
||||
)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Redraw the icon when necessary
|
||||
if menu.icon_per_state == true then
|
||||
item:connect_signal("state::changed",function(i,d,st)
|
||||
|
@ -239,8 +258,6 @@ end
|
|||
|
||||
local function new(s)
|
||||
|
||||
local track = tracker(s)
|
||||
|
||||
local args = {
|
||||
item_style = beautiful.taglist_item_style or radical.item.style.arrow_prefix,
|
||||
style = beautiful.taglist_style,
|
||||
|
@ -284,21 +301,43 @@ local function new(s)
|
|||
end)
|
||||
|
||||
init()
|
||||
track:reload()
|
||||
|
||||
return instances[capi.screen[s]]
|
||||
end
|
||||
|
||||
local delayed_reflow = {}
|
||||
|
||||
local function force_reflow(s)
|
||||
if not delayed_reflow[s] then
|
||||
timer.delayed_call(function()
|
||||
delayed_reflow[s] = false
|
||||
local tags = capi.screen[s].tags
|
||||
local menu = instances[capi.screen[s]]
|
||||
-- print("\n\nHERE!")
|
||||
if menu then
|
||||
for i, t in ipairs(tags) do
|
||||
local item = cache[t]
|
||||
-- It is possible that the items hasn't been created yet
|
||||
if item then
|
||||
-- print("ITEM", t.name, i)
|
||||
menu:move(item,i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
delayed_reflow[s] = true
|
||||
end
|
||||
end
|
||||
|
||||
capi.tag.connect_signal("property::selected" , select)
|
||||
capi.tag.connect_signal("property::index2",function(t,i)
|
||||
capi.tag.connect_signal("property::index",function(t)
|
||||
if t and not beautiful.taglist_disable_index then
|
||||
local i = t.index
|
||||
local s = t.screen
|
||||
local item = cache[t]
|
||||
if item then
|
||||
local menu = instances[capi.screen[s]]
|
||||
menu:move(item,i)
|
||||
if item.tw then
|
||||
item.tw:set_markup((menu.index_prefix or " <b>#")..(i)..(menu.index_suffix or "</b>: "))
|
||||
end
|
||||
force_reflow(s)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -318,4 +357,4 @@ end
|
|||
|
||||
|
||||
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||
-- kate: space-indent on; indent-width 4; replace-tabs on;
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
-- This module try to track tags relative index
|
||||
-- It will emit signals the widget can rely on
|
||||
local capi = {tag=tag,screen=screen}
|
||||
local object = require( "radical.object" )
|
||||
|
||||
local cache = {}
|
||||
local init = false
|
||||
local screen_cache = setmetatable({}, { __mode = 'k' })--TODO this suck
|
||||
|
||||
local function reload(t,s)
|
||||
s = s or t.screen or screen_cache[t]
|
||||
local tracker = cache[s]
|
||||
|
||||
if not tracker then return end
|
||||
|
||||
local old_tags = tracker._internal.old_tags or {}
|
||||
|
||||
local new_tags = capi.screen[s].tags
|
||||
|
||||
for k,v in ipairs(new_tags) do
|
||||
if v ~= old_tags[k] then
|
||||
-- print(v.name,k,s,tag.getscreen(v),tag.getidx(v))
|
||||
v:emit_signal("property::index2",k)
|
||||
screen_cache[v] = s
|
||||
end
|
||||
end
|
||||
tracker._internal.old_tags = new_tags
|
||||
end
|
||||
|
||||
--[[awful.tag.setscreen = function(t, s)
|
||||
if not tag or type(t) ~= "tag" or not s then return end
|
||||
|
||||
-- Keeping the old index make very little sense when chaning screen
|
||||
awful.tag.setproperty(t, "index", nil)
|
||||
|
||||
local old_screen = awful.tag.getproperty(t,"screen")
|
||||
|
||||
-- Change the screen
|
||||
-- awful.tag.setproperty(t, "screen", s)
|
||||
|
||||
--Prevent some very strange side effects, does create some issue with multitag clients
|
||||
for k,c in ipairs(t:clients()) do
|
||||
c.screen = s --Move all clients
|
||||
c:tags({t})
|
||||
end
|
||||
awful.tag.history.restore(old_screen,1)
|
||||
end]]--
|
||||
|
||||
local function new(s)
|
||||
if cache[s] then return cache[s] end
|
||||
|
||||
local tracker = object({
|
||||
private_data = {
|
||||
selected = false,
|
||||
},
|
||||
autogen_getmap = true,
|
||||
autogen_setmap = true,
|
||||
autogen_signals = true,
|
||||
})
|
||||
tracker._internal = {}
|
||||
|
||||
cache[s] = tracker
|
||||
|
||||
if not init then
|
||||
capi.tag.connect_signal("property::screen" , reload )
|
||||
capi.tag.connect_signal("property::activated", reload )
|
||||
capi.tag.connect_signal("property::index" , reload )
|
||||
end
|
||||
|
||||
tracker.reload = function()
|
||||
reload(nil,s)
|
||||
end
|
||||
|
||||
return tracker
|
||||
end
|
||||
|
||||
return setmetatable({}, { __call = function(_, ...) return new(...) end })
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
Loading…
Reference in New Issue