impl: Adapt to new upstream API changes

* The screen API was broken
 * Many awful.tag, client and screen methods were deprecated
This commit is contained in:
Emmanuel Lepage Vallee 2016-04-13 01:24:18 -04:00
parent e18f664de0
commit aeb9aeb1b8
8 changed files with 59 additions and 55 deletions

View File

@ -30,7 +30,7 @@ local function push_focus(c)
if c and not pause_monitoring then if c and not pause_monitoring then
focusTable[c] = focusIdx focusTable[c] = focusIdx
focusIdx = focusIdx + 1 focusIdx = focusIdx + 1
focusTag[c] = tag.selected(c.screen) focusTag[c] = c.screen.selected_tag
end end
end end
capi.client.connect_signal("focus", push_focus) capi.client.connect_signal("focus", push_focus)
@ -114,7 +114,7 @@ local function new(args)
end end
local scr = capi.client.focus and capi.client.focus.screen or capi.mouse.screen local scr = capi.client.focus and capi.client.focus.screen or capi.mouse.screen
local t,auto_release = tag.selected(scr),args.auto_release local t,auto_release = scr.selected_tag,args.auto_release
local currentMenu = radical.box({filter = true, show_filter=not auto_release, autodiscard = true, local currentMenu = radical.box({filter = true, show_filter=not auto_release, autodiscard = true,
disable_markup=true,fkeys_prefix=not auto_release,width=(((capi.screen[scr]).geometry.width)/2), disable_markup=true,fkeys_prefix=not auto_release,width=(((capi.screen[scr]).geometry.width)/2),
icon_transformation = beautiful.alttab_icon_transformation,filter_underlay="Use [Shift] and [Control] to toggle clients",filter_underlay_color=beautiful.menu_bg_normal, icon_transformation = beautiful.alttab_icon_transformation,filter_underlay="Use [Shift] and [Control] to toggle clients",filter_underlay_color=beautiful.menu_bg_normal,
@ -201,7 +201,7 @@ local function new(args)
checked = v.screen == scr and (not auto_release and is_in_tag(t,v)) or nil, checked = v.screen == scr and (not auto_release and is_in_tag(t,v)) or nil,
button1 = function(a,b,c,d,no_hide) button1 = function(a,b,c,d,no_hide)
local t = focusTag[v] or v:tags()[1] local t = focusTag[v] or v:tags()[1]
if t and t.selected == false and not util.table.hasitem(v:tags(),tag.selected(v.screen)) then if t and t.selected == false and not util.table.hasitem(v:tags(),capi.screen[v.screen].selected_tag) then
lock_history = true lock_history = true
tag.viewonly(t) tag.viewonly(t)
lock_history = false lock_history = false

View File

@ -10,8 +10,8 @@ local module = {}
local function createTagList(aScreen) local function createTagList(aScreen)
local tagList = radical.context {} local tagList = radical.context {}
for _, v in ipairs(awful.tag.gettags(aScreen)) do for _, v in ipairs(capi.screen[aScreen].tags) do
tagList:add_item({text = v.name,icon=awful.tag.geticon(v)}) tagList:add_item({text = v.name,icon=v.icon})
end end
return tagList return tagList
end end

View File

@ -14,8 +14,8 @@ local function createTagList(aScreen,args)
end end
local tagList = args.menu or radical.context {} local tagList = args.menu or radical.context {}
local ret = {} local ret = {}
for _, v in ipairs(awful.tag.gettags(aScreen)) do for _, v in ipairs(capi.screen[aScreen].tags) do
args.text,args.icon = v.name,awful.tag.geticon(v) args.text,args.icon = v.name,v.icon
local i = tagList:add_item(args) local i = tagList:add_item(args)
i._tag = v i._tag = v
ret[v] = i ret[v] = i
@ -45,7 +45,7 @@ function module.listTags(args, menu)
end end
function module.layouts(menu,layouts) function module.layouts(menu,layouts)
local cur = awful.layout.get(awful.tag.getscreen(awful.tag.selected(capi.client.focus and capi.client.focus.screen))) local cur = awful.layout.get(capi.client.focus and capi.client.focus.screen)
local screenSelect = menu or radical.context {} local screenSelect = menu or radical.context {}
local layouts = layouts or awful.layout.layouts local layouts = layouts or awful.layout.layouts
@ -57,7 +57,7 @@ function module.layouts(menu,layouts)
if mod then if mod then
screenSelect[mod[1] == "Shift" and "previous_item" or "next_item"].selected = true screenSelect[mod[1] == "Shift" and "previous_item" or "next_item"].selected = true
end end
awful.layout.set(layouts[screenSelect.current_index] or layouts[1],awful.tag.selected(capi.client.focus and capi.client.focus.screen)) awful.layout.set(layouts[screenSelect.current_index] or layouts[1],(capi.client.focus and capi.client.focus.screen).selected_tag)
end, selected = is_current, item_layout = radical.item.layout.icon}) end, selected = is_current, item_layout = radical.item.layout.icon})
end end
end end

View File

@ -44,8 +44,8 @@ module.buttons = { [1] = awful.tag.viewonly,
menu.visible = true menu.visible = true
menu._internal.w:move_by_parent(geo, "cursor") menu._internal.w:move_by_parent(geo, "cursor")
end, end,
[4] = function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end, [4] = function(t) awful.tag.viewnext(t.screen) end,
[5] = function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end, [5] = function(t) awful.tag.viewprev(t.screen) end,
} }
-- awful.button({ modkey }, 1, awful.client.movetotag), -- awful.button({ modkey }, 1, awful.client.movetotag),
-- awful.button({ modkey }, 3, awful.client.toggletag), -- awful.button({ modkey }, 3, awful.client.toggletag),
@ -63,7 +63,7 @@ local function index_draw(self, context, cr, width, height)
end end
local function create_item(t,s) local function create_item(t,s)
local menu,ib,original = instances[s],nil,tag.geticon(t) or beautiful.taglist_default_icon local menu,ib,original = instances[capi.screen[s]],nil,t.icon or beautiful.taglist_default_icon
if not menu or not t then return end if not menu or not t then return end
local w = wibox.layout.fixed.horizontal() local w = wibox.layout.fixed.horizontal()
if beautiful.taglist_disable_icon ~= true then if beautiful.taglist_disable_icon ~= true then
@ -122,6 +122,7 @@ local function create_item(t,s)
menu:connect_signal("button::press",function(menu,item,button_id,mod,geo) menu:connect_signal("button::press",function(menu,item,button_id,mod,geo)
if module.buttons and module.buttons[button_id] then if module.buttons and module.buttons[button_id] then
if item.tag[1] then if item.tag[1] then
assert(type(item.tag[1]) == "tag")
module.buttons[button_id](item.tag[1],menu,item,button_id,mod,geo) module.buttons[button_id](item.tag[1],menu,item,button_id,mod,geo)
else else
print("Invalid tag") print("Invalid tag")
@ -138,8 +139,8 @@ local function create_item(t,s)
end end
local function track_used(c,t) local function track_used(c,t)
if t then if t and t.activated then
local item = cache[t] or create_item(t,tag.getscreen(t)) local item = cache[t] or create_item(t,t.screen or c.screen or capi.mouse.screen)
if not item then return end -- Yes, it happen if the screen is still nil if not item then return end -- Yes, it happen if the screen is still nil
item.state[radical.base.item_flags.USED] = #t:clients() > 0 and true or nil item.state[radical.base.item_flags.USED] = #t:clients() > 0 and true or nil
item.state[radical.base.item_flags.CHANGED] = ((not t.selected) and #t:clients() > 0) and true or nil item.state[radical.base.item_flags.CHANGED] = ((not t.selected) and #t:clients() > 0) and true or nil
@ -156,7 +157,7 @@ end
local function tag_activated(t) local function tag_activated(t)
if not t.activated and cache[t] then if not t.activated and cache[t] then
instances[cache[t]._internal.screen]:remove(cache[t]) instances[capi.screen[cache[t]._internal.screen]]:remove(cache[t])
cache[t] = nil cache[t] = nil
end end
end end
@ -164,18 +165,18 @@ end
local function tag_added(t,b) local function tag_added(t,b)
if not t then return end if not t then return end
local s = tag.getscreen(t) local s = t.screen
local item = cache[t] local item = cache[t]
-- Creating items when there is no screen cause random behaviors -- Creating items when there is no screen cause random behaviors
if not item and s then if not item and s then
create_item(t,s) create_item(t,s or capi.mouse.screen)
elseif item._internal.screen ~= s then elseif item._internal.screen ~= s then
if item._internal.screen then if item._internal.screen then
instances[item._internal.screen]:remove(item) instances[capi.screen[item._internal.screen]]:remove(item)
end end
if s then if s then
instances[s]:append(item) instances[capi.screen[s]]:append(item)
end end
--Allow nil --Allow nil
@ -185,7 +186,7 @@ end
local function select(t) local function select(t)
local s = t.selected local s = t.selected
local item = cache[t] or create_item(t,tag.getscreen(t)) local item = cache[t] or create_item(t,t.screen or capi.mouse.screen)
if item then if item then
item.state[radical.base.item_flags.SELECTED] = s or nil item.state[radical.base.item_flags.SELECTED] = s or nil
-- if s then --We also want to unset those when we quit the tag -- if s then --We also want to unset those when we quit the tag
@ -197,7 +198,7 @@ end
local function urgent_callback(t) local function urgent_callback(t)
local modif = tag.getproperty(t,"urgent") local modif = tag.getproperty(t,"urgent")
local item = cache[t] or create_item(t,tag.getscreen(t)) local item = cache[t] or create_item(t,t.screen or capi.mouse.screen)
if item then if item then
item.state[radical.base.item_flags.URGENT] = modif and true or nil item.state[radical.base.item_flags.URGENT] = modif and true or nil
end end
@ -228,7 +229,7 @@ local function init()
capi.tag.connect_signal("property::icon", function(t) capi.tag.connect_signal("property::icon", function(t)
local item = cache[t] local item = cache[t]
if item and item._internal.icon_w then if item and item._internal.icon_w then
item._internal.icon_w:set_image(tag.geticon(t) or beautiful.taglist_default_icon) item._internal.icon_w:set_image(t.icon or beautiful.taglist_default_icon)
end end
end) end)
is_init = true is_init = true
@ -282,22 +283,22 @@ local function new(s)
args["fg_"..v] = beautiful["taglist_fg_"..v] args["fg_"..v] = beautiful["taglist_fg_"..v]
end end
instances[s] = radical.bar(args) instances[capi.screen[s]] = radical.bar(args)
--Add some settings --Add some settings
rawset(instances[s],"index_prefix",beautiful.taglist_index_prefix) rawset(instances[capi.screen[s]],"index_prefix",beautiful.taglist_index_prefix)
rawset(instances[s],"index_suffix",beautiful.taglist_index_suffix) rawset(instances[capi.screen[s]],"index_suffix",beautiful.taglist_index_suffix)
-- Load the innitial set of tags -- Load the innitial set of tags
for k,t in ipairs(tag.gettags(s)) do for k,t in ipairs(capi.screen[s].tags) do
create_item(t,s) create_item(t,capi.screen[s])
end end
-- Per screen signals -- Per screen signals
-- tag.attached_connect_signal(screen, "property::hide", ut)! -- tag.attached_connect_signal(screen, "property::hide", ut)!
instances[s]:connect_signal("button::press",function(m,item,button_id,mod) instances[capi.screen[s]]:connect_signal("button::press",function(m,item,button_id,mod)
if module.buttons and module.buttons[button_id] then if module.buttons and module.buttons[button_id] then
module.buttons[button_id](item.tag[1],m,item,button_id,mod) module.buttons[button_id](item.tag[1],m,item,button_id,mod)
end end
@ -305,16 +306,16 @@ local function new(s)
init() init()
track:reload() track:reload()
return instances[s] return instances[capi.screen[s]]
end end
capi.tag.connect_signal("property::selected" , select) capi.tag.connect_signal("property::selected" , select)
capi.tag.connect_signal("property::index2",function(t,i) capi.tag.connect_signal("property::index2",function(t,i)
if t and not beautiful.taglist_disable_index then if t and not beautiful.taglist_disable_index then
local s = tag.getscreen(t) local s = t.screen
local item = cache[t] local item = cache[t]
if item then if item then
local menu = instances[s] local menu = instances[capi.screen[s]]
menu:move(item,i) menu:move(item,i)
if item.tw then if item.tw then
item.tw:set_markup((menu.index_prefix or " <b>#")..(i)..(menu.index_suffix or "</b>: ")) item.tw:set_markup((menu.index_prefix or " <b>#")..(i)..(menu.index_suffix or "</b>: "))

View File

@ -97,7 +97,7 @@ local function new(t)
aTagMenu:add_item({text = "Screen",sub_menu = screenMenu}) aTagMenu:add_item({text = "Screen",sub_menu = screenMenu})
for i=1,capi.screen.count() do for i=1,capi.screen.count() do
screenMenu:add_item({text = "Screen "..i, checked = tag.getscreen(aTag) == i,button1 = function() tag_to_screen(aTag,i) end}) screenMenu:add_item({text = "Screen "..i, checked = aTag.screen == i,button1 = function() tag_to_screen(aTag,i) end})
end end
end end
@ -108,7 +108,7 @@ local function new(t)
function createTagList(aScreen) function createTagList(aScreen)
local tagList = menu() local tagList = menu()
local count = 0 local count = 0
for _, v in ipairs(awful.tag.gettags(aScreen)) do for _, v in ipairs(capi.screen[aScreen].tags) do
tagList:add_item({text = v.name}) tagList:add_item({text = v.name})
count = count + 1 count = count + 1
end end
@ -127,7 +127,7 @@ local function new(t)
if (file == "END" or nil) or (counter > 30) then if (file == "END" or nil) or (counter > 30) then
break break
end end
mainMenu2:add_item({ button1 = function() tag.seticon(file,aTag) end, icon = file, item_layout = radical.item.layout.icon}) mainMenu2:add_item({ button1 = function() aTag.icon = file end, icon = file, item_layout = radical.item.layout.icon})
counter = counter +1 counter = counter +1
end end
f:close() f:close()

View File

@ -1,6 +1,6 @@
-- This module try to track tags relative index -- This module try to track tags relative index
-- It will emit signals the widget can rely on -- It will emit signals the widget can rely on
local capi = {tag=tag} local capi = {tag=tag,screen=screen}
local tag = require( "awful.tag" ) local tag = require( "awful.tag" )
local object = require( "radical.object" ) local object = require( "radical.object" )
local awful = require("awful") local awful = require("awful")
@ -10,14 +10,15 @@ local init = false
local screen_cache = setmetatable({}, { __mode = 'k' })--TODO this suck local screen_cache = setmetatable({}, { __mode = 'k' })--TODO this suck
local function reload(t,s) local function reload(t,s)
local s = s or tag.getscreen(t) or screen_cache[t] local s = s or t.screen or screen_cache[t]
local tracker = cache[s] local tracker = cache[s]
if not tracker then return end if not tracker then return end
local old_tags = tracker._internal.old_tags or {} local old_tags = tracker._internal.old_tags or {}
local new_tags = tag.gettags(s) local new_tags = capi.screen[s].tags
for k,v in ipairs(new_tags) do for k,v in ipairs(new_tags) do
if v ~= old_tags[k] then if v ~= old_tags[k] then
-- print(v.name,k,s,tag.getscreen(v),tag.getidx(v)) -- print(v.name,k,s,tag.getscreen(v),tag.getidx(v))
@ -37,7 +38,7 @@ end
local old_screen = awful.tag.getproperty(t,"screen") local old_screen = awful.tag.getproperty(t,"screen")
-- Change the screen -- Change the screen
awful.tag.setproperty(t, "screen", s) -- awful.tag.setproperty(t, "screen", s)
--Prevent some very strange side effects, does create some issue with multitag clients --Prevent some very strange side effects, does create some issue with multitag clients
for k,c in ipairs(t:clients()) do for k,c in ipairs(t:clients()) do

View File

@ -82,8 +82,8 @@ local function new(screen, args)
text = "Floating", text = "Floating",
checked = true , checked = true ,
button1 = function() button1 = function()
awful.client.floating.set(module.client,not awful.client.floating.get(module.client)) module.client.floating = not module.client.floating
itemVFloating.checked = awful.client.floating.get(module.client) itemVFloating.checked = module.client.floating
end end
} }
itemMaximized = mainMenu:add_item{ itemMaximized = mainMenu:add_item{

View File

@ -6,7 +6,7 @@
-- @license GPLv2+ because of copy paste from the old tasklist.lua -- @license GPLv2+ because of copy paste from the old tasklist.lua
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local capi = {client = client,tag=tag} local capi = {client = client,tag=tag,screen=screen}
local rawset = rawset local rawset = rawset
local radical = require( "radical" ) local radical = require( "radical" )
local tag = require( "awful.tag" ) local tag = require( "awful.tag" )
@ -83,7 +83,7 @@ end
local function sticky_callback(c) local function sticky_callback(c)
local val = c.sticky local val = c.sticky
sticky[c] = val and true or nil sticky[c] = val and true or nil
local menu = instances[c.screen].menu local menu = instances[capi.screen[c.screen]].menu
local is_in_tag = false local is_in_tag = false
for _,t in ipairs(tag.selectedlist(k)) do for _,t in ipairs(tag.selectedlist(k)) do
for k2,v2 in ipairs(c:tags()) do for k2,v2 in ipairs(c:tags()) do
@ -157,7 +157,7 @@ local function reload_infoshapes(c)
if c.ontop then if c.ontop then
infoshapes[#infoshapes+1] = infoshape_template.ontop infoshapes[#infoshapes+1] = infoshape_template.ontop
end end
if client.floating.get(c) then if c.floating then
infoshapes[#infoshapes+1] = infoshape_template.float infoshapes[#infoshapes+1] = infoshape_template.float
end end
if c.sticky then if c.sticky then
@ -184,7 +184,7 @@ end
local function create_client_item(c,screen) local function create_client_item(c,screen)
local item = _cache[c] local item = _cache[c]
local menu = instances[screen].menu local menu = instances[capi.screen[screen]].menu
-- If it already exist, don't waste time creating a copy -- If it already exist, don't waste time creating a copy
if item then if item then
menu:append(item) menu:append(item)
@ -236,11 +236,11 @@ end
-- Clear the menu and repopulate it -- Clear the menu and repopulate it
local function load_clients(t) local function load_clients(t)
local screen = tag.getscreen(t) local screen = t.screen
if not t or not screen or not instances[screen] then return end if not t or not screen or not instances[capi.screen[screen]] then return end
local menu = instances[screen].menu local menu = instances[capi.screen[screen]].menu
local clients = {} local clients = {}
local selected = tag.selectedlist(screen) local selected = screen.selected_tags
-- The "#selected > 0" is for reseting when multiple tags are selected -- The "#selected > 0" is for reseting when multiple tags are selected
if t.selected or #selected > 0 then if t.selected or #selected > 0 then
menu:clear() menu:clear()
@ -261,7 +261,7 @@ end
-- Reload the tag -- Reload the tag
local function tag_screen_changed(t) local function tag_screen_changed(t)
if not t.selected then return end if not t.selected then return end
local screen = tag.getscreen(t) local screen = t.screen
load_clients(t) load_clients(t)
end end
@ -284,9 +284,11 @@ end
-- Remove the client from the tag -- Remove the client from the tag
local function untagged(c,t) local function untagged(c,t)
local item = _cache[c] local item = _cache[c]
local screen = tag.getscreen(t)
if not item or not instances[screen] then return end -- t.screen can be nil if the tag was deleted
local menu = instances[screen].menu local screen = t.screen or c.screen or capi.mouse.screen
if not item or not instances[capi.screen[screen]] then return end
local menu = instances[capi.screen[screen]].menu
if t.selected then if t.selected then
menu:remove(item) menu:remove(item)
end end
@ -295,7 +297,7 @@ end
-- Add and remove clients from the tasklist -- Add and remove clients from the tasklist
local function tagged(c,t) local function tagged(c,t)
if t.selected and not c.sticky then if t.selected and not c.sticky then
add_client(c,tag.getscreen(t)) add_client(c,t.screen)
end end
end end
@ -332,9 +334,9 @@ local function new(screen)
-- Connect to a bunch of signals -- Connect to a bunch of signals
instances[screen] = {menu = menu} instances[capi.screen[screen]] = {menu = menu}
load_clients(tag.selected(screen)) load_clients(screen.selected_tag)
menu:connect_signal("button::press",function(menu,item,button_id,mod,geo) menu:connect_signal("button::press",function(menu,item,button_id,mod,geo)
if module.buttons and module.buttons[button_id] then if module.buttons and module.buttons[button_id] then