Add "focusable" property to client objects

If this property is true, setting "client.focus" to this client might have some
effect. If it is false, setting "client.focus" will be ignored completely.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-08-12 13:08:55 +02:00
parent 7e03e3b796
commit 544fa215ea
3 changed files with 22 additions and 0 deletions

View File

@ -26,6 +26,7 @@ ellipsize
end end
fg fg
focus focus
focusable
font font
font_height font_height
fullscreen fullscreen

View File

@ -40,6 +40,7 @@ module("client")
-- user_size, program_position, program_size, etc. -- user_size, program_position, program_size, etc.
-- @field sticky Set the client sticky, i.e. available on all tags. -- @field sticky Set the client sticky, i.e. available on all tags.
-- @field modal Indicate if the client is modal. -- @field modal Indicate if the client is modal.
-- @field focusable True if the client can receive the input focus.
-- @class table -- @class table
-- @name client -- @name client

View File

@ -1613,6 +1613,22 @@ luaA_client_get_icon(lua_State *L, client_t *c)
return luaA_object_push_item(L, -2, c->icon); return luaA_object_push_item(L, -2, c->icon);
} }
static int
luaA_client_get_focusable(lua_State *L, client_t *c)
{
bool ret;
/* A client can be focused if it doesnt have the "nofocus" hint...*/
if (!c->nofocus)
ret = true;
else
/* ...or if it knows the WM_TAKE_FOCUS protocol */
ret = client_hasproto(c, WM_TAKE_FOCUS);
lua_pushboolean(L, ret);
return 1;
}
static int static int
luaA_client_get_size_hints(lua_State *L, client_t *c) luaA_client_get_size_hints(lua_State *L, client_t *c)
{ {
@ -1957,6 +1973,10 @@ client_class_setup(lua_State *L)
NULL, NULL,
(lua_class_propfunc_t) luaA_client_get_size_hints, (lua_class_propfunc_t) luaA_client_get_size_hints,
NULL); NULL);
luaA_class_add_property(&client_class, A_TK_FOCUSABLE,
NULL,
(lua_class_propfunc_t) luaA_client_get_focusable,
NULL);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80