2 * vim:ts=4:sw=4:expandtab
4 * © 2010 Michael Stapelberg
6 * See LICENSE for licensing information
14 #include <xcb/xinerama.h>
20 /* Number of Xinerama screens which are currently present. */
23 /* The resolutions of the currently present Xinerama screens. */
26 static bool xinerama_active;
27 extern bool debug_mode;
29 void xinerama_init(void) {
30 if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) {
31 DEBUG("Xinerama extension not found, disabling.\n");
35 xcb_xinerama_is_active_cookie_t cookie;
36 xcb_xinerama_is_active_reply_t *reply;
38 cookie = xcb_xinerama_is_active(conn);
39 reply = xcb_xinerama_is_active_reply(conn, cookie, NULL);
48 xinerama_active = true;
52 void xinerama_query_screens(void) {
56 xcb_xinerama_query_screens_cookie_t cookie;
57 xcb_xinerama_query_screens_reply_t *reply;
58 xcb_xinerama_screen_info_t *screen_info;
60 cookie = xcb_xinerama_query_screens_unchecked(conn);
61 reply = xcb_xinerama_query_screens_reply(conn, cookie, NULL);
64 fprintf(stderr, "Couldn't get Xinerama screens\n");
67 screen_info = xcb_xinerama_query_screens_screen_info(reply);
68 int screens = xcb_xinerama_query_screens_screen_info_length(reply);
70 Rect *resolutions = malloc(screens * sizeof(Rect));
71 /* No memory? Just keep on using the old information. */
76 xr_resolutions = resolutions;
79 for (int screen = 0; screen < xr_screens; screen++) {
80 xr_resolutions[screen].x = screen_info[screen].x_org;
81 xr_resolutions[screen].y = screen_info[screen].y_org;
82 xr_resolutions[screen].width = screen_info[screen].width;
83 xr_resolutions[screen].height = screen_info[screen].height;
84 DEBUG("found Xinerama screen: %d x %d at %d x %d\n",
85 screen_info[screen].width, screen_info[screen].height,
86 screen_info[screen].x_org, screen_info[screen].y_org);