From 1f65d888580d26996b181121b60670f1023fa950 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Wed, 19 Aug 2020 19:22:17 +0100 Subject: [PATCH] x: add more picture helper functions Signed-off-by: Yuxuan Shui --- src/x.c | 20 ++++++++++++++++++++ src/x.h | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/src/x.c b/src/x.c index 0d97ff5d..42726675 100644 --- a/src/x.c +++ b/src/x.c @@ -168,6 +168,15 @@ xcb_visualid_t x_get_visual_for_standard(xcb_connection_t *c, xcb_pict_standard_ return x_get_visual_for_pictfmt(g_pictfmts, pictfmt->id); } +xcb_render_pictformat_t +x_get_pictfmt_for_standard(xcb_connection_t *c, xcb_pict_standard_t std) { + x_get_server_pictfmts(c); + + auto pictfmt = xcb_render_util_find_standard_format(g_pictfmts, std); + + return pictfmt->id; +} + int x_get_visual_depth(xcb_connection_t *c, xcb_visualid_t visual) { auto setup = xcb_get_setup(c); for (auto screen = xcb_setup_roots_iterator(setup); screen.rem; @@ -231,6 +240,17 @@ x_create_picture_with_standard_and_pixmap(xcb_connection_t *c, xcb_pict_standard return x_create_picture_with_pictfmt_and_pixmap(c, pictfmt, pixmap, valuemask, attr); } +xcb_render_picture_t +x_create_picture_with_standard(xcb_connection_t *c, xcb_drawable_t d, int w, int h, + xcb_pict_standard_t standard, uint32_t valuemask, + const xcb_render_create_picture_value_list_t *attr) { + x_get_server_pictfmts(c); + + auto pictfmt = xcb_render_util_find_standard_format(g_pictfmts, standard); + assert(pictfmt); + return x_create_picture_with_pictfmt(c, d, w, h, pictfmt, valuemask, attr); +} + /** * Create an picture. */ diff --git a/src/x.h b/src/x.h index e408428a..fb57ce30 100644 --- a/src/x.h +++ b/src/x.h @@ -172,6 +172,12 @@ x_create_picture_with_standard_and_pixmap(xcb_connection_t *, xcb_pict_standard_ const xcb_render_create_picture_value_list_t *attr) attr_nonnull(1); +xcb_render_picture_t +x_create_picture_with_standard(xcb_connection_t *c, xcb_drawable_t d, int w, int h, + xcb_pict_standard_t standard, uint32_t valuemask, + const xcb_render_create_picture_value_list_t *attr) + attr_nonnull(1); + /** * Create an picture. */ @@ -261,6 +267,9 @@ struct xvisual_info x_get_visual_info(xcb_connection_t *c, xcb_visualid_t visual xcb_visualid_t x_get_visual_for_standard(xcb_connection_t *c, xcb_pict_standard_t std); +xcb_render_pictformat_t +x_get_pictfmt_for_standard(xcb_connection_t *c, xcb_pict_standard_t std); + xcb_screen_t *x_screen_of_display(xcb_connection_t *c, int screen); uint32_t attr_deprecated xcb_generate_id(xcb_connection_t *c);