modernc.org/xcb@v1.0.15/examples/helloworld/helloworld.c (about) 1 // +build ignore 2 3 // src: https://www.x.org/releases/current/doc/libxcb/tutorial/index.html#helloworld 4 5 #include <unistd.h> /* pause() */ 6 7 #include <xcb/xcb.h> 8 9 int 10 main () 11 { 12 xcb_connection_t *c; 13 xcb_screen_t *screen; 14 xcb_window_t win; 15 16 /* Open the connection to the X server */ 17 c = xcb_connect (NULL, NULL); 18 19 /* Get the first screen */ 20 screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data; 21 22 /* Ask for our window's Id */ 23 win = xcb_generate_id(c); 24 25 /* Create the window */ 26 xcb_create_window (c, /* Connection */ 27 XCB_COPY_FROM_PARENT, /* depth (same as root)*/ 28 win, /* window Id */ 29 screen->root, /* parent window */ 30 0, 0, /* x, y */ 31 150, 150, /* width, height */ 32 10, /* border_width */ 33 XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */ 34 screen->root_visual, /* visual */ 35 0, NULL); /* masks, not used yet */ 36 37 /* Map the window on the screen */ 38 xcb_map_window (c, win); 39 40 /* Make sure commands are sent before we pause, so window is shown */ 41 xcb_flush (c); 42 43 pause (); /* hold client until Ctrl-C */ 44 45 return 0; 46 }