Turn a wibox' bg_image into a cairo surface
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
6dfaa0fd76
commit
8fbffcd2fb
|
@ -83,6 +83,8 @@ wibox_wipe(wibox_t *wibox)
|
|||
p_delete(&wibox->cursor);
|
||||
wibox_wipe_resources(wibox);
|
||||
widget_node_array_wipe(&wibox->widgets);
|
||||
if(wibox->bg_image)
|
||||
cairo_surface_destroy(wibox->bg_image);
|
||||
}
|
||||
|
||||
/** Wipe an array of widget_node. Release references to widgets.
|
||||
|
@ -938,11 +940,19 @@ luaA_wibox_get_bg(lua_State *L, wibox_t *wibox)
|
|||
static int
|
||||
luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
|
||||
{
|
||||
luaA_checkudata(L, -1, &image_class);
|
||||
luaA_object_unref_item(L, -3, wibox->bg_image);
|
||||
wibox->bg_image = luaA_object_ref_item(L, -3, -1);
|
||||
if(lua_isnil(L, -1))
|
||||
{
|
||||
if(wibox->bg_image)
|
||||
cairo_surface_destroy(wibox->bg_image);
|
||||
wibox->bg_image = NULL;
|
||||
} else {
|
||||
cairo_surface_t *surface = luaA_image_to_surface(L, -1);
|
||||
if(wibox->bg_image)
|
||||
cairo_surface_destroy(wibox->bg_image);
|
||||
wibox->bg_image = surface;
|
||||
}
|
||||
wibox->need_update = true;
|
||||
luaA_object_emit_signal(L, -2, "property::bg_image", 0);
|
||||
luaA_object_emit_signal(L, -3, "property::bg_image", 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -954,7 +964,9 @@ luaA_wibox_set_bg_image(lua_State *L, wibox_t *wibox)
|
|||
static int
|
||||
luaA_wibox_get_bg_image(lua_State *L, wibox_t *wibox)
|
||||
{
|
||||
return luaA_object_push_item(L, 1, wibox->bg_image);
|
||||
if(wibox->bg_image)
|
||||
return oocairo_surface_push(L, wibox->bg_image);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Set the wibox on top status.
|
||||
|
|
|
@ -44,7 +44,7 @@ struct wibox_t
|
|||
/** Cursor */
|
||||
char *cursor;
|
||||
/** Background image */
|
||||
image_t *bg_image;
|
||||
cairo_surface_t *bg_image;
|
||||
/** The pixmap copied to the window object. */
|
||||
xcb_pixmap_t pixmap;
|
||||
/** The window geometry. */
|
||||
|
|
|
@ -332,7 +332,7 @@ widget_render(wibox_t *wibox)
|
|||
|
||||
/* 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_surface(ctx, 0, 0, 1.0, wibox->bg_image);
|
||||
|
||||
/* draw background color */
|
||||
xcolor_to_color(&ctx->bg, &col);
|
||||
|
|
Loading…
Reference in New Issue