X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fxinerama.c;h=c116deaa954fb0bd709a1e5ec44a23c0f1b5e7a9;hb=914ca6cfe719a5dd997f03132840cfd5600bfd09;hp=d7efff0d6c6199f096a1730bd477ef40b8780aa6;hpb=bd76e994b8b0c21defc0fecdff510277a970acd2;p=i3%2Fi3 diff --git a/src/xinerama.c b/src/xinerama.c index d7efff0d..c116deaa 100644 --- a/src/xinerama.c +++ b/src/xinerama.c @@ -1,9 +1,9 @@ /* - * vim:ts=8:expandtab + * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager * - * © 2009-2010 Michael Stapelberg and contributors + * © 2009-2011 Michael Stapelberg and contributors * * See file LICENSE for license information. * @@ -12,20 +12,10 @@ * driver which does not support RandR in 2010 *sigh*. * */ -#include -#include -#include -#include #include -#include "queue.h" -#include "data.h" -#include "util.h" -#include "xinerama.h" -#include "workspace.h" -#include "log.h" -#include "randr.h" +#include "all.h" static int num_screens; @@ -34,12 +24,12 @@ static int num_screens; * */ static Output *get_screen_at(int x, int y) { - Output *output; - TAILQ_FOREACH(output, &outputs, outputs) - if (output->rect.x == x && output->rect.y == y) - return output; + Output *output; + TAILQ_FOREACH(output, &outputs, outputs) + if (output->rect.x == x && output->rect.y == y) + return output; - return NULL; + return NULL; } /* @@ -48,52 +38,54 @@ static Output *get_screen_at(int x, int y) { * */ static void query_screens(xcb_connection_t *conn) { - xcb_xinerama_query_screens_reply_t *reply; - xcb_xinerama_screen_info_t *screen_info; + xcb_xinerama_query_screens_reply_t *reply; + xcb_xinerama_screen_info_t *screen_info; - reply = xcb_xinerama_query_screens_reply(conn, xcb_xinerama_query_screens_unchecked(conn), NULL); - if (!reply) { - ELOG("Couldn't get Xinerama screens\n"); - return; - } - screen_info = xcb_xinerama_query_screens_screen_info(reply); - int screens = xcb_xinerama_query_screens_screen_info_length(reply); - - for (int screen = 0; screen < screens; screen++) { - Output *s = get_screen_at(screen_info[screen].x_org, screen_info[screen].y_org); - if (s != NULL) { - DLOG("Re-used old Xinerama screen %p\n", s); - /* This screen already exists. We use the littlest screen so that the user - can always see the complete workspace */ - s->rect.width = min(s->rect.width, screen_info[screen].width); - s->rect.height = min(s->rect.height, screen_info[screen].height); - } else { - s = scalloc(sizeof(Output)); - asprintf(&(s->name), "xinerama-%d", num_screens); - DLOG("Created new Xinerama screen %s (%p)\n", s->name, s); - s->active = true; - s->rect.x = screen_info[screen].x_org; - s->rect.y = screen_info[screen].y_org; - s->rect.width = screen_info[screen].width; - s->rect.height = screen_info[screen].height; - /* We always treat the screen at 0x0 as the primary screen */ - if (s->rect.x == 0 && s->rect.y == 0) - TAILQ_INSERT_HEAD(&outputs, s, outputs); - else TAILQ_INSERT_TAIL(&outputs, s, outputs); - num_screens++; - } + reply = xcb_xinerama_query_screens_reply(conn, xcb_xinerama_query_screens_unchecked(conn), NULL); + if (!reply) { + ELOG("Couldn't get Xinerama screens\n"); + return; + } + screen_info = xcb_xinerama_query_screens_screen_info(reply); + int screens = xcb_xinerama_query_screens_screen_info_length(reply); - DLOG("found Xinerama screen: %d x %d at %d x %d\n", - screen_info[screen].width, screen_info[screen].height, - screen_info[screen].x_org, screen_info[screen].y_org); + for (int screen = 0; screen < screens; screen++) { + Output *s = get_screen_at(screen_info[screen].x_org, screen_info[screen].y_org); + if (s != NULL) { + DLOG("Re-used old Xinerama screen %p\n", s); + /* This screen already exists. We use the littlest screen so that the user + can always see the complete workspace */ + s->rect.width = min(s->rect.width, screen_info[screen].width); + s->rect.height = min(s->rect.height, screen_info[screen].height); + } else { + s = scalloc(sizeof(Output)); + asprintf(&(s->name), "xinerama-%d", num_screens); + DLOG("Created new Xinerama screen %s (%p)\n", s->name, s); + s->active = true; + s->rect.x = screen_info[screen].x_org; + s->rect.y = screen_info[screen].y_org; + s->rect.width = screen_info[screen].width; + s->rect.height = screen_info[screen].height; + /* We always treat the screen at 0x0 as the primary screen */ + if (s->rect.x == 0 && s->rect.y == 0) + TAILQ_INSERT_HEAD(&outputs, s, outputs); + else TAILQ_INSERT_TAIL(&outputs, s, outputs); + output_init_con(s); + init_ws_for_output(s, output_get_content(s->con)); + num_screens++; } - free(reply); + DLOG("found Xinerama screen: %d x %d at %d x %d\n", + screen_info[screen].width, screen_info[screen].height, + screen_info[screen].x_org, screen_info[screen].y_org); + } - if (num_screens == 0) { - ELOG("No screens found. Please fix your setup. i3 will exit now.\n"); - exit(0); - } + free(reply); + + if (num_screens == 0) { + ELOG("No screens found. Please fix your setup. i3 will exit now.\n"); + exit(0); + } } /* @@ -101,28 +93,30 @@ static void query_screens(xcb_connection_t *conn) { * information to setup workspaces for each screen. * */ -void initialize_xinerama(xcb_connection_t *conn) { - if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) { - DLOG("Xinerama extension not found, disabling.\n"); - disable_randr(conn); - } else { - xcb_xinerama_is_active_reply_t *reply; - reply = xcb_xinerama_is_active_reply(conn, xcb_xinerama_is_active(conn), NULL); +void xinerama_init() { + if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) { + DLOG("Xinerama extension not found, disabling.\n"); + disable_randr(conn); + } else { + xcb_xinerama_is_active_reply_t *reply; + reply = xcb_xinerama_is_active_reply(conn, xcb_xinerama_is_active(conn), NULL); - if (reply == NULL || !reply->state) { - DLOG("Xinerama is not active (in your X-Server), disabling.\n"); - disable_randr(conn); - } else - query_screens(conn); + if (reply == NULL || !reply->state) { + DLOG("Xinerama is not active (in your X-Server), disabling.\n"); + disable_randr(conn); + } else + query_screens(conn); - FREE(reply); - } + FREE(reply); + } - Output *output; - Workspace *ws; - /* Just go through each active output and associate one workspace */ - TAILQ_FOREACH(output, &outputs, outputs) { - ws = get_first_workspace_for_output(output); - initialize_output(conn, output, ws); - } +#if 0 + Output *output; + Workspace *ws; + /* Just go through each active output and associate one workspace */ + TAILQ_FOREACH(output, &outputs, outputs) { + ws = get_first_workspace_for_output(output); + initialize_output(conn, output, ws); + } +#endif }