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
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <xcb/xcb.h>
int main(void)
{
xcb_connection_t *conn = xcb_connect(NULL, NULL);
if (!conn)
{
printf("xcb_connect() failed; conn = %p\n", conn);
return EXIT_FAILURE;
}
printf("connected to X; conn = %p\n", conn);
xcb_screen_t *scr = xcb_setup_roots_iterator(
xcb_get_setup(conn)
).data;
xcb_window_t win = xcb_generate_id(conn);
xcb_create_window(conn, XCB_COPY_FROM_PARENT, win, scr->root,
0, 0, 100, 100, 10, XCB_WINDOW_CLASS_INPUT_OUTPUT,
scr->root_visual, 0, NULL);
xcb_map_window(conn, win);
xcb_flush(conn);
printf("window created; win = %d\n", win);
sleep(5);
xcb_unmap_window(conn, win);
xcb_flush(conn);
printf("window destroyed; win = %d\n", win);
xcb_disconnect(conn);
puts("disconnected from X");
return EXIT_SUCCESS;
}
|