[layout] Pass screen number on arrange; fix layoutbox

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-26 16:07:35 +02:00
parent be44700669
commit a5c00cca24
3 changed files with 19 additions and 14 deletions

View File

@ -68,9 +68,13 @@ mytextbox:set("text", "<i><small>awesome " .. AWESOME_VERSION .. "</small></i>")
myiconbox = widget.new({ type = "iconbox", name = "myiconbox", align = "right" }) myiconbox = widget.new({ type = "iconbox", name = "myiconbox", align = "right" })
myiconbox:set("image", "@iconsdir@/awesome16.png") myiconbox:set("image", "@iconsdir@/awesome16.png")
-- Create an iconbox widget which will contains an icon indicating which layout we're using -- Create an iconbox widget which will contains an icon indicating which layout we're using.
mylayoutbox = widget.new({ type = "iconbox", name = "myiconbox", align = "right" }) -- We need one layoutbox per screen.
mylayoutbox:set("image", "@iconsdir@/layouts/tile.png") mylayoutbox = {}
for s = 1, awesome.screen_count() do
mylayoutbox[s] = widget.new({ type = "iconbox", name = "myiconbox", align = "right" })
mylayoutbox[s]:set("image", "@iconsdir@/layouts/tile.png")
end
-- Create a statusbar for each screen and add it -- Create a statusbar for each screen and add it
for s = 1, awesome.screen_count() do for s = 1, awesome.screen_count() do
@ -80,7 +84,7 @@ for s = 1, awesome.screen_count() do
mystatusbar:widget_add(mytaglist) mystatusbar:widget_add(mytaglist)
mystatusbar:widget_add(mytasklist) mystatusbar:widget_add(mytasklist)
mystatusbar:widget_add(mytextbox) mystatusbar:widget_add(mytextbox)
mystatusbar:widget_add(mylayoutbox) mystatusbar:widget_add(mylayoutbox[s])
mystatusbar:add(s) mystatusbar:add(s)
end end
-- }}} -- }}}
@ -197,9 +201,9 @@ end
-- Hook function to execute when arranging the screen -- Hook function to execute when arranging the screen
-- (tag switch, new client, etc) -- (tag switch, new client, etc)
function hook_arrange() function hook_arrange(screen)
local layout = awful.layout.get() local layout = awful.layout.get(screen)
mylayoutbox:set("image", "@iconsdir@/layouts/" .. layout .. "w.png") mylayoutbox[screen]:set("image", "@iconsdir@/layouts/" .. layout .. "w.png")
end end
-- Set up some hooks -- Set up some hooks

View File

@ -91,9 +91,9 @@ function screen_focus(i)
end end
-- Return a table with all visible tags -- Return a table with all visible tags
function tag_selectedlist() function tag_selectedlist(s)
local idx = 1 local idx = 1
local screen = mouse.screen_get() local screen = s or mouse.screen_get()
local tags = tag.get(screen) local tags = tag.get(screen)
local vtags = {} local vtags = {}
for i, t in ipairs(tags) do for i, t in ipairs(tags) do
@ -107,8 +107,8 @@ end
-- Return only the first element of all visible tags, -- Return only the first element of all visible tags,
-- so that's the first visible tags. -- so that's the first visible tags.
function tag_selected() function tag_selected(s)
return tag_selectedlist()[1] return tag_selectedlist(s)[1]
end end
-- Set master width factor -- Set master width factor
@ -223,8 +223,8 @@ function client_togglefloating(c)
end end
end end
function layout_get() function layout_get(screen)
local t = tag_selected() local t = tag_selected(screen)
if t then if t then
return t:layout_get() return t:layout_get()
end end

View File

@ -94,7 +94,8 @@ arrange(int screen)
globalconf.screens[screen].need_arrange = false; globalconf.screens[screen].need_arrange = false;
/* call hook */ /* call hook */
luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 0); lua_pushnumber(globalconf.L, screen + 1);
luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1);
} }
/** Refresh the screen disposition /** Refresh the screen disposition