X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fxinerama.c;h=25bfa6b194970257fffeaa90cc4365605dbc3acb;hb=4c97c94a0a29e0b775974c780d574639372e76c2;hp=7e5b5aebb4acb60e64379ceed47ed17c0428f42e;hpb=8d2799c251cc1c44f1429c36817c346fa56b9701;p=i3%2Fi3 diff --git a/src/xinerama.c b/src/xinerama.c index 7e5b5aeb..25bfa6b1 100644 --- a/src/xinerama.c +++ b/src/xinerama.c @@ -1,10 +1,8 @@ -#undef I3__FILE__ -#define I3__FILE__ "xinerama.c" /* * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009 Michael Stapelberg and contributors (see also: LICENSE) * * This is LEGACY code (we support RandR, which can do much more than * Xinerama), but necessary for the poor users of the nVidia binary @@ -15,18 +13,17 @@ #include - static int num_screens; /* * Looks in outputs for the Output whose start coordinates are x, y * */ -static Output *get_screen_at(int x, int y) { +static Output *get_screen_at(unsigned int x, unsigned int y) { Output *output; TAILQ_FOREACH(output, &outputs, outputs) - if (output->rect.x == x && output->rect.y == y) - return output; + if (output->rect.x == x && output->rect.y == y) + return output; return NULL; } @@ -57,7 +54,7 @@ static void query_screens(xcb_connection_t *conn) { 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)); + s = scalloc(1, sizeof(Output)); sasprintf(&(s->name), "xinerama-%d", num_screens); DLOG("Created new Xinerama screen %s (%p)\n", s->name, s); s->active = true; @@ -67,16 +64,17 @@ static void query_screens(xcb_connection_t *conn) { 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); + 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++; } 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); + screen_info[screen].width, screen_info[screen].height, + screen_info[screen].x_org, screen_info[screen].y_org); } free(reply); @@ -87,6 +85,19 @@ static void query_screens(xcb_connection_t *conn) { } } +/* + * This creates the root_output (borrowed from randr.c) and uses it + * as the sole output for this session. + * + */ +static void use_root_output(xcb_connection_t *conn) { + Output *s = create_root_output(conn); + s->active = true; + TAILQ_INSERT_TAIL(&outputs, s, outputs); + output_init_con(s); + init_ws_for_output(s, output_get_content(s->con)); +} + /* * We have just established a connection to the X server and need the initial Xinerama * information to setup workspaces for each screen. @@ -94,28 +105,18 @@ static void query_screens(xcb_connection_t *conn) { */ void xinerama_init(void) { if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) { - DLOG("Xinerama extension not found, disabling.\n"); - disable_randr(conn); + DLOG("Xinerama extension not found, using root output.\n"); + use_root_output(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); + DLOG("Xinerama is not active (in your X-Server), using root output.\n"); + use_root_output(conn); } else query_screens(conn); FREE(reply); } - -#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 }