From 9d1ae71cbfe73888bfd0005aed60e08bbe8adfd7 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 12 Aug 2010 13:08:55 +0200 Subject: [PATCH] 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 --- client.c | 20 ++++++++++++++++++++ common/tokenize.gperf | 1 + luadoc/client.lua | 1 + 3 files changed, 22 insertions(+) diff --git a/client.c b/client.c index 299b8e406..8ec58aa24 100644 --- a/client.c +++ b/client.c @@ -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 diff --git a/common/tokenize.gperf b/common/tokenize.gperf index 7f07a4d6f..84cc0f343 100644 --- a/common/tokenize.gperf +++ b/common/tokenize.gperf @@ -30,6 +30,7 @@ ellipsize end fg focus +focusable font font_height fullscreen diff --git a/luadoc/client.lua b/luadoc/client.lua index 6cabe2430..d85e32714 100644 --- a/luadoc/client.lua +++ b/luadoc/client.lua @@ -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