mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
[titlebar] Allow nil to be arg of titlebar_set()
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
e9bfdcf681
commit
88c76cadf4
2 changed files with 22 additions and 15 deletions
28
client.c
28
client.c
|
@ -1286,19 +1286,31 @@ static int
|
|||
luaA_client_titlebar_set(lua_State *L)
|
||||
{
|
||||
client_t **c = luaA_checkudata(L, 1, "client");
|
||||
titlebar_t **t = luaA_checkudata(L, 2, "titlebar");
|
||||
|
||||
if(client_getbytitlebar(*t))
|
||||
luaL_error(L, "titlebar is already used by another client");
|
||||
titlebar_t **t = NULL;
|
||||
|
||||
if(lua_gettop(L) == 2)
|
||||
{
|
||||
t = luaA_checkudata(L, 2, "titlebar");
|
||||
if(client_getbytitlebar(*t))
|
||||
luaL_error(L, "titlebar is already used by another client");
|
||||
}
|
||||
|
||||
/* If client had a titlebar, unref it */
|
||||
if((*c)->titlebar)
|
||||
{
|
||||
titlebar_unref(&(*c)->titlebar);
|
||||
simplewindow_delete(&(*c)->titlebar->sw);
|
||||
}
|
||||
|
||||
/* Attach titlebar to client */
|
||||
(*c)->titlebar = *t;
|
||||
titlebar_ref(t);
|
||||
titlebar_init(*c);
|
||||
if(t)
|
||||
{
|
||||
/* Attach titlebar to client */
|
||||
(*c)->titlebar = *t;
|
||||
titlebar_ref(t);
|
||||
titlebar_init(*c);
|
||||
}
|
||||
else
|
||||
(*c)->titlebar = NULL;
|
||||
|
||||
if((*c)->isfloating || layout_get_current((*c)->screen) == layout_floating)
|
||||
titlebar_update_geometry_floating(*c);
|
||||
|
|
|
@ -368,8 +368,6 @@ titlebar_init(client_t *c)
|
|||
{
|
||||
default:
|
||||
c->titlebar->position = Off;
|
||||
if(c->titlebar->sw)
|
||||
xcb_unmap_window(globalconf.connection, c->titlebar->sw->window);
|
||||
return;
|
||||
case Top:
|
||||
case Bottom:
|
||||
|
@ -389,12 +387,9 @@ titlebar_init(client_t *c)
|
|||
break;
|
||||
}
|
||||
|
||||
/* Delete old statusbar */
|
||||
simplewindow_delete(&c->titlebar->sw);
|
||||
|
||||
c->titlebar->sw = simplewindow_new(globalconf.connection,
|
||||
c->phys_screen, 0, 0,
|
||||
width, height, 0);
|
||||
c->phys_screen, 0, 0,
|
||||
width, height, 0);
|
||||
titlebar_draw(c);
|
||||
xcb_map_window(globalconf.connection, c->titlebar->sw->window);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue