diff --git a/draw.c b/draw.c index 0c83b965..1a0e4d8f 100644 --- a/draw.c +++ b/draw.c @@ -239,7 +239,7 @@ draw_load_image(lua_State *L, const char *path) return ret; } -xcb_visualtype_t *draw_default_visual(const xcb_screen_t *s) +xcb_visualtype_t *draw_find_visual(const xcb_screen_t *s, xcb_visualid_t visual) { xcb_depth_iterator_t depth_iter = xcb_screen_allowed_depths_iterator(s); @@ -247,12 +247,17 @@ xcb_visualtype_t *draw_default_visual(const xcb_screen_t *s) for(; depth_iter.rem; xcb_depth_next (&depth_iter)) for(xcb_visualtype_iterator_t visual_iter = xcb_depth_visuals_iterator(depth_iter.data); visual_iter.rem; xcb_visualtype_next (&visual_iter)) - if(s->root_visual == visual_iter.data->visual_id) + if(visual == visual_iter.data->visual_id) return visual_iter.data; return NULL; } +xcb_visualtype_t *draw_default_visual(const xcb_screen_t *s) +{ + return draw_find_visual(s, s->root_visual); +} + xcb_visualtype_t *draw_argb_visual(const xcb_screen_t *s) { xcb_depth_iterator_t depth_iter = xcb_screen_allowed_depths_iterator(s); diff --git a/draw.h b/draw.h index 4a2199ac..1bbf1cc7 100644 --- a/draw.h +++ b/draw.h @@ -70,6 +70,7 @@ cairo_surface_t *draw_surface_from_data(int width, int height, uint32_t *data); cairo_surface_t *draw_dup_image_surface(cairo_surface_t *surface); cairo_surface_t *draw_load_image(lua_State *L, const char *path); +xcb_visualtype_t *draw_find_visual(const xcb_screen_t *s, xcb_visualid_t visual); xcb_visualtype_t *draw_default_visual(const xcb_screen_t *s); xcb_visualtype_t *draw_argb_visual(const xcb_screen_t *s); uint8_t draw_visual_depth(const xcb_screen_t *s, xcb_visualid_t vis);