include stdio include unistd include xcb xcb include xcb xcb_aux inclu

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_image.h>
int main(int argc, char** argv)
{
xcb_connection_t* c;
xcb_drawable_t draw;
xcb_screen_t* screen;
int screen_nbr;
uint32_t values[2];
xcb_image_t* image;
c = xcb_connect(NULL, &screen_nbr);
screen = xcb_aux_get_screen(c, screen_nbr);
values[0] = screen->white_pixel;
values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS;
draw = xcb_generate_id (c);
xcb_create_window(c, xcb_aux_get_depth(c, screen),
draw,
screen->root,
0, 0, 256, 256,
0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
screen->root_visual,
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
values);
xcb_map_window(c, draw);
xcb_flush(c);
if(argc > 1)
sleep(1);
image = xcb_image_get(c, draw, 0, 0, 256, 256,
~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
printf("%p\n", image);
return 0;
}