drawable: Add property::surface
This new property is used for fixing some missing redraws that the old code had. Those could be seen via awful.menu. Open and close a submenu repeatedly and the submenu will appear black. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
1115457ac8
commit
1e418cbe3b
|
@ -201,10 +201,7 @@ function drawable.new(d, widget_arg)
|
|||
end
|
||||
end
|
||||
capi.awesome.connect_signal("wallpaper_changed", ret.draw)
|
||||
d:connect_signal("property::x", ret.draw)
|
||||
d:connect_signal("property::y", ret.draw)
|
||||
d:connect_signal("property::width", ret.draw)
|
||||
d:connect_signal("property::height", ret.draw)
|
||||
d:connect_signal("property::surface", ret.draw)
|
||||
|
||||
-- Set the default background
|
||||
ret:set_bg(beautiful.bg_normal)
|
||||
|
|
|
@ -646,7 +646,8 @@ client_resize_do(client_t *c, area_t geometry)
|
|||
drawable_t *drawable = titlebar_get_drawable(globalconf.L, c, -1, bar);
|
||||
|
||||
/* Get rid of the old state */
|
||||
drawable_set_surface(drawable, NULL);
|
||||
luaA_object_push_item(globalconf.L, -1, drawable);
|
||||
drawable_set_surface(drawable, -1, NULL);
|
||||
if (c->titlebar[bar].pixmap != XCB_NONE)
|
||||
xcb_free_pixmap(globalconf.connection, c->titlebar[bar].pixmap);
|
||||
|
||||
|
@ -660,13 +661,12 @@ client_resize_do(client_t *c, area_t geometry)
|
|||
cairo_surface_t *surface = cairo_xcb_surface_create(globalconf.connection,
|
||||
c->titlebar[bar].pixmap, globalconf.visual,
|
||||
area.width, area.height);
|
||||
drawable_set_surface(drawable, surface);
|
||||
drawable_set_surface(drawable, -1, surface);
|
||||
}
|
||||
|
||||
/* Convert to global coordinates */
|
||||
area.x += geometry.x;
|
||||
area.y += geometry.y;
|
||||
luaA_object_push_item(globalconf.L, -1, drawable);
|
||||
drawable_set_geometry(drawable, -1, area);
|
||||
|
||||
/* Pop the client and the drawable */
|
||||
|
@ -1361,7 +1361,7 @@ titlebar_get_drawable(lua_State *L, client_t *c, int cl_idx, client_titlebar_t b
|
|||
if (c->titlebar[bar].drawable == NULL)
|
||||
{
|
||||
cl_idx = luaA_absindex(L, cl_idx);
|
||||
drawable_allocator(L, NULL, (drawable_refresh_callback *) client_refresh, c);
|
||||
drawable_allocator(L, (drawable_refresh_callback *) client_refresh, c);
|
||||
c->titlebar[bar].drawable = luaA_object_ref_item(L, cl_idx, -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,23 +29,26 @@ static lua_class_t drawable_class;
|
|||
LUA_OBJECT_FUNCS(drawable_class, drawable_t, drawable)
|
||||
|
||||
drawable_t *
|
||||
drawable_allocator(lua_State *L, cairo_surface_t *surface, drawable_refresh_callback *callback, void *data)
|
||||
drawable_allocator(lua_State *L, drawable_refresh_callback *callback, void *data)
|
||||
{
|
||||
drawable_t *d = drawable_new(L);
|
||||
d->refresh_callback = callback;
|
||||
d->refresh_data = data;
|
||||
drawable_set_surface(d, surface);
|
||||
d->surface = NULL;
|
||||
return d;
|
||||
}
|
||||
|
||||
static void
|
||||
drawable_wipe(drawable_t *d)
|
||||
{
|
||||
drawable_set_surface(d, NULL);
|
||||
if (!d->surface)
|
||||
return;
|
||||
cairo_surface_finish(d->surface);
|
||||
cairo_surface_destroy(d->surface);
|
||||
}
|
||||
|
||||
void
|
||||
drawable_set_surface(drawable_t *d, cairo_surface_t *surface)
|
||||
drawable_set_surface(drawable_t *d, int didx, cairo_surface_t *surface)
|
||||
{
|
||||
if (d->surface) {
|
||||
cairo_surface_finish(d->surface);
|
||||
|
@ -54,13 +57,14 @@ drawable_set_surface(drawable_t *d, cairo_surface_t *surface)
|
|||
|
||||
d->surface = cairo_surface_reference(surface);
|
||||
|
||||
if (d->surface != NULL)
|
||||
if (d->surface)
|
||||
{
|
||||
/* Make sure the surface doesn't contain garbage by filling it with black */
|
||||
cairo_t *cr = cairo_create(surface);
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
|
||||
cairo_paint(cr);
|
||||
cairo_destroy(cr);
|
||||
luaA_object_emit_signal(globalconf.L, didx, "property::surface", 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,6 +161,7 @@ drawable_class_setup(lua_State *L)
|
|||
signal_add(&drawable_class.signals, "property::width");
|
||||
signal_add(&drawable_class.signals, "property::x");
|
||||
signal_add(&drawable_class.signals, "property::y");
|
||||
signal_add(&drawable_class.signals, "property::surface");
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -42,9 +42,8 @@ struct drawable_t
|
|||
void *refresh_data;
|
||||
};
|
||||
|
||||
drawable_t *drawable_allocator(lua_State *, cairo_surface_t *,
|
||||
drawable_refresh_callback *, void *);
|
||||
void drawable_set_surface(drawable_t *, cairo_surface_t *);
|
||||
drawable_t *drawable_allocator(lua_State *, drawable_refresh_callback *, void *);
|
||||
void drawable_set_surface(drawable_t *, int, cairo_surface_t *);
|
||||
void drawable_set_geometry(drawable_t *, int, area_t);
|
||||
void drawable_class_setup(lua_State *);
|
||||
|
||||
|
|
|
@ -96,7 +96,8 @@ drawin_update_drawing(drawin_t *w, int widx)
|
|||
if(!w->visible)
|
||||
return;
|
||||
/* Clean up old stuff */
|
||||
drawable_set_surface(w->drawable, NULL);
|
||||
luaA_object_push_item(globalconf.L, widx, w->drawable);
|
||||
drawable_set_surface(w->drawable, -1, NULL);
|
||||
if(w->pixmap)
|
||||
xcb_free_pixmap(globalconf.connection, w->pixmap);
|
||||
|
||||
|
@ -109,9 +110,7 @@ drawin_update_drawing(drawin_t *w, int widx)
|
|||
cairo_surface_t *surface = cairo_xcb_surface_create(globalconf.connection,
|
||||
w->pixmap, globalconf.visual,
|
||||
w->geometry.width, w->geometry.height);
|
||||
drawable_set_surface(w->drawable, surface);
|
||||
|
||||
luaA_object_push_item(globalconf.L, widx, w->drawable);
|
||||
drawable_set_surface(w->drawable, -1, surface);
|
||||
drawable_set_geometry(w->drawable, -1, w->geometry);
|
||||
lua_pop(globalconf.L, 1);
|
||||
}
|
||||
|
@ -337,7 +336,7 @@ drawin_allocator(lua_State *L)
|
|||
w->geometry.height = 1;
|
||||
w->type = _NET_WM_WINDOW_TYPE_NORMAL;
|
||||
|
||||
drawable_allocator(L, NULL, (drawable_refresh_callback *) drawin_refresh_pixmap, w);
|
||||
drawable_allocator(L, (drawable_refresh_callback *) drawin_refresh_pixmap, w);
|
||||
w->drawable = luaA_object_ref_item(L, -2, -1);
|
||||
|
||||
drawin_init(w);
|
||||
|
|
Loading…
Reference in New Issue