]> git.sur5r.net Git - i3/i3/blobdiff - src/table.c
Implement moving clients to the left if they are leftmost
[i3/i3] / src / table.c
index 4c13be8366cb8fc497b7d0992e6308f164c6783d..917639723fd0af0d92d2feb7dafc4d28cc9e4607 100644 (file)
@@ -85,6 +85,28 @@ void expand_table_cols(Workspace *workspace) {
                 new_container(workspace, &(workspace->table[workspace->cols-1][c]), workspace->cols-1, c);
 }
 
+/*
+ * Inserts one column at the table’s head
+ *
+ */
+void expand_table_cols_at_head(Workspace *workspace) {
+        workspace->cols++;
+
+        workspace->table = realloc(workspace->table, sizeof(Container**) * workspace->cols);
+        workspace->table[workspace->cols-1] = calloc(sizeof(Container*) * workspace->rows, 1);
+
+        /* Move the other columns */
+        for (int rows = 0; rows < workspace->rows; rows++)
+                for (int cols = workspace->cols - 1; cols > 0; cols--) {
+                        LOG("Moving col %d to %d\n", cols-1, cols);
+                        workspace->table[cols][rows] = workspace->table[cols-1][rows];
+                        workspace->table[cols][rows]->col = cols;
+                }
+
+        for (int rows = 0; rows < workspace->rows; rows++)
+                new_container(workspace, &(workspace->table[0][rows]), 0, rows);
+}
+
 /*
  * Shrinks the table by one column.
  *