X-Git-Url: http://pileus.org/git/?p=wmpus;a=blobdiff_plain;f=sys-xcb.c;h=7c73a4d67588d25ba3a2fca718e5fe7eb1750f8f;hp=26a105f059cbdb2550fe8563b52cab5f702b58db;hb=d79a7e5f74824d1e4b430953a30e71f43dfccf47;hpb=4103fe7bd83d5770b98ee2fd4d244b62dadc6f97 diff --git a/sys-xcb.c b/sys-xcb.c index 26a105f..7c73a4d 100644 --- a/sys-xcb.c +++ b/sys-xcb.c @@ -19,6 +19,7 @@ #include #include +#include #include "util.h" #include "conf.h" @@ -138,6 +139,41 @@ static xcb_get_window_attributes_reply_t *do_get_window_attributes(xcb_window_t return reply; } +static int do_xinerama_check(void) +{ + const xcb_query_extension_reply_t *data = + xcb_get_extension_data(conn, &xcb_xinerama_id); + if (!data || !data->present) + return printf("do_xinerama_check: no ext\n"), 0; + + xcb_xinerama_is_active_cookie_t cookie = + xcb_xinerama_is_active(conn); + if (!cookie.sequence) + return printf("do_xinerama_check: no cookie\n"), 0; + + xcb_xinerama_is_active_reply_t *reply = + xcb_xinerama_is_active_reply(conn, cookie, NULL); + if (!reply) + printf("do_xinerama_check: no reply\n"), 0; + else + printf("do_xinerama_check: %d\n", reply->state); + return reply && reply->state; +} + +static xcb_xinerama_query_screens_reply_t *do_query_screens(void) +{ + xcb_xinerama_query_screens_cookie_t cookie = + xcb_xinerama_query_screens(conn); + xcb_xinerama_query_screens_reply_t *reply = + xcb_xinerama_query_screens_reply(conn, cookie, NULL); + if (!reply) + printf("do_query_screens: no reply\n"); + else + printf("do_query_screens: %d screens\n", + xcb_xinerama_query_screens_screen_info_length(reply)); + return reply; +} + /********************** * X11 Event Handlers * **********************/ @@ -294,6 +330,32 @@ list_t *sys_info(void) { printf("sys_info\n"); + if (screens == NULL && do_xinerama_check()) { + /* Add Xinerama screens */ + xcb_xinerama_query_screens_reply_t *query; + unsigned int ninfo; + xcb_xinerama_screen_info_t *info; + + query = do_query_screens(); + ninfo = xcb_xinerama_query_screens_screen_info_length(query); + info = xcb_xinerama_query_screens_screen_info(query); + + for (int i = 0; i < ninfo; i++) { + win_t *screen = new0(win_t); + + screen->x = info[i].x_org; + screen->y = info[i].y_org; + screen->w = info[i].width; + screen->h = info[i].height; + + screens = list_insert(NULL, screen); + + printf("sys_info: xinerama screen - %dx%d @ %d,%d\n", + screen->w, screen->h, + screen->x, screen->y); + } + } + if (screens == NULL) { /* No xinerama support */ const xcb_setup_t *setup = xcb_get_setup(conn);