modernc.org/99c@v1.0.1-0.20181109153923-a9e8197063d9/examples/xcb/screen.c (about) 1 // 99c screen.c -lxcb && ./a.out 2 3 // +build ignore 4 5 // src: https://www.x.org/releases/current/doc/libxcb/tutorial/index.html#screen 6 7 #include <stdio.h> 8 #include <xcb/xcb.h> 9 #include <inttypes.h> 10 11 int main() 12 { 13 /* Open the connection to the X server. Use the DISPLAY environment variable */ 14 15 int i, screenNum; 16 xcb_connection_t *connection = xcb_connect(NULL, &screenNum); 17 18 /* Get the screen whose number is screenNum */ 19 20 const xcb_setup_t *setup = xcb_get_setup(connection); 21 xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup); 22 23 // we want the screen at index screenNum of the iterator 24 for (i = 0; i < screenNum; ++i) { 25 xcb_screen_next(&iter); 26 } 27 28 xcb_screen_t *screen = iter.data; 29 30 /* report */ 31 32 printf("\n"); 33 printf("Informations of screen %" PRIu32 ":\n", screen->root); 34 printf(" width.........: %" PRIu16 "\n", screen->width_in_pixels); 35 printf(" height........: %" PRIu16 "\n", screen->height_in_pixels); 36 printf(" white pixel...: %" PRIu32 "\n", screen->white_pixel); 37 printf(" black pixel...: %" PRIu32 "\n", screen->black_pixel); 38 printf("\n"); 39 40 return 0; 41 }