+ /* Check that the selected screen supports this depth */
+ const xcb_depth_t *d = FindDepth (scr, fmt->depth);
+ if (d == NULL)
+ continue;
+
+ /* Find a visual type for the selected depth */
+ const xcb_visualtype_t *vt = xcb_depth_visuals (d);
+
+ /* First try True Color class */
+ for (int i = xcb_depth_visuals_length (d); i > 0; i--)
+ {
+ if (vt->_class == XCB_VISUAL_CLASS_TRUE_COLOR)
+ {
+ fmt_pic.i_rmask = vt->red_mask;
+ fmt_pic.i_gmask = vt->green_mask;
+ fmt_pic.i_bmask = vt->blue_mask;
+ found_visual:
+ vd->fmt = fmt_pic;
+ vid = vt->visual_id;
+ msg_Dbg (vd, "using X11 visual ID 0x%"PRIx32, vid);
+ sys->depth = fmt->depth;
+ msg_Dbg (vd, " %"PRIu8" bits depth", sys->depth);
+ msg_Dbg (vd, " %"PRIu8" bits per pixel", fmt->bits_per_pixel);
+ msg_Dbg (vd, " %"PRIu8" bits line pad", fmt->scanline_pad);
+ goto found_format;
+ }
+ vt++;
+ }
+
+ /* Then try Static Gray class */
+ if (fmt->depth != 8)
+ continue;
+ vt = xcb_depth_visuals (d);
+ for (int i = xcb_depth_visuals_length (d); i > 0 && !vid; i--)
+ {
+ if (vt->_class == XCB_VISUAL_CLASS_STATIC_GRAY)
+ {
+ fmt_pic.i_chroma = VLC_CODEC_GREY;
+ goto found_visual;
+ }
+ vt++;
+ }