api: Fix deprecation warnings and update API usage
Be safe(r) with screen object usage.
This commit is contained in:
parent
62f251d36e
commit
edd065e694
|
@ -41,13 +41,13 @@ end
|
|||
|
||||
function module.get_geometry(tag)
|
||||
local cls,results,flt = {},setmetatable({},{__mode="k"}),{}
|
||||
local s = awful.tag.getscreen(tag)
|
||||
local s = tag.screen
|
||||
local l = awful.tag.getproperty(tag,"layout")
|
||||
local focus,focus_wrap = capi.client.focus,nil
|
||||
for k,c in ipairs (tag:clients()) do
|
||||
-- Handle floating client separately
|
||||
if not c.minimized then
|
||||
local floating = awful.client.floating.get(c)
|
||||
local floating = c.floating
|
||||
if (not floating) and (not l == awful.layout.suit.floating) then
|
||||
cls[#cls+1] = gen_cls(c,results)
|
||||
if c == focus then
|
||||
|
@ -82,7 +82,7 @@ end
|
|||
function module.draw(tag,cr,width,height)
|
||||
local worked = false
|
||||
local l,l2 = module.get_geometry(tag)
|
||||
local s = awful.tag.getscreen(tag)
|
||||
local s = tag.screen
|
||||
local scr_geo = capi.screen[s or 1].workarea
|
||||
local ratio = height/scr_geo.height
|
||||
local w_stretch = width/(scr_geo.width*ratio)
|
||||
|
@ -114,4 +114,4 @@ function module.draw(tag,cr,width,height)
|
|||
end
|
||||
|
||||
return module
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||
|
|
12
max.lua
12
max.lua
|
@ -233,7 +233,7 @@ local function tag_icon(t,width,height)
|
|||
local has_layout = layout.draw(t,cr,width,height)
|
||||
|
||||
-- Create a monochrome representation of the icon
|
||||
local icon_orig = surface(awful.tag.geticon(t))
|
||||
local icon_orig = surface(t.icon)
|
||||
if icon_orig then
|
||||
local icon = cairo.ImageSurface(cairo.Format.ARGB32, icon_orig:get_width(), icon_orig:get_height())
|
||||
local cr2 = cairo.Context(icon)
|
||||
|
@ -261,14 +261,14 @@ local function change_tag(s,direction,is_swap)
|
|||
awful.tag[direction == "left" and "viewprev" or "viewnext"](s)
|
||||
else
|
||||
-- Move the tag
|
||||
local t = awful.tag.selected(s)
|
||||
local cur_idx,count = awful.tag.getidx(t),#awful.tag.gettags(s)
|
||||
local t = capi.screen[s].selected_tag
|
||||
local cur_idx,count = awful.tag.getidx(t),#capi.screen[s].tags
|
||||
cur_idx = cur_idx + (direction == "left" and -1 or 1)
|
||||
cur_idx = cur_idx == 0 and count or cur_idx > count and 1 or cur_idx
|
||||
awful.tag.move(cur_idx,t)
|
||||
end
|
||||
local tags = awful.tag.gettags(s)
|
||||
local fk = awful.util.table.hasitem(tags,awful.tag.selected(s))
|
||||
local tags = capi.screen[s].tags
|
||||
local fk = awful.util.table.hasitem(tags,capi.screen[s].selected_tag)
|
||||
draw_shape(s,tags,fk,tag_icon,capi.screen[s].workarea.y + 15,20)
|
||||
end
|
||||
|
||||
|
@ -285,4 +285,4 @@ function module.change_tag(mod,key,event,direction,is_swap,is_max)
|
|||
end
|
||||
|
||||
return module
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||
|
|
|
@ -87,7 +87,7 @@ local function init_wiboxes(direction)
|
|||
end
|
||||
|
||||
local function select_screen(scr_index,move,old_screen)
|
||||
if scr_index ~= old_screen then
|
||||
if capi.screen[scr_index] ~= capi.screen[old_screen] then
|
||||
local c = last_clients[scr_index]
|
||||
if pcall(c) then
|
||||
last_clients[scr_index] = nil
|
||||
|
@ -108,8 +108,8 @@ local function select_screen(scr_index,move,old_screen)
|
|||
end
|
||||
|
||||
if move then
|
||||
local t = awful.tag.selected(old_screen)
|
||||
awful.tag.setscreen(t,scr_index)
|
||||
local t = capi.screen[old_screen].selected_tag
|
||||
t.screen = scr_index
|
||||
awful.tag.viewonly(t)
|
||||
else
|
||||
local c = awful.mouse.client_under_pointer()
|
||||
|
@ -146,7 +146,7 @@ local function save_cursor_position()
|
|||
end
|
||||
|
||||
local function next_screen(ss,dir,move)
|
||||
local scr_index = screens_inv[ss]
|
||||
local scr_index = capi.screen[screens_inv[ss]].index
|
||||
|
||||
if type(scr_index) == "screen" then
|
||||
scr_index = scr_index.index
|
||||
|
|
Loading…
Reference in New Issue