diff --git a/common/tokenize.gperf b/common/tokenize.gperf index 40e91549..c17b86cf 100644 --- a/common/tokenize.gperf +++ b/common/tokenize.gperf @@ -26,6 +26,7 @@ ellipsize end fg focus +focusable font font_height fullscreen diff --git a/luadoc/client.lua b/luadoc/client.lua index 85700ced..8e676ee6 100644 --- a/luadoc/client.lua +++ b/luadoc/client.lua @@ -40,6 +40,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 diff --git a/objects/client.c b/objects/client.c index 6709095c..7096f7e9 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1613,6 +1613,22 @@ luaA_client_get_icon(lua_State *L, client_t *c) 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 luaA_client_get_size_hints(lua_State *L, client_t *c) { @@ -1957,6 +1973,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