-void initialize_xinerama(xcb_connection_t *conn) {
- virtual_screens = scalloc(sizeof(struct screens_head));
- TAILQ_INIT(virtual_screens);
-
- if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) {
- printf("Xinerama extension not found, disabling.\n");
- disable_xinerama(conn);
- return;
- }
-
- if (!xcb_xinerama_is_active_reply(conn, xcb_xinerama_is_active(conn), NULL)->state) {
- printf("Xinerama is not active (in your X-Server), disabling.\n");
- disable_xinerama(conn);
- return;
- }
-
- query_screens(conn, virtual_screens);
-
- i3Screen *s;
- num_screens = 0;
- /* Just go through each workspace and associate as many screens as we can. */
- TAILQ_FOREACH(s, virtual_screens, screens) {
- s->num = num_screens;
- initialize_screen(conn, s, &(workspaces[num_screens]));
- num_screens++;
- }
-}
-
-/*
- * This is called when the rootwindow receives a configure_notify event and therefore the
- * number/position of the Xinerama screens could have changed.
- *
- */
-void xinerama_requery_screens(xcb_connection_t *conn) {
- /* POSSIBLE PROBLEM: Is the order of the Xinerama screens always constant? That is, can
- it change when I move the --right-of video projector to --left-of? */
-
- if (!xinerama_enabled) {
- printf("Xinerama is disabled\n");
- return;
- }
-
- /* We use a separate copy to diff with the previous set of screens */
- struct screens_head *new_screens = scalloc(sizeof(struct screens_head));
- TAILQ_INIT(new_screens);
-
- query_screens(conn, new_screens);
-
- i3Screen *first = TAILQ_FIRST(new_screens),
- *screen;
- int screen_count = 0;
- TAILQ_FOREACH(screen, new_screens, screens) {
- screen->num = screen_count;
- screen->current_workspace = -1;
- for (int c = 0; c < 10; c++)
- if ((workspaces[c].screen != NULL) &&
- (workspaces[c].screen->num == screen_count)) {
- printf("Found a matching screen\n");
- /* Try to use the same workspace, if it’s available */
- if (workspaces[c].screen->current_workspace)
- screen->current_workspace = workspaces[c].screen->current_workspace;
-
- if (screen->current_workspace == -1)
- screen->current_workspace = c;
-
- /* Re-use the old bar window */
- screen->bar = workspaces[c].screen->bar;
- screen->bargc = workspaces[c].screen->bargc;
-
- /* Update the dimensions */
- memcpy(&(workspaces[c].rect), &(screen->rect), sizeof(Rect));
- workspaces[c].screen = screen;
- }
- if (screen->current_workspace == -1) {
- /* Create a new workspace for this screen, it’s new */
- for (int c = 0; c < 10; c++)
- if (workspaces[c].screen == NULL) {
- printf("fix: initializing new workspace, setting num to %d\n", c);
- initialize_screen(conn, screen, &(workspaces[c]));
- break;
- }
- }
- screen_count++;
- }
-
- /* Check for workspaces which are out of bounds */
- for (int c = 0; c < 10; c++)
- if ((workspaces[c].screen != NULL) &&
- (workspaces[c].screen->num >= num_screens)) {
- printf("Closing bar window\n");
- xcb_destroy_window(conn, workspaces[c].screen->bar);
-
- printf("Workspace %d's screen out of bounds, assigning to first screen\n", c+1);
- workspaces[c].screen = first;
- memcpy(&(workspaces[c].rect), &(first->rect), sizeof(Rect));
- }
-
- /* Free the old list */
- TAILQ_FOREACH(screen, virtual_screens, screens) {
- TAILQ_REMOVE(virtual_screens, screen, screens);
- free(screen);
- }
- free(virtual_screens);
-
- virtual_screens = new_screens;
-
- printf("Current workspace is now: %d\n", first->current_workspace);
-
- render_layout(conn);
+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);
+
+ 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