#include static xcb_visualtype_t * lookup_visual(xcb_screen_t *s, xcb_visualid_t visual) { xcb_depth_iterator_t d; d = xcb_screen_allowed_depths_iterator(s); for (; d.rem; xcb_depth_next(&d)) { xcb_visualtype_iterator_t v = xcb_depth_visuals_iterator(d.data); for (; v.rem; xcb_visualtype_next(&v)) { if (v.data->visual_id == visual) return v.data; } } return NULL; } int main() { xcb_connection_t *c; xcb_screen_t *screen; cairo_surface_t *surf; cairo_device_t *device; cairo_t *cr; /* Connect to the server */ c = xcb_connect(NULL, NULL); screen = xcb_setup_roots_iterator(xcb_get_setup(c)).data; /* Get the cairo XCB device */ surf = cairo_xcb_surface_create(c, screen->root, lookup_visual(screen, screen->root_visual), screen->width_in_pixels, screen->height_in_pixels); device = cairo_device_reference(cairo_surface_get_device(surf)); cairo_surface_destroy(surf); /* Don't use RENDER */ cairo_xcb_device_debug_cap_xrender_version(device, -1, -1); /* Create our surface */ surf = cairo_xcb_surface_create(c, screen->root, lookup_visual(screen, screen->root_visual), screen->width_in_pixels, screen->height_in_pixels); /* Cause a fallback */ cr = cairo_create(surf); cairo_set_source_rgba(cr, 1, 1, 1, 0.5); cairo_move_to(cr, 0, 0); cairo_line_to(cr, 2, 2); cairo_stroke(cr); /* Pretend we draw directly */ cairo_surface_flush(surf); #ifdef USE_WORKAROUND cairo_surface_flush(surf); #endif cairo_surface_mark_dirty(surf); return 0; }