]> git.sur5r.net Git - i3/i3/commitdiff
Implement moving clients to the left if they are leftmost
authorMichael Stapelberg <michael+x200@stapelberg.de>
Wed, 11 Mar 2009 00:55:10 +0000 (01:55 +0100)
committerMichael Stapelberg <michael+x200@stapelberg.de>
Wed, 11 Mar 2009 00:55:10 +0000 (01:55 +0100)
include/table.h
src/commands.c
src/table.c

index 9d1d19f9d66ff73aa11dfa710f6291634dbbd373..0e4cdfe9b917479280c65fb9f3af243494e61998 100644 (file)
@@ -28,10 +28,10 @@ extern int current_row;
 void init_table();
 void expand_table_rows(Workspace *workspace);
 void expand_table_cols(Workspace *workspace);
+void expand_table_cols_at_head(Workspace *workspace);
 bool cell_exists(int col, int row);
 void cleanup_table(xcb_connection_t *conn, Workspace *workspace);
 void fix_colrowspan(xcb_connection_t *conn, Workspace *workspace);
 void dump_table(xcb_connection_t *conn, Workspace *workspace);
 
-
 #endif
index e47855f6ef5d27c226219950530a0fbe03370e01..22d067a4d2930ba4f2596678c14a5edbc296ef9a 100644 (file)
@@ -181,11 +181,13 @@ static void move_current_window(xcb_connection_t *conn, direction_t direction) {
 
         switch (direction) {
                 case D_LEFT:
-                        /* TODO: If we’re at the left-most position, move the rest of the table right */
-                        if (current_col == 0)
-                                return;
+                        /* If we’re at the left-most position, move the rest of the table right */
+                        if (current_col == 0) {
+                                expand_table_cols_at_head(c_ws);
+                                new = CUR_TABLE[current_col][current_row];
+                        } else
+                                new = CUR_TABLE[--current_col][current_row];
 
-                        new = CUR_TABLE[--current_col][current_row];
                         break;
                 case D_RIGHT:
                         if (current_col == (c_ws->cols-1))
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.
  *