root.wallpaper: Cleanup and correctness fixes
Turns out that my rant about "we can't query the pixmap's values" was wrong. This commit makes awesome use a GetGeometry request to get the properties of the (old) root window's back pixmap. This also converts code to p_delete() instead of free() for consistency. Bad me for doing multiple things in one commit... Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
20afb26080
commit
069a8e84a2
30
root.c
30
root.c
|
@ -63,7 +63,7 @@ root_set_wallpaper_pixmap(xcb_connection_t *c, xcb_pixmap_t p)
|
||||||
if (rootpix)
|
if (rootpix)
|
||||||
xcb_kill_client(c, *rootpix);
|
xcb_kill_client(c, *rootpix);
|
||||||
}
|
}
|
||||||
free(prop_r);
|
p_delete(&prop_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -347,6 +347,8 @@ luaA_root_wallpaper(lua_State *L)
|
||||||
{
|
{
|
||||||
xcb_get_property_cookie_t prop_c;
|
xcb_get_property_cookie_t prop_c;
|
||||||
xcb_get_property_reply_t *prop_r;
|
xcb_get_property_reply_t *prop_r;
|
||||||
|
xcb_get_geometry_cookie_t geom_c;
|
||||||
|
xcb_get_geometry_reply_t *geom_r;
|
||||||
xcb_pixmap_t *rootpix;
|
xcb_pixmap_t *rootpix;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
|
||||||
|
@ -364,27 +366,37 @@ luaA_root_wallpaper(lua_State *L)
|
||||||
|
|
||||||
if (!prop_r || !prop_r->value_len)
|
if (!prop_r || !prop_r->value_len)
|
||||||
{
|
{
|
||||||
free(prop_r);
|
p_delete(&prop_r);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rootpix = xcb_get_property_value(prop_r);
|
rootpix = xcb_get_property_value(prop_r);
|
||||||
if (!rootpix)
|
if (!rootpix)
|
||||||
{
|
{
|
||||||
free(prop_r);
|
p_delete(&prop_r);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We can't query the pixmap's values (or even if that pixmap exists at
|
geom_c = xcb_get_geometry_unchecked(globalconf.connection, *rootpix);
|
||||||
* all), so let's just assume that it uses the default visual and is as
|
geom_r = xcb_get_geometry_reply(globalconf.connection, geom_c, NULL);
|
||||||
* large as the root window. Everything else wouldn't make sense.
|
if (!geom_r)
|
||||||
*/
|
{
|
||||||
|
p_delete(&prop_r);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Only the default visual makes sense, so just the default depth */
|
||||||
|
if (geom_r->depth != draw_visual_depth(globalconf.screen, globalconf.default_visual->visual_id))
|
||||||
|
warn("Got a pixmap with depth %d, but the default depth is %d, continuing anyway",
|
||||||
|
geom_r->depth, draw_visual_depth(globalconf.screen, globalconf.default_visual->visual_id));
|
||||||
|
|
||||||
surface = cairo_xcb_surface_create(globalconf.connection, *rootpix, globalconf.default_visual,
|
surface = cairo_xcb_surface_create(globalconf.connection, *rootpix, globalconf.default_visual,
|
||||||
globalconf.screen->width_in_pixels, globalconf.screen->height_in_pixels);
|
geom_r->width, geom_r->height);
|
||||||
|
|
||||||
/* lua has to make sure this surface gets destroyed */
|
/* lua has to make sure this surface gets destroyed */
|
||||||
lua_pushlightuserdata(L, surface);
|
lua_pushlightuserdata(L, surface);
|
||||||
free(prop_r);
|
p_delete(&prop_r);
|
||||||
|
p_delete(&geom_r);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue