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)
|
luaA_client_titlebar_set(lua_State *L)
|
||||||
{
|
{
|
||||||
client_t **c = luaA_checkudata(L, 1, "client");
|
client_t **c = luaA_checkudata(L, 1, "client");
|
||||||
titlebar_t **t = luaA_checkudata(L, 2, "titlebar");
|
titlebar_t **t = NULL;
|
||||||
|
|
||||||
if(client_getbytitlebar(*t))
|
if(lua_gettop(L) == 2)
|
||||||
luaL_error(L, "titlebar is already used by another client");
|
{
|
||||||
|
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 client had a titlebar, unref it */
|
||||||
if((*c)->titlebar)
|
if((*c)->titlebar)
|
||||||
|
{
|
||||||
titlebar_unref(&(*c)->titlebar);
|
titlebar_unref(&(*c)->titlebar);
|
||||||
|
simplewindow_delete(&(*c)->titlebar->sw);
|
||||||
|
}
|
||||||
|
|
||||||
/* Attach titlebar to client */
|
if(t)
|
||||||
(*c)->titlebar = *t;
|
{
|
||||||
titlebar_ref(t);
|
/* Attach titlebar to client */
|
||||||
titlebar_init(*c);
|
(*c)->titlebar = *t;
|
||||||
|
titlebar_ref(t);
|
||||||
|
titlebar_init(*c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
(*c)->titlebar = NULL;
|
||||||
|
|
||||||
if((*c)->isfloating || layout_get_current((*c)->screen) == layout_floating)
|
if((*c)->isfloating || layout_get_current((*c)->screen) == layout_floating)
|
||||||
titlebar_update_geometry_floating(*c);
|
titlebar_update_geometry_floating(*c);
|
||||||
|
|
|
@ -368,8 +368,6 @@ titlebar_init(client_t *c)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
c->titlebar->position = Off;
|
c->titlebar->position = Off;
|
||||||
if(c->titlebar->sw)
|
|
||||||
xcb_unmap_window(globalconf.connection, c->titlebar->sw->window);
|
|
||||||
return;
|
return;
|
||||||
case Top:
|
case Top:
|
||||||
case Bottom:
|
case Bottom:
|
||||||
|
@ -389,12 +387,9 @@ titlebar_init(client_t *c)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete old statusbar */
|
|
||||||
simplewindow_delete(&c->titlebar->sw);
|
|
||||||
|
|
||||||
c->titlebar->sw = simplewindow_new(globalconf.connection,
|
c->titlebar->sw = simplewindow_new(globalconf.connection,
|
||||||
c->phys_screen, 0, 0,
|
c->phys_screen, 0, 0,
|
||||||
width, height, 0);
|
width, height, 0);
|
||||||
titlebar_draw(c);
|
titlebar_draw(c);
|
||||||
xcb_map_window(globalconf.connection, c->titlebar->sw->window);
|
xcb_map_window(globalconf.connection, c->titlebar->sw->window);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue