// gcc -std=gnu99 `pkg-config --cflags --libs xcb` setup.c -o setup #include #include #include #include #include xcb_connection_t *conn; void test_setup(void) { const xcb_setup_t *setup = xcb_get_setup(conn); assert(setup); printf("status: %d\n", setup->status); printf("protocol_major_version: %d\n", setup->protocol_major_version); printf("protocol_minor_version: %d\n", setup->protocol_minor_version); printf("length: %d\n", setup->length); printf("release_number: %d\n", setup->release_number); printf("resource_id_base: %d\n", setup->resource_id_base); printf("resource_id_mask: %#x\n", setup->resource_id_mask); printf("motion_buffer_size: %d\n", setup->motion_buffer_size); printf("vendor_len: %d\n", setup->vendor_len); printf("maximum_request_length: %d\n", setup->maximum_request_length); printf("roots_len: %d\n", setup->roots_len); printf("pixmap_formats_len: %d\n", setup->pixmap_formats_len); printf("image_byte_order: %d\n", setup->image_byte_order); printf("bitmap_format_bit_order: %d\n", setup->bitmap_format_bit_order); printf("bitmap_format_scanline_unit: %d\n", setup->bitmap_format_scanline_unit); printf("bitmap_format_scanline_pad: %d\n", setup->bitmap_format_scanline_pad); printf("min_keycode: %d\n", setup->min_keycode); printf("max_keycode: %d\n", setup->max_keycode); printf("vendor: %.*s\n", xcb_setup_vendor_length(setup), xcb_setup_vendor(setup)); { int length = xcb_setup_pixmap_formats_length(setup); xcb_format_iterator_t iter = xcb_setup_pixmap_formats_iterator(setup); for (int i = 0; i < length; i++) { xcb_format_t *format = iter.data; printf("Format %d:\n", i); printf("\tdepth: %d\n", format->depth); printf("\tbits_per_pixel: %d\n", format->bits_per_pixel); printf("\tscanline_pad: %d\n", format->scanline_pad); xcb_format_next(&iter); } } { int screens_length = xcb_setup_roots_length(setup); xcb_screen_iterator_t screens_iter = xcb_setup_roots_iterator(setup); for (int i = 0; i < screens_length; i++) { xcb_screen_t *screen = screens_iter.data; printf("Screen %d:\n", i); printf("\troot: %d\n", screen->root); printf("\tdefault_colormap: %d\n", screen->default_colormap); printf("\twhite_pixel: %#x\n", screen->white_pixel); printf("\tblack_pixel: %#x\n", screen->black_pixel); printf("\tcurrent_input_masks: %d\n", screen->current_input_masks); printf("\twidth_in_pixels: %d\n", screen->width_in_pixels); printf("\theight_in_pixels: %d\n", screen->height_in_pixels); printf("\twidth_in_millimeters: %d\n", screen->width_in_millimeters); printf("\theight_in_millimeters: %d\n", screen->height_in_millimeters); printf("\tmin_installed_maps: %d\n", screen->min_installed_maps); printf("\tmax_installed_maps: %d\n", screen->max_installed_maps); printf("\troot_visual: %d\n", screen->root_visual); printf("\tbacking_stores: %d\n", screen->backing_stores); printf("\tsave_unders: %d\n", screen->save_unders); printf("\troot_depth: %d\n", screen->root_depth); printf("\tallowed_depths_len: %d\n", screen->allowed_depths_len); { int depths_length = xcb_screen_allowed_depths_length(screen); xcb_depth_iterator_t depths_iter = xcb_screen_allowed_depths_iterator(screen); for (int j = 0; j < depths_length; j++) { xcb_depth_t *depth = depths_iter.data; printf("\tDepth %d:\n", j); printf("\t\tdepth: %d\n", depth->depth); printf("\t\tvisuals_len: %d\n", depth->visuals_len); { int visuals_length = xcb_depth_visuals_length(depth); xcb_visualtype_iterator_t visuals_iter = xcb_depth_visuals_iterator(depth); for (int k = 0; k < visuals_length; k++) { xcb_visualtype_t *visual = visuals_iter.data; printf("\t\tVisual %d:\n", k); printf("\t\t\tvisual_id: %d\n", visual->visual_id); printf("\t\t\tclass: %d\n", visual->_class); printf("\t\t\tbits_per_rgb_value: %d\n",visual->bits_per_rgb_value); printf("\t\t\tcolormap_entries: %d\n", visual->colormap_entries); printf("\t\t\tred_mask : %#x\n",visual->red_mask); printf("\t\t\tgreen_mask: %#x\n", visual->green_mask); printf("\t\t\tblue_mask: %#x\n", visual->blue_mask); xcb_visualtype_next(&visuals_iter); } } xcb_depth_next(&depths_iter); } } xcb_screen_next(&screens_iter); } } } int main(void) { conn = xcb_connect(NULL, NULL); assert(conn); test_setup(); return 0; }