Add client.first_tag, as a shortcut for `c:tags()[1]`
This is meant to be a faster alternative in case only the first tag is relevant/used. Closes https://github.com/awesomeWM/awesome/pull/294.
This commit is contained in:
parent
78abb4a54c
commit
d5cf6e0272
|
@ -141,7 +141,7 @@ mytasklist.buttons = awful.util.table.join(
|
||||||
-- :isvisible() makes no sense
|
-- :isvisible() makes no sense
|
||||||
c.minimized = false
|
c.minimized = false
|
||||||
if not c:isvisible() then
|
if not c:isvisible() then
|
||||||
awful.tag.viewonly(c:tags()[1])
|
awful.tag.viewonly(c.first_tag)
|
||||||
end
|
end
|
||||||
-- This will also un-minimize
|
-- This will also un-minimize
|
||||||
-- the client, if needed
|
-- the client, if needed
|
||||||
|
|
|
@ -61,7 +61,7 @@ function client.jumpto(c, merge)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Try to make client visible, this also covers e.g. sticky
|
-- Try to make client visible, this also covers e.g. sticky
|
||||||
local t = c:tags()[1]
|
local t = c.first_tag
|
||||||
if t and not c:isvisible() then
|
if t and not c:isvisible() then
|
||||||
if merge then
|
if merge then
|
||||||
t.selected = true
|
t.selected = true
|
||||||
|
|
|
@ -613,7 +613,7 @@ end
|
||||||
-- terms[i] =
|
-- terms[i] =
|
||||||
-- {c.name,
|
-- {c.name,
|
||||||
-- function()
|
-- function()
|
||||||
-- awful.tag.viewonly(c:tags()[1])
|
-- awful.tag.viewonly(c.first_tag)
|
||||||
-- client.focus = c
|
-- client.focus = c
|
||||||
-- end,
|
-- end,
|
||||||
-- c.icon
|
-- c.icon
|
||||||
|
|
|
@ -97,6 +97,7 @@
|
||||||
* @field shape_client_clip The client's clip shape as set by the program as a (native) cairo surface.
|
* @field shape_client_clip The client's clip shape as set by the program as a (native) cairo surface.
|
||||||
* @field startup_id The FreeDesktop StartId.
|
* @field startup_id The FreeDesktop StartId.
|
||||||
* @field valid If the client that this object refers to is still managed by awesome.
|
* @field valid If the client that this object refers to is still managed by awesome.
|
||||||
|
* @field first_tag The first tag of the client. Optimized form of `c:tags()[1]`.
|
||||||
* @table client
|
* @table client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1559,9 +1560,11 @@ luaA_client_swap(lua_State *L)
|
||||||
|
|
||||||
/** Access or set the client tags.
|
/** Access or set the client tags.
|
||||||
*
|
*
|
||||||
* @param tags_table A table with tags to set, or none to get the current tags
|
* Use the `first_tag` field to access the first tag of a client directly.
|
||||||
* table.
|
*
|
||||||
* @return A table with all tags.
|
* @tparam table tags_table A table with tags to set, or `nil` to get the
|
||||||
|
* current tags.
|
||||||
|
* @treturn table A table with all tags.
|
||||||
* @function tags
|
* @function tags
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
|
@ -1611,6 +1614,23 @@ luaA_client_tags(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the first tag of a client.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_client_get_first_tag(lua_State *L)
|
||||||
|
{
|
||||||
|
client_t *c = luaA_checkudata(L, 1, &client_class);
|
||||||
|
|
||||||
|
foreach(tag, globalconf.tags)
|
||||||
|
if(is_client_tagged(c, *tag))
|
||||||
|
{
|
||||||
|
luaA_object_push(L, *tag);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Raise a client on top of others which are on the same layer.
|
/** Raise a client on top of others which are on the same layer.
|
||||||
*
|
*
|
||||||
* @function raise
|
* @function raise
|
||||||
|
@ -2639,6 +2659,10 @@ client_class_setup(lua_State *L)
|
||||||
NULL,
|
NULL,
|
||||||
(lua_class_propfunc_t) luaA_client_get_client_shape_clip,
|
(lua_class_propfunc_t) luaA_client_get_client_shape_clip,
|
||||||
NULL);
|
NULL);
|
||||||
|
luaA_class_add_property(&client_class, "first_tag",
|
||||||
|
NULL,
|
||||||
|
(lua_class_propfunc_t) luaA_client_get_first_tag,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/** When a client gains focus.
|
/** When a client gains focus.
|
||||||
* @signal .focus
|
* @signal .focus
|
||||||
|
|
Loading…
Reference in New Issue