client: export tags as a function
That makes more sense. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
3104969d03
commit
871285551d
73
client.c
73
client.c
|
@ -986,6 +986,49 @@ luaA_client_swap(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Access or set the client tags.
|
||||||
|
* \param L The Lua VM state.
|
||||||
|
* \return The number of elements pushed on stack.
|
||||||
|
* \lparam A table with tags to set, or none to get the current tags table.
|
||||||
|
* \return The clients tag.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_client_tags(lua_State *L)
|
||||||
|
{
|
||||||
|
tag_array_t *tags;
|
||||||
|
tag_t **tag;
|
||||||
|
client_t **c = luaA_checkudata(L, 1, "client");
|
||||||
|
|
||||||
|
if(lua_gettop(L) == 2)
|
||||||
|
{
|
||||||
|
luaA_checktable(L, 2);
|
||||||
|
tags = &globalconf.screens[(*c)->screen].tags;
|
||||||
|
for(int i = 0; i < tags->len; i++)
|
||||||
|
untag_client(*c, tags->tab[i]);
|
||||||
|
lua_pushnil(L);
|
||||||
|
while(lua_next(L, 2))
|
||||||
|
{
|
||||||
|
tag = luaA_checkudata(L, -1, "tag");
|
||||||
|
tag_client(*c, *tag);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tags = &globalconf.screens[(*c)->screen].tags;
|
||||||
|
luaA_otable_new(L);
|
||||||
|
for(int i = 0; i < tags->len; i++)
|
||||||
|
if(is_client_tagged(*c, tags->tab[i]))
|
||||||
|
{
|
||||||
|
luaA_tag_userdata_new(L, tags->tab[i]);
|
||||||
|
luaA_tag_userdata_new(L, tags->tab[i]);
|
||||||
|
lua_rawset(L, -3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/** Focus a client (DEPRECATED).
|
/** Focus a client (DEPRECATED).
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
*
|
*
|
||||||
|
@ -1071,8 +1114,6 @@ luaA_client_newindex(lua_State *L)
|
||||||
double d;
|
double d;
|
||||||
int i;
|
int i;
|
||||||
titlebar_t **t = NULL;
|
titlebar_t **t = NULL;
|
||||||
tag_array_t *tags;
|
|
||||||
tag_t **tag;
|
|
||||||
|
|
||||||
if((*c)->invalid)
|
if((*c)->invalid)
|
||||||
luaL_error(L, "client is invalid\n");
|
luaL_error(L, "client is invalid\n");
|
||||||
|
@ -1175,19 +1216,6 @@ luaA_client_newindex(lua_State *L)
|
||||||
titlebar_init(*c);
|
titlebar_init(*c);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_TAGS:
|
|
||||||
luaA_checktable(L, 3);
|
|
||||||
tags = &globalconf.screens[(*c)->screen].tags;
|
|
||||||
for(i = 0; i < tags->len; i++)
|
|
||||||
untag_client(*c, tags->tab[i]);
|
|
||||||
lua_pushnil(L);
|
|
||||||
while(lua_next(L, 3))
|
|
||||||
{
|
|
||||||
tag = luaA_checkudata(L, -1, "tag");
|
|
||||||
tag_client(*c, *tag);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1216,7 +1244,6 @@ luaA_client_newindex(lua_State *L)
|
||||||
* \lfield coords The client coordinates.
|
* \lfield coords The client coordinates.
|
||||||
* \lfield titlebar The client titlebar.
|
* \lfield titlebar The client titlebar.
|
||||||
* \lfield urgent The client urgent state.
|
* \lfield urgent The client urgent state.
|
||||||
* \lfield tags The clients tags.
|
|
||||||
* \lfield focus The focused client.
|
* \lfield focus The focused client.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
|
@ -1231,8 +1258,6 @@ luaA_client_index(lua_State *L)
|
||||||
xutil_class_hint_t hint;
|
xutil_class_hint_t hint;
|
||||||
xcb_get_property_cookie_t prop_c;
|
xcb_get_property_cookie_t prop_c;
|
||||||
xcb_get_property_reply_t *prop_r = NULL;
|
xcb_get_property_reply_t *prop_r = NULL;
|
||||||
tag_array_t *tags;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if((*c)->invalid)
|
if((*c)->invalid)
|
||||||
luaL_error(L, "client is invalid\n");
|
luaL_error(L, "client is invalid\n");
|
||||||
|
@ -1326,17 +1351,6 @@ luaA_client_index(lua_State *L)
|
||||||
case A_TK_URGENT:
|
case A_TK_URGENT:
|
||||||
lua_pushboolean(L, (*c)->isurgent);
|
lua_pushboolean(L, (*c)->isurgent);
|
||||||
break;
|
break;
|
||||||
case A_TK_TAGS:
|
|
||||||
tags = &globalconf.screens[(*c)->screen].tags;
|
|
||||||
luaA_otable_new(L);
|
|
||||||
for(i = 0; i < tags->len; i++)
|
|
||||||
if(is_client_tagged(*c, tags->tab[i]))
|
|
||||||
{
|
|
||||||
luaA_tag_userdata_new(L, tags->tab[i]);
|
|
||||||
luaA_tag_userdata_new(L, tags->tab[i]);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1404,6 +1418,7 @@ const struct luaL_reg awesome_client_methods[] =
|
||||||
};
|
};
|
||||||
const struct luaL_reg awesome_client_meta[] =
|
const struct luaL_reg awesome_client_meta[] =
|
||||||
{
|
{
|
||||||
|
{ "tags", luaA_client_tags },
|
||||||
{ "kill", luaA_client_kill },
|
{ "kill", luaA_client_kill },
|
||||||
{ "swap", luaA_client_swap },
|
{ "swap", luaA_client_swap },
|
||||||
{ "focus_set", luaA_client_focus_set },
|
{ "focus_set", luaA_client_focus_set },
|
||||||
|
|
|
@ -505,8 +505,7 @@ function client.movetotag(target, c)
|
||||||
if sel then
|
if sel then
|
||||||
-- Check that tag and client screen are identical
|
-- Check that tag and client screen are identical
|
||||||
if sel.screen ~= target.screen then return end
|
if sel.screen ~= target.screen then return end
|
||||||
local tags = { target }
|
sel:tags({ target })
|
||||||
sel.tags = tags
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -517,13 +516,13 @@ function client.toggletag(target, c)
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
-- Check that tag and client screen are identical
|
-- Check that tag and client screen are identical
|
||||||
if sel and sel.screen == target.screen then
|
if sel and sel.screen == target.screen then
|
||||||
local tags = sel.tags
|
local tags = sel:tags()
|
||||||
if tags[target] then
|
if tags[target] then
|
||||||
tags[target] = nil
|
tags[target] = nil
|
||||||
else
|
else
|
||||||
tags[target] = target
|
tags[target] = target
|
||||||
end
|
end
|
||||||
sel.tags = tags
|
sel:tags(tags)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1151,7 +1150,7 @@ function widget.taglist.label.all(t, args)
|
||||||
bg_color = bg_focus
|
bg_color = bg_focus
|
||||||
fg_color = fg_focus
|
fg_color = fg_focus
|
||||||
end
|
end
|
||||||
if sel and sel.tags[t] then
|
if sel and sel:tags()[t] then
|
||||||
background = "resize=\"true\" image=\"@AWESOME_ICON_PATH@/taglist/squarefw.png\""
|
background = "resize=\"true\" image=\"@AWESOME_ICON_PATH@/taglist/squarefw.png\""
|
||||||
elseif bg_urgent and fg_urgent then
|
elseif bg_urgent and fg_urgent then
|
||||||
for k, c in pairs(t.clients) do
|
for k, c in pairs(t.clients) do
|
||||||
|
@ -1290,7 +1289,7 @@ function widget.tasklist.label.currenttags(c, screen, args)
|
||||||
-- Only print client on the same screen as this widget
|
-- Only print client on the same screen as this widget
|
||||||
if c.screen ~= screen then return end
|
if c.screen ~= screen then return end
|
||||||
for k, t in ipairs(capi.screen[screen].tags) do
|
for k, t in ipairs(capi.screen[screen].tags) do
|
||||||
if t.selected and c.tags[t] then
|
if t.selected and c:tags()[t] then
|
||||||
return widget_tasklist_label_common(c, args)
|
return widget_tasklist_label_common(c, args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue