]> git.sur5r.net Git - i3/i3/blobdiff - src/randr.c
Implement support for top/bottom dock clients (according to _NET_WM_STRUT_PARTIAL...
[i3/i3] / src / randr.c
index 9abe9c7c1d0819a1798b9567956e1d0c8d88cff5..d4dc770bf097b07fd8b92bb22bcb52924fdba857 100644 (file)
@@ -273,7 +273,7 @@ void output_init_con(Output *output) {
     /* this container swallows dock clients */
     Match *match = scalloc(sizeof(Match));
     match_init(match);
-    match->dock = true;
+    match->dock = M_DOCK_TOP;
     match->insert_where = M_BELOW;
     TAILQ_INSERT_TAIL(&(topdock->swallow_head), match, matches);
 
@@ -285,6 +285,8 @@ void output_init_con(Output *output) {
     DLOG("attaching\n");
     con_attach(topdock, con, false);
 
+    /* content container */
+
     DLOG("adding main content container\n");
     Con *content = con_new(NULL);
     content->type = CT_CON;
@@ -295,6 +297,26 @@ void output_init_con(Output *output) {
     FREE(name);
     con_attach(content, con, false);
 
+    /* bottom dock container */
+    Con *bottomdock = con_new(NULL);
+    bottomdock->type = CT_DOCKAREA;
+    bottomdock->layout = L_DOCKAREA;
+    bottomdock->orientation = VERT;
+    /* this container swallows dock clients */
+    match = scalloc(sizeof(Match));
+    match_init(match);
+    match->dock = M_DOCK_BOTTOM;
+    match->insert_where = M_BELOW;
+    TAILQ_INSERT_TAIL(&(bottomdock->swallow_head), match, matches);
+
+    bottomdock->name = sstrdup("bottomdock");
+
+    asprintf(&name, "[i3 con] bottom dockarea %s", con->name);
+    x_set_name(bottomdock, name);
+    FREE(name);
+    DLOG("attaching\n");
+    con_attach(bottomdock, con, false);
+
     DLOG("Now adding a workspace\n");
 
     /* add a workspace to this output */
@@ -306,7 +328,7 @@ void output_init_con(Output *output) {
     int c = 0;
     bool exists = true;
     while (exists) {
-        Con *out, *current;
+        Con *out, *current, *child;
 
         c++;
 
@@ -316,11 +338,16 @@ void output_init_con(Output *output) {
         exists = false;
         TAILQ_FOREACH(out, &(croot->nodes_head), nodes) {
             TAILQ_FOREACH(current, &(out->nodes_head), nodes) {
-                if (strcasecmp(current->name, ws->name) != 0)
+                if (current->type != CT_CON)
                     continue;
 
-                exists = true;
-                break;
+                TAILQ_FOREACH(child, &(current->nodes_head), nodes) {
+                    if (strcasecmp(child->name, ws->name) != 0)
+                        continue;
+
+                    exists = true;
+                    break;
+                }
             }
         }
 
@@ -579,7 +606,9 @@ void randr_query_outputs() {
             DLOG("Output %s disabled, re-assigning workspaces/docks\n", output->name);
 
             if ((first = get_first_output()) == NULL)
-                    die("No usable outputs available\n");
+                die("No usable outputs available\n");
+
+            Con *first_content = output_get_content(first->con);
 
             if (output->con != NULL) {
                 /* We need to move the workspaces from the disappearing output to the first output */
@@ -593,12 +622,13 @@ void randr_query_outputs() {
 
                 /* 2: iterate through workspaces and re-assign them */
                 Con *current;
-                while (!TAILQ_EMPTY(&(output->con->nodes_head))) {
-                    current = TAILQ_FIRST(&(output->con->nodes_head));
+                Con *old_content = output_get_content(output->con);
+                while (!TAILQ_EMPTY(&(old_content->nodes_head))) {
+                    current = TAILQ_FIRST(&(old_content->nodes_head));
                     DLOG("Detaching current = %p / %s\n", current, current->name);
                     con_detach(current);
                     DLOG("Re-attaching current = %p / %s\n", current, current->name);
-                    con_attach(current, first->con, false);
+                    con_attach(current, first_content, false);
                     DLOG("Done, next\n");
                 }
                 DLOG("re-attached all workspaces\n");