wibox: add support for background image (FS#464)
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
e56f8f30d0
commit
cc54c32c5f
|
@ -108,6 +108,8 @@ typedef struct
|
||||||
bool need_update;
|
bool need_update;
|
||||||
/** Cursor */
|
/** Cursor */
|
||||||
char *cursor;
|
char *cursor;
|
||||||
|
/** Background image */
|
||||||
|
image_t *bg_image;
|
||||||
/** Button bindings */
|
/** Button bindings */
|
||||||
button_array_t buttons;
|
button_array_t buttons;
|
||||||
} wibox_t;
|
} wibox_t;
|
||||||
|
|
23
wibox.c
23
wibox.c
|
@ -861,6 +861,12 @@ luaA_wibox_index(lua_State *L)
|
||||||
case A_TK_BG:
|
case A_TK_BG:
|
||||||
luaA_pushcolor(L, &(*wibox)->sw.ctx.bg);
|
luaA_pushcolor(L, &(*wibox)->sw.ctx.bg);
|
||||||
break;
|
break;
|
||||||
|
case A_TK_BG_IMAGE:
|
||||||
|
if((*wibox)->bg_image)
|
||||||
|
luaA_image_userdata_new(L, (*wibox)->bg_image);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
case A_TK_POSITION:
|
case A_TK_POSITION:
|
||||||
lua_pushstring(L, position_tostr((*wibox)->position));
|
lua_pushstring(L, position_tostr((*wibox)->position));
|
||||||
break;
|
break;
|
||||||
|
@ -976,6 +982,23 @@ luaA_wibox_newindex(lua_State *L)
|
||||||
if(xcolor_init_reply(xcolor_init_unchecked(&(*wibox)->sw.ctx.bg, buf, len)))
|
if(xcolor_init_reply(xcolor_init_unchecked(&(*wibox)->sw.ctx.bg, buf, len)))
|
||||||
(*wibox)->need_update = true;
|
(*wibox)->need_update = true;
|
||||||
break;
|
break;
|
||||||
|
case A_TK_BG_IMAGE:
|
||||||
|
{
|
||||||
|
if(lua_isnil(L, 3))
|
||||||
|
{
|
||||||
|
image_unref(&(*wibox)->bg_image);
|
||||||
|
(*wibox)->bg_image = NULL;
|
||||||
|
(*wibox)->need_update = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
image_t **img = luaA_checkudata(L, 3, "image");
|
||||||
|
image_unref(&(*wibox)->bg_image);
|
||||||
|
(*wibox)->bg_image = image_ref(img);
|
||||||
|
(*wibox)->need_update = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case A_TK_ALIGN:
|
case A_TK_ALIGN:
|
||||||
buf = luaL_checklstring(L, 3, &len);
|
buf = luaL_checklstring(L, 3, &len);
|
||||||
(*wibox)->align = draw_align_fromstr(buf, len);
|
(*wibox)->align = draw_align_fromstr(buf, len);
|
||||||
|
|
7
widget.c
7
widget.c
|
@ -270,9 +270,14 @@ widget_render(wibox_t *wibox)
|
||||||
left += widgets->tab[i].geometry.width;
|
left += widgets->tab[i].geometry.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw everything! */
|
/* draw background image, only if the background color is not opaque */
|
||||||
|
if(wibox->bg_image && ctx->bg.alpha != 0xffff)
|
||||||
|
draw_image(ctx, 0, 0, 1.0, wibox->bg_image);
|
||||||
|
|
||||||
|
/* draw background color */
|
||||||
draw_rectangle(ctx, rectangle, 1.0, true, &ctx->bg);
|
draw_rectangle(ctx, rectangle, 1.0, true, &ctx->bg);
|
||||||
|
|
||||||
|
/* draw everything! */
|
||||||
for(int i = 0; i < widgets->len; i++)
|
for(int i = 0; i < widgets->len; i++)
|
||||||
if(widgets->tab[i].widget->isvisible)
|
if(widgets->tab[i].widget->isvisible)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue