]> git.sur5r.net Git - i3/i3/blobdiff - src/randr.c
Merge branch 'master' into next
[i3/i3] / src / randr.c
index 85f0eab3a916153c5eec4075fac99f75b33f6544..b691a3326a42640b2b0082399f8efd19310a7d01 100644 (file)
@@ -60,7 +60,7 @@ Output *get_output_by_name(const char *name) {
  * Returns the first output which is active.
  *
  */
-Output *get_first_output() {
+Output *get_first_output(void) {
     Output *output;
 
     TAILQ_FOREACH(output, &outputs, outputs)
@@ -256,7 +256,6 @@ void output_init_con(Output *output) {
     Con *topdock = con_new(NULL, NULL);
     topdock->type = CT_DOCKAREA;
     topdock->layout = L_DOCKAREA;
-    topdock->orientation = VERT;
     /* this container swallows dock clients */
     Match *match = scalloc(sizeof(Match));
     match_init(match);
@@ -278,6 +277,7 @@ void output_init_con(Output *output) {
     DLOG("adding main content container\n");
     Con *content = con_new(NULL, NULL);
     content->type = CT_CON;
+    content->layout = L_SPLITH;
     FREE(content->name);
     content->name = sstrdup("content");
 
@@ -290,7 +290,6 @@ void output_init_con(Output *output) {
     Con *bottomdock = con_new(NULL, NULL);
     bottomdock->type = CT_DOCKAREA;
     bottomdock->layout = L_DOCKAREA;
-    bottomdock->orientation = VERT;
     /* this container swallows dock clients */
     match = scalloc(sizeof(Match));
     match_init(match);
@@ -359,6 +358,19 @@ void init_ws_for_output(Output *output, Con *content) {
             workspace_show(previous);
         }
 
+        /* Render the output on which the workspace was to get correct Rects.
+         * Then, we need to work with the "content" container, since we cannot
+         * be sure that the workspace itself was rendered at all (in case it’s
+         * invisible, it won’t be rendered). */
+        render_con(workspace_out, false);
+        Con *ws_out_content = output_get_content(workspace_out);
+
+        Con *floating_con;
+        TAILQ_FOREACH(floating_con, &(workspace->floating_head), floating_windows)
+            /* NB: We use output->con here because content is not yet rendered,
+             * so it has a rect of {0, 0, 0, 0}. */
+            floating_fix_coordinates(floating_con, &(ws_out_content->rect), &(output->con->rect));
+
         con_detach(workspace);
         con_attach(workspace, content, false);
 
@@ -447,11 +459,11 @@ static void output_change_mode(xcb_connection_t *conn, Output *output) {
             if (con_num_children(workspace) > 1)
                 continue;
 
-            workspace->orientation = (output->rect.height > output->rect.width) ? VERT : HORIZ;
-            DLOG("Setting workspace [%d,%s]'s orientation to %d.\n", workspace->num, workspace->name, workspace->orientation);
+            workspace->layout = (output->rect.height > output->rect.width) ? L_SPLITV : L_SPLITH;
+            DLOG("Setting workspace [%d,%s]'s layout to %d.\n", workspace->num, workspace->name, workspace->layout);
             if ((child = TAILQ_FIRST(&(workspace->nodes_head)))) {
-                child->orientation = workspace->orientation;
-                DLOG("Setting child [%d,%s]'s orientation to %d.\n", child->num, child->name, child->orientation);
+                child->layout = workspace->layout;
+                DLOG("Setting child [%d,%s]'s layout to %d.\n", child->num, child->name, child->layout);
             }
         }
     }
@@ -539,7 +551,7 @@ static void handle_output(xcb_connection_t *conn, xcb_randr_output_t id,
  * (Re-)queries the outputs via RandR and stores them in the list of outputs.
  *
  */
-void randr_query_outputs() {
+void randr_query_outputs(void) {
     Output *output, *other, *first;
     xcb_randr_get_output_primary_cookie_t pcookie;
     xcb_randr_get_screen_resources_current_cookie_t rcookie;
@@ -682,7 +694,7 @@ void randr_query_outputs() {
                     DLOG("Fixing the coordinates of floating containers\n");
                     Con *floating_con;
                     TAILQ_FOREACH(floating_con, &(current->floating_head), floating_windows)
-                        floating_fix_coordinates(floating_con, &(old_content->rect), &(first_content->rect));
+                        floating_fix_coordinates(floating_con, &(output->con->rect), &(first->con->rect));
                     DLOG("Done, next\n");
                 }
                 DLOG("re-attached all workspaces\n");