]> git.sur5r.net Git - i3/i3/blobdiff - src/commands.c
Turn nested functions into real functions or macros
[i3/i3] / src / commands.c
index f4bc04be3dc83bb035cd3e8526ff39f1684ce86d..184394b40323e747421206df634d4e903e1119f1 100644 (file)
@@ -89,12 +89,13 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
         Workspace *t_ws = c_ws;
 
         /* Makes sure new_col and new_row are within bounds of the new workspace */
-        void check_colrow_boundaries() {
-                if (new_col >= t_ws->cols)
-                        new_col = (t_ws->cols - 1);
-                if (new_row >= t_ws->rows)
-                        new_row = (t_ws->rows - 1);
-        }
+#define CHECK_COLROW_BOUNDARIES \
+        do { \
+                if (new_col >= t_ws->cols) \
+                        new_col = (t_ws->cols - 1); \
+                if (new_row >= t_ws->rows) \
+                        new_row = (t_ws->rows - 1); \
+        } while (0)
 
         /* There always is a container. If not, current_col or current_row is wrong */
         assert(container != NULL);
@@ -121,17 +122,17 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
                         bounds.y -= bounds.height;
                 else bounds.y += bounds.height;
 
-                Output *target = get_screen_containing(bounds.x, bounds.y);
+                Output *target = get_output_containing(bounds.x, bounds.y);
                 if (target == NULL) {
                         DLOG("Target output NULL\n");
                         /* Wrap around if the target screen is out of bounds */
                         if (direction == D_RIGHT)
-                                target = get_screen_most(D_LEFT, cs);
+                                target = get_output_most(D_LEFT, cs);
                         else if (direction == D_LEFT)
-                                target = get_screen_most(D_RIGHT, cs);
+                                target = get_output_most(D_RIGHT, cs);
                         else if (direction == D_UP)
-                                target = get_screen_most(D_DOWN, cs);
-                        else target = get_screen_most(D_UP, cs);
+                                target = get_output_most(D_DOWN, cs);
+                        else target = get_output_most(D_UP, cs);
                 }
 
                 DLOG("Switching to ws %d\n", target->current_workspace + 1);
@@ -165,16 +166,16 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
                         DLOG("container is at %d with height %d\n", container->y, container->height);
                         Output *output;
                         int destination_y = (direction == D_UP ? (container->y - 1) : (container->y + container->height + 1));
-                        if ((output = get_screen_containing(container->x, destination_y)) == NULL) {
+                        if ((output = get_output_containing(container->x, destination_y)) == NULL) {
                                 DLOG("Wrapping screen around vertically\n");
                                 /* No screen found? Then wrap */
-                                output = get_screen_most((direction == D_UP ? D_DOWN : D_UP), container->workspace->output);
+                                output = get_output_most((direction == D_UP ? D_DOWN : D_UP), container->workspace->output);
                         }
                         t_ws = output->current_workspace;
                         new_row = (direction == D_UP ? (t_ws->rows - 1) : 0);
                 }
 
-                check_colrow_boundaries();
+                CHECK_COLROW_BOUNDARIES;
 
                 DLOG("new_col = %d, new_row = %d\n", new_col, new_row);
                 if (t_ws->table[new_col][new_row]->currently_focused == NULL) {
@@ -208,15 +209,15 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
                         DLOG("container is at %d with width %d\n", container->x, container->width);
                         Output *output;
                         int destination_x = (direction == D_LEFT ? (container->x - 1) : (container->x + container->width + 1));
-                        if ((output = get_screen_containing(destination_x, container->y)) == NULL) {
+                        if ((output = get_output_containing(destination_x, container->y)) == NULL) {
                                 DLOG("Wrapping screen around horizontally\n");
-                                output = get_screen_most((direction == D_LEFT ? D_RIGHT : D_LEFT), container->workspace->output);
+                                output = get_output_most((direction == D_LEFT ? D_RIGHT : D_LEFT), container->workspace->output);
                         }
                         t_ws = output->current_workspace;
                         new_col = (direction == D_LEFT ? (t_ws->cols - 1) : 0);
                 }
 
-                check_colrow_boundaries();
+                CHECK_COLROW_BOUNDARIES;
 
                 DLOG("new_col = %d, new_row = %d\n", new_col, new_row);
                 if (t_ws->table[new_col][new_row]->currently_focused == NULL) {
@@ -235,7 +236,7 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
                 return;
         }
 
-        check_colrow_boundaries();
+        CHECK_COLROW_BOUNDARIES;
 
         if (t_ws->table[new_col][new_row]->currently_focused != NULL)
                 set_focus(conn, t_ws->table[new_col][new_row]->currently_focused, true);
@@ -1036,9 +1037,9 @@ void parse_command(xcb_connection_t *conn, const char *command) {
                 }
                 LOG("Switching mode for current container\n");
                 int new_mode = MODE_DEFAULT;
-                if (command[0] == 's')
+                if (command[0] == 's' && CUR_CELL->mode != MODE_STACK)
                         new_mode = MODE_STACK;
-                if (command[0] == 'T')
+                if (command[0] == 'T' && CUR_CELL->mode != MODE_TABBED)
                         new_mode = MODE_TABBED;
                 switch_layout_mode(conn, CUR_CELL, new_mode);
                 return;