Codebase list i3-gaps / a046512d-906a-4424-8cd5-1cdbccaff156/upstream libi3 / get_visualtype.c
a046512d-906a-4424-8cd5-1cdbccaff156/upstream

Tree @a046512d-906a-4424-8cd5-1cdbccaff156/upstream (Download .tar.gz)

get_visualtype.c @a046512d-906a-4424-8cd5-1cdbccaff156/upstreamraw · history · blame

/*
 * vim:ts=4:sw=4:expandtab
 *
 * i3 - an improved dynamic tiling window manager
 * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
 *
 */
#include "libi3.h"

/*
 * Returns the visual type associated with the given screen.
 *
 */
xcb_visualtype_t *get_visualtype(xcb_screen_t *screen) {
    xcb_depth_iterator_t depth_iter;
    for (depth_iter = xcb_screen_allowed_depths_iterator(screen);
         depth_iter.rem;
         xcb_depth_next(&depth_iter)) {
        xcb_visualtype_iterator_t visual_iter;
        for (visual_iter = xcb_depth_visuals_iterator(depth_iter.data);
             visual_iter.rem;
             xcb_visualtype_next(&visual_iter)) {
            if (screen->root_visual == visual_iter.data->visual_id)
                return visual_iter.data;
        }
    }
    return NULL;
}