[titlebar] Add titlebar_client_get()
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
2742318f16
commit
eb8378749b
7
client.c
7
client.c
|
@ -1131,12 +1131,11 @@ luaA_client_name_set(lua_State *L)
|
||||||
static int
|
static int
|
||||||
luaA_client_titlebar_set(lua_State *L)
|
luaA_client_titlebar_set(lua_State *L)
|
||||||
{
|
{
|
||||||
client_t *cl, **c = luaL_checkudata(L, 1, "client");
|
client_t **c = luaL_checkudata(L, 1, "client");
|
||||||
titlebar_t **t = luaL_checkudata(L, 2, "titlebar");
|
titlebar_t **t = luaL_checkudata(L, 2, "titlebar");
|
||||||
|
|
||||||
for(cl = globalconf.clients; cl; cl = cl->next)
|
if(client_getbytitlebar(*t))
|
||||||
if(cl->titlebar == *t)
|
luaL_error(L, "titlebar is already used by another client");
|
||||||
luaL_error(L, "titlebar is already used by another client");
|
|
||||||
|
|
||||||
/* If client had a titlebar, unref it */
|
/* If client had a titlebar, unref it */
|
||||||
if((*c)->titlebar)
|
if((*c)->titlebar)
|
||||||
|
|
35
titlebar.c
35
titlebar.c
|
@ -32,8 +32,24 @@
|
||||||
|
|
||||||
extern awesome_t globalconf;
|
extern awesome_t globalconf;
|
||||||
|
|
||||||
|
/** Get a client by its titlebar.
|
||||||
|
* \param titlebar The titlebar.
|
||||||
|
* \return A client.
|
||||||
|
*/
|
||||||
|
client_t *
|
||||||
|
client_getbytitlebar(titlebar_t *titlebar)
|
||||||
|
{
|
||||||
|
client_t *c;
|
||||||
|
|
||||||
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
|
if(c->titlebar == titlebar)
|
||||||
|
return c;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get a client by its titlebar window.
|
/** Get a client by its titlebar window.
|
||||||
* \param The window.
|
* \param win The window.
|
||||||
* \return A client.
|
* \return A client.
|
||||||
*/
|
*/
|
||||||
client_t *
|
client_t *
|
||||||
|
@ -478,6 +494,22 @@ luaA_titlebar_widget_get(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the client which the titlebar is attached to. That is a the same as
|
||||||
|
* checking if every clients's titlebar is equal to titlebar.
|
||||||
|
* \return A client if the titlebar is attached, nil otherwise.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_titlebar_client_get(lua_State *L)
|
||||||
|
{
|
||||||
|
titlebar_t **titlebar = luaL_checkudata(L, 1, "titlebar");
|
||||||
|
client_t *c;
|
||||||
|
|
||||||
|
if((c = client_getbytitlebar(*titlebar)))
|
||||||
|
return luaA_client_userdata_new(c);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Create a new titlebar userdata.
|
/** Create a new titlebar userdata.
|
||||||
* \param t The titlebar.
|
* \param t The titlebar.
|
||||||
*/
|
*/
|
||||||
|
@ -524,6 +556,7 @@ const struct luaL_reg awesome_titlebar_meta[] =
|
||||||
{
|
{
|
||||||
{ "widget_add", luaA_titlebar_widget_add },
|
{ "widget_add", luaA_titlebar_widget_add },
|
||||||
{ "widget_get", luaA_titlebar_widget_get },
|
{ "widget_get", luaA_titlebar_widget_get },
|
||||||
|
{ "client_get", luaA_titlebar_client_get },
|
||||||
{ "__eq", luaA_titlebar_eq },
|
{ "__eq", luaA_titlebar_eq },
|
||||||
{ "__gc", luaA_titlebar_gc },
|
{ "__gc", luaA_titlebar_gc },
|
||||||
{ "__tostring", luaA_titlebar_tostring },
|
{ "__tostring", luaA_titlebar_tostring },
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
|
client_t * client_getbytitlebar(titlebar_t *);
|
||||||
client_t * client_getbytitlebarwin(xcb_window_t);
|
client_t * client_getbytitlebarwin(xcb_window_t);
|
||||||
void titlebar_draw(client_t *);
|
void titlebar_draw(client_t *);
|
||||||
void titlebar_update_geometry_floating(client_t *);
|
void titlebar_update_geometry_floating(client_t *);
|
||||||
|
|
Loading…
Reference in New Issue