[client] Add client.name_set() function and hook on title update
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
2654b5b938
commit
f6f74c4565
16
client.c
16
client.c
|
@ -191,6 +191,11 @@ client_updatetitle(client_t *c)
|
||||||
|
|
||||||
p_delete(&c->name);
|
p_delete(&c->name);
|
||||||
c->name = name;
|
c->name = name;
|
||||||
|
|
||||||
|
/* call hook */
|
||||||
|
luaA_client_userdata_new(c);
|
||||||
|
luaA_dofunction(globalconf.L, globalconf.hooks.titleupdate, 1);
|
||||||
|
|
||||||
titlebar_draw(c);
|
titlebar_draw(c);
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
}
|
}
|
||||||
|
@ -1102,6 +1107,16 @@ luaA_client_name_get(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
luaA_client_name_set(lua_State *L)
|
||||||
|
{
|
||||||
|
client_t **c = luaL_checkudata(L, 1, "client");
|
||||||
|
const char *name = luaL_checkstring(L, 2);
|
||||||
|
p_delete(&(*c)->name);
|
||||||
|
(*c)->name = a_strdup(name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
luaA_client_userdata_new(client_t *c)
|
luaA_client_userdata_new(client_t *c)
|
||||||
{
|
{
|
||||||
|
@ -1121,6 +1136,7 @@ const struct luaL_reg awesome_client_methods[] =
|
||||||
const struct luaL_reg awesome_client_meta[] =
|
const struct luaL_reg awesome_client_meta[] =
|
||||||
{
|
{
|
||||||
{ "name_get", luaA_client_name_get },
|
{ "name_get", luaA_client_name_get },
|
||||||
|
{ "name_set", luaA_client_name_set },
|
||||||
{ "titlebar_set", luaA_client_titlebar_set },
|
{ "titlebar_set", luaA_client_titlebar_set },
|
||||||
{ "screen_set", luaA_client_screen_set },
|
{ "screen_set", luaA_client_screen_set },
|
||||||
{ "screen_get", luaA_client_screen_get },
|
{ "screen_get", luaA_client_screen_get },
|
||||||
|
|
11
lua.c
11
lua.c
|
@ -267,6 +267,16 @@ luaA_hooks_arrange(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
luaA_hooks_titleupdate(lua_State *L)
|
||||||
|
{
|
||||||
|
luaA_checkfunction(L, 1);
|
||||||
|
if(globalconf.hooks.titleupdate)
|
||||||
|
luaL_unref(L, LUA_REGISTRYINDEX, globalconf.hooks.titleupdate);
|
||||||
|
globalconf.hooks.titleupdate = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
luaA_openlib(lua_State *L, const char *name,
|
luaA_openlib(lua_State *L, const char *name,
|
||||||
const struct luaL_reg methods[],
|
const struct luaL_reg methods[],
|
||||||
|
@ -335,6 +345,7 @@ luaA_parserc(const char *rcfile)
|
||||||
{ "newclient", luaA_hooks_newclient },
|
{ "newclient", luaA_hooks_newclient },
|
||||||
{ "mouseover", luaA_hooks_mouseover },
|
{ "mouseover", luaA_hooks_mouseover },
|
||||||
{ "arrange", luaA_hooks_arrange },
|
{ "arrange", luaA_hooks_arrange },
|
||||||
|
{ "titleupdate", luaA_hooks_titleupdate },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -418,6 +418,8 @@ struct awesome_t
|
||||||
luaA_function mouseover;
|
luaA_function mouseover;
|
||||||
/** Command to run on arrange */
|
/** Command to run on arrange */
|
||||||
luaA_function arrange;
|
luaA_function arrange;
|
||||||
|
/** Command to run on title change */
|
||||||
|
luaA_function titleupdate;
|
||||||
} hooks;
|
} hooks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue