From bb304c80a35ecd92e42ead3f4632e4701e211c1a Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 16 Sep 2013 11:59:00 +0200 Subject: [PATCH] draw: Add function for finding a visual by id Signed-off-by: Uli Schlachter --- draw.c | 9 +++++++-- draw.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/draw.c b/draw.c index 0c83b9658..1a0e4d8f9 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 4a2199acb..1bbf1cc7a 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);