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 6f19940020
commit 9d1ae71cbf
3 changed files with 22 additions and 0 deletions

View File

@ -1998,6 +1998,22 @@ luaA_client_get_titlebar(lua_State *L, client_t *c)
return luaA_object_push(L, c->titlebar);
}
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
luaA_client_get_size_hints(lua_State *L, client_t *c)
{
@ -2381,6 +2397,10 @@ client_class_setup(lua_State *L)
NULL,
(lua_class_propfunc_t) luaA_client_get_size_hints,
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

View File

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

View File

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