2 * vim:ts=4:sw=4:expandtab
4 * © 2010-2012 Michael Stapelberg
6 * See LICENSE for licensing information
14 #include <xcb/xinerama.h>
19 /* Number of Xinerama screens which are currently present. */
22 /* The resolutions of the currently present Xinerama screens. */
25 static bool xinerama_active;
27 void xinerama_init() {
28 if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) {
29 printf("Xinerama extension not found, disabling.\n");
33 xcb_xinerama_is_active_cookie_t cookie;
34 xcb_xinerama_is_active_reply_t *reply;
36 cookie = xcb_xinerama_is_active(conn);
37 reply = xcb_xinerama_is_active_reply(conn, cookie, NULL);
46 xinerama_active = true;
49 void xinerama_query_screens() {
53 xcb_xinerama_query_screens_cookie_t cookie;
54 xcb_xinerama_query_screens_reply_t *reply;
55 xcb_xinerama_screen_info_t *screen_info;
57 cookie = xcb_xinerama_query_screens_unchecked(conn);
58 reply = xcb_xinerama_query_screens_reply(conn, cookie, NULL);
60 fprintf(stderr, "Couldn't get Xinerama screens\n");
63 screen_info = xcb_xinerama_query_screens_screen_info(reply);
64 int screens = xcb_xinerama_query_screens_screen_info_length(reply);
66 Rect *resolutions = malloc(screens * sizeof(Rect));
67 /* No memory? Just keep on using the old information. */
72 xr_resolutions = resolutions;
75 for (int screen = 0; screen < xr_screens; screen++) {
76 xr_resolutions[screen].x = screen_info[screen].x_org;
77 xr_resolutions[screen].y = screen_info[screen].y_org;
78 xr_resolutions[screen].width = screen_info[screen].width;
79 xr_resolutions[screen].height = screen_info[screen].height;
80 printf("found Xinerama screen: %d x %d at %d x %d\n",
81 screen_info[screen].width, screen_info[screen].height,
82 screen_info[screen].x_org, screen_info[screen].y_org);