+ /* 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;
+ goto found_visual;
+ }
+ vt++;
+ }
+ /* Then try Static Gray class */
+ if (fmt->depth == 8)
+ for (int i = xcb_depth_visuals_length (d); i > 0 && !vid; i--)
+ {
+ if (vt->_class == XCB_VISUAL_CLASS_STATIC_GRAY)
+ goto found_grey;
+ vt++;
+ }
+
+ continue; /* Fail: unusable pixel format */
+
+ found_grey:
+ fmt_pic.i_chroma = VLC_CODEC_GREY;
+ found_visual: