1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-11 13:51:02 -05:00

x: add the x_get_visual_for_depth function

it returns the first found visual for the given depth

(cherry picked from commit 4401666cfb)
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Maxim Solovyov 2024-02-01 02:31:29 +03:00 committed by Yuxuan Shui
parent e0aa6f9107
commit d3a108b3db
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4
2 changed files with 17 additions and 0 deletions

15
src/x.c
View file

@ -321,6 +321,21 @@ xcb_visualid_t x_get_visual_for_standard(struct x_connection *c, xcb_pict_standa
return x_get_visual_for_pictfmt(g_pictfmts, pictfmt->id);
}
xcb_visualid_t x_get_visual_for_depth(struct x_connection *c, uint8_t depth) {
xcb_screen_iterator_t screen_it = xcb_setup_roots_iterator(xcb_get_setup(c->c));
for (; screen_it.rem; xcb_screen_next(&screen_it)) {
xcb_depth_iterator_t depth_it =
xcb_screen_allowed_depths_iterator(screen_it.data);
for (; depth_it.rem; xcb_depth_next(&depth_it)) {
if (depth_it.data->depth == depth) {
return xcb_depth_visuals_iterator(depth_it.data).data->visual_id;
}
}
}
return XCB_NONE;
}
xcb_render_pictformat_t
x_get_pictfmt_for_standard(struct x_connection *c, xcb_pict_standard_t std) {
x_get_server_pictfmts(c);

View file

@ -411,6 +411,8 @@ struct xvisual_info x_get_visual_info(struct x_connection *c, xcb_visualid_t vis
xcb_visualid_t x_get_visual_for_standard(struct x_connection *c, xcb_pict_standard_t std);
xcb_visualid_t x_get_visual_for_depth(struct x_connection *c, uint8_t depth);
xcb_render_pictformat_t
x_get_pictfmt_for_standard(struct x_connection *c, xcb_pict_standard_t std);