tag: tag.get() now returns an 'hash' table
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
7709b22261
commit
471e0f1088
18
awful.lua
18
awful.lua
|
@ -138,7 +138,7 @@ local function tag_selectedlist(s)
|
|||
local screen = s or mouse.screen_get()
|
||||
local tags = tag.get(screen)
|
||||
local vtags = {}
|
||||
for i, t in ipairs(tags) do
|
||||
for i, t in pairs(tags) do
|
||||
if t:isselected() then
|
||||
vtags[idx] = t
|
||||
idx = idx + 1
|
||||
|
@ -204,7 +204,7 @@ end
|
|||
-- View no tag
|
||||
local function tag_viewnone()
|
||||
local tags = tag.get(mouse.screen_get())
|
||||
for i, t in ipairs(tags) do
|
||||
for i, t in pairs(tags) do
|
||||
t:view(false)
|
||||
end
|
||||
end
|
||||
|
@ -212,11 +212,13 @@ end
|
|||
local function tag_viewidx(r)
|
||||
local tags = tag.get(mouse.screen_get())
|
||||
local sel = tag_selected()
|
||||
local i = 1
|
||||
tag_viewnone()
|
||||
for i, t in ipairs(tags) do
|
||||
for name, t in pairs(tags) do
|
||||
if t == sel then
|
||||
tags[array_boundandcycle(tags, i + r)]:view(true)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -237,7 +239,7 @@ end
|
|||
|
||||
local function tag_viewmore(tags)
|
||||
tag_viewnone()
|
||||
for i, t in ipairs(tags) do
|
||||
for i, t in pairs(tags) do
|
||||
t:view(true)
|
||||
end
|
||||
end
|
||||
|
@ -245,7 +247,7 @@ end
|
|||
local function client_movetotag(target, c)
|
||||
local sel = c or client.focus_get();
|
||||
local tags = tag.get(mouse.screen_get())
|
||||
for i, t in ipairs(tags) do
|
||||
for i, t in pairs(tags) do
|
||||
sel:tag(t, false)
|
||||
end
|
||||
sel:tag(target, true)
|
||||
|
@ -254,17 +256,19 @@ end
|
|||
local function client_toggletag(target, c)
|
||||
local sel = c or client.focus_get();
|
||||
local toggle = false
|
||||
if sel then
|
||||
-- Count how many tags has the client
|
||||
-- an only toggle tag if the client has at least one tag other than target
|
||||
for k, v in ipairs(tag.get(sel:screen_get())) do
|
||||
for k, v in pairs(tag.get(sel:screen_get())) do
|
||||
if target ~= v and sel:istagged(v) then
|
||||
toggle = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if toggle and sel then
|
||||
if toggle then
|
||||
sel:tag(target, not sel:istagged(target))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function client_togglefloating(c)
|
||||
|
|
7
tag.c
7
tag.c
|
@ -267,8 +267,12 @@ luaA_tag_add(lua_State *L)
|
|||
|
||||
for(i = 0; i < globalconf.screens_info->nscreen; i++)
|
||||
for(t = globalconf.screens[i].tags; t; t = t->next)
|
||||
{
|
||||
if(*tag == t)
|
||||
luaL_error(L, "tag already on screen %d", i + 1);
|
||||
else if(t->screen == screen && !a_strcmp((*tag)->name, t->name))
|
||||
luaL_error(L, "a tag with the name `%s' is already on screen %d", t->name, i + 1);
|
||||
}
|
||||
|
||||
(*tag)->screen = screen;
|
||||
tag_append_to_screen(*tag, screen);
|
||||
|
@ -287,7 +291,6 @@ luaA_tag_get(lua_State *L)
|
|||
{
|
||||
int screen = luaL_checknumber(L, 1) - 1;
|
||||
tag_t *tag;
|
||||
int i = 1;
|
||||
|
||||
luaA_checkscreen(screen);
|
||||
|
||||
|
@ -296,7 +299,7 @@ luaA_tag_get(lua_State *L)
|
|||
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
||||
{
|
||||
luaA_tag_userdata_new(tag);
|
||||
lua_rawseti(L, -2, i++);
|
||||
lua_setfield(L, -2, tag->name);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
Loading…
Reference in New Issue