Convert a client's icon to a cairo surface
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
8fbffcd2fb
commit
146a5dd67c
2
ewmh.c
2
ewmh.c
|
@ -657,7 +657,7 @@ ewmh_window_icon_from_reply(xcb_get_property_reply_t *r)
|
|||
if (!data[0] || !data[1] || len > r->length - 2)
|
||||
return 0;
|
||||
|
||||
return image_new_from_argb32(globalconf.L, data[0], data[1], data + 2);
|
||||
return luaA_surface_from_data(globalconf.L, data[0], data[1], data + 2);
|
||||
}
|
||||
|
||||
/** Get NET_WM_ICON.
|
||||
|
|
|
@ -50,6 +50,8 @@ client_wipe(client_t *c)
|
|||
p_delete(&c->alt_icon_name);
|
||||
p_delete(&c->name);
|
||||
p_delete(&c->alt_name);
|
||||
if(c->icon)
|
||||
cairo_surface_destroy(c->icon);
|
||||
}
|
||||
|
||||
/** Change the clients urgency flag.
|
||||
|
@ -1092,12 +1094,17 @@ void
|
|||
client_set_icon(lua_State *L, int cidx, int iidx)
|
||||
{
|
||||
client_t *c = luaA_checkudata(L, cidx, &client_class);
|
||||
/* convert index to absolute */
|
||||
cidx = luaA_absindex(L, cidx);
|
||||
iidx = luaA_absindex(L, iidx);
|
||||
luaA_checkudata(L, iidx, &image_class);
|
||||
luaA_object_unref_item(L, cidx, c->icon);
|
||||
c->icon = luaA_object_ref_item(L, cidx, iidx);
|
||||
if(lua_isnil(L, iidx))
|
||||
{
|
||||
if(c->icon)
|
||||
cairo_surface_destroy(c->icon);
|
||||
c->icon = NULL;
|
||||
} else {
|
||||
cairo_surface_t *surface = luaA_image_to_surface(L, iidx);
|
||||
if(c->icon)
|
||||
cairo_surface_destroy(c->icon);
|
||||
c->icon = surface;
|
||||
}
|
||||
luaA_object_emit_signal(L, cidx < iidx ? cidx : cidx - 1, "property::icon", 0);
|
||||
}
|
||||
|
||||
|
@ -1464,7 +1471,9 @@ luaA_client_get_screen(lua_State *L, client_t *c)
|
|||
static int
|
||||
luaA_client_get_icon(lua_State *L, client_t *c)
|
||||
{
|
||||
return luaA_object_push_item(L, -2, c->icon);
|
||||
if(c->icon)
|
||||
return oocairo_surface_push(L, c->icon);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -87,7 +87,7 @@ struct client_t
|
|||
/** Key bindings */
|
||||
key_array_t keys;
|
||||
/** Icon */
|
||||
image_t *icon;
|
||||
cairo_surface_t *icon;
|
||||
/** Size hints */
|
||||
xcb_size_hints_t size_hints;
|
||||
bool size_hints_honor;
|
||||
|
|
Loading…
Reference in New Issue