-
- /* TODO: for horizontal default layout, this has to be expanded to LEFT/RIGHT */
- if (direction == D_UP || direction == D_DOWN) {
- if (thing == THING_WINDOW)
- /* Let’s see if we can perform up/down focus in the current container */
- if (focus_window_in_container(conn, container, direction))
- return;
-
- if (direction == D_DOWN && cell_exists(current_col, current_row+1))
- new_row = current_row + t_ws->table[current_col][current_row]->rowspan;
- else if (direction == D_UP && cell_exists(current_col, current_row-1)) {
- /* Set new_row as a sane default, but it may get overwritten in a second */
- new_row--;
-
- /* Search from the top to correctly handle rowspanned containers */
- for (int rows = 0; rows < current_row; rows += t_ws->table[current_col][rows]->rowspan) {
- if (new_row > (rows + (t_ws->table[current_col][rows]->rowspan - 1)))
- continue;
-
- new_row = rows;
- break;
- }
- } else {
- /* Let’s see if there is a screen down/up there to which we can switch */
- LOG("container is at %d with height %d\n", container->y, container->height);
- i3Screen *screen;
- int destination_y = (direction == D_UP ? (container->y - 1) : (container->y + container->height + 1));
- if ((screen = get_screen_containing(container->x, destination_y)) == NULL) {
- LOG("Wrapping screen around vertically\n");
- /* No screen found? Then wrap */
- screen = get_screen_most((direction == D_UP ? D_DOWN : D_UP));
- }
- t_ws = &(workspaces[screen->current_workspace]);
- new_row = (direction == D_UP ? (t_ws->rows - 1) : 0);
- }
-
- check_colrow_boundaries();
-
- LOG("new_col = %d, new_row = %d\n", new_col, new_row);
- if (t_ws->table[new_col][new_row]->currently_focused == NULL) {
- LOG("Cell empty, checking for colspanned client above...\n");
- for (int cols = 0; cols < new_col; cols += t_ws->table[cols][new_row]->colspan) {
- if (new_col > (cols + (t_ws->table[cols][new_row]->colspan - 1)))
- continue;
-
- new_col = cols;
- break;
- }
- LOG("Fixed it to new col %d\n", new_col);
- }
- } else if (direction == D_LEFT || direction == D_RIGHT) {
- if (direction == D_RIGHT && cell_exists(current_col+1, current_row))
- new_col = current_col + t_ws->table[current_col][current_row]->colspan;
- else if (direction == D_LEFT && cell_exists(current_col-1, current_row)) {
- /* Set new_col as a sane default, but it may get overwritten in a second */
- new_col--;
-
- /* Search from the left to correctly handle colspanned containers */
- for (int cols = 0; cols < current_col; cols += t_ws->table[cols][current_row]->colspan) {
- if (new_col > (cols + (t_ws->table[cols][current_row]->colspan - 1)))
- continue;
-
- new_col = cols;
- break;
- }
- } else {
- /* Let’s see if there is a screen left/right here to which we can switch */
- LOG("container is at %d with width %d\n", container->x, container->width);
- i3Screen *screen;
- int destination_x = (direction == D_LEFT ? (container->x - 1) : (container->x + container->width + 1));
- if ((screen = get_screen_containing(destination_x, container->y)) == NULL) {
- LOG("Wrapping screen around horizontally\n");
- screen = get_screen_most((direction == D_LEFT ? D_RIGHT : D_LEFT));
- }
- t_ws = &(workspaces[screen->current_workspace]);
- new_col = (direction == D_LEFT ? (t_ws->cols - 1) : 0);
- }
-
- check_colrow_boundaries();
-
- LOG("new_col = %d, new_row = %d\n", new_col, new_row);
- if (t_ws->table[new_col][new_row]->currently_focused == NULL) {
- LOG("Cell empty, checking for rowspanned client above...\n");
- for (int rows = 0; rows < new_row; rows += t_ws->table[new_col][rows]->rowspan) {
- if (new_row > (rows + (t_ws->table[new_col][rows]->rowspan - 1)))
- continue;
-
- new_row = rows;
- break;
- }
- LOG("Fixed it to new row %d\n", new_row);
- }