titlebar: fix position init

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-23 20:37:31 +02:00
parent 242c0b5a91
commit c1e1083e63
1 changed files with 10 additions and 9 deletions

View File

@ -297,7 +297,7 @@ static int
luaA_titlebar_new(lua_State *L) luaA_titlebar_new(lua_State *L)
{ {
titlebar_t *tb; titlebar_t *tb;
const char *color; const char *buf;
size_t len; size_t len;
luaA_checktable(L, 1); luaA_checktable(L, 1);
@ -312,23 +312,24 @@ luaA_titlebar_new(lua_State *L)
/* 1.5 as default factor, it fits nice but no one knows why */ /* 1.5 as default factor, it fits nice but no one knows why */
tb->height = 1.5 * globalconf.font->height; tb->height = 1.5 * globalconf.font->height;
tb->position = position_fromstr(luaA_getopt_string(L, 1, "position", "top", &len), len); buf = luaA_getopt_string(L, 1, "position", "top", &len);
tb->position = position_fromstr(buf, len);
if((color = luaA_getopt_string(L, -1, "fg", NULL, NULL))) if((buf = luaA_getopt_string(L, -1, "fg", NULL, NULL)))
xcolor_new(globalconf.connection, globalconf.default_screen, xcolor_new(globalconf.connection, globalconf.default_screen,
color, &tb->colors.fg); buf, &tb->colors.fg);
else else
tb->colors.fg = globalconf.colors.fg; tb->colors.fg = globalconf.colors.fg;
if((color = luaA_getopt_string(L, 1, "bg", NULL, NULL))) if((buf = luaA_getopt_string(L, 1, "bg", NULL, NULL)))
xcolor_new(globalconf.connection, globalconf.default_screen, xcolor_new(globalconf.connection, globalconf.default_screen,
color, &tb->colors.bg); buf, &tb->colors.bg);
else else
tb->colors.bg = globalconf.colors.bg; tb->colors.bg = globalconf.colors.bg;
if((color = luaA_getopt_string(L, 1, "border_color", NULL, NULL))) if((buf = luaA_getopt_string(L, 1, "border_color", NULL, NULL)))
xcolor_new(globalconf.connection, globalconf.default_screen, xcolor_new(globalconf.connection, globalconf.default_screen,
color, &tb->border.color); buf, &tb->border.color);
tb->border.width = luaA_getopt_number(L, 1, "border_width", 0); tb->border.width = luaA_getopt_number(L, 1, "border_width", 0);