Bugfix: Correctly handle col-/rowspanned containers when setting focus (Thanks Ned)

This fixes ticket #34
This commit is contained in:
Michael Stapelberg 2009-05-09 19:59:36 +02:00
parent b7f94e9b5d
commit 610fabf873
1 changed files with 26 additions and 6 deletions

View File

@ -77,10 +77,20 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
return; return;
if (direction == D_DOWN && cell_exists(current_col, current_row+1)) if (direction == D_DOWN && cell_exists(current_col, current_row+1))
new_row++; new_row = current_row + t_ws->table[current_col][current_row]->rowspan;
else if (direction == D_UP && cell_exists(current_col, current_row-1)) 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--; new_row--;
else {
/* 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 {
/* Lets see if there is a screen down/up there to which we can switch */ /* Lets 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); LOG("container is at %d with height %d\n", container->y, container->height);
i3Screen *screen; i3Screen *screen;
@ -95,10 +105,20 @@ static void focus_thing(xcb_connection_t *conn, direction_t direction, thing_t t
} }
} else if (direction == D_LEFT || direction == D_RIGHT) { } else if (direction == D_LEFT || direction == D_RIGHT) {
if (direction == D_RIGHT && cell_exists(current_col+1, current_row)) if (direction == D_RIGHT && cell_exists(current_col+1, current_row))
new_col++; new_col = current_col + t_ws->table[current_col][current_row]->colspan;
else if (direction == D_LEFT && cell_exists(current_col-1, current_row)) 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--; new_col--;
else {
/* 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 {
/* Lets see if there is a screen left/right here to which we can switch */ /* Lets 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); LOG("container is at %d with width %d\n", container->x, container->width);
i3Screen *screen; i3Screen *screen;