From: Michael Stapelberg Date: Sat, 11 Apr 2009 12:52:11 +0000 (+0200) Subject: Bugfix: Perform some bounds checking for snapped containers in fix_colrowspan (Thanks... X-Git-Tag: 3.a-bf1~44 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bb8727cf27738a580906fcbc83ae78d449aac8b7;p=i3%2Fi3 Bugfix: Perform some bounds checking for snapped containers in fix_colrowspan (Thanks jchome) This fixes ticket #22 --- diff --git a/src/handlers.c b/src/handlers.c index 88f7ec65..42f3b947 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -635,6 +635,8 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti if (client->container != NULL) cleanup_table(conn, client->container->workspace); + fix_colrowspan(conn, client->container->workspace); + /* Let’s see how many clients there are left on the workspace to delete it if it’s empty */ bool workspace_empty = true; FOR_TABLE(client->workspace) diff --git a/src/table.c b/src/table.c index 0bf7aa49..491d3bc8 100644 --- a/src/table.c +++ b/src/table.c @@ -296,7 +296,7 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) { } /* - * Fixes col/rowspan (makes sure there are no overlapping windows) + * Fixes col/rowspan (makes sure there are no overlapping windows, obeys borders). * */ void fix_colrowspan(xcb_connection_t *conn, Workspace *workspace) { @@ -305,16 +305,18 @@ void fix_colrowspan(xcb_connection_t *conn, Workspace *workspace) { FOR_TABLE(workspace) { Container *con = workspace->table[cols][rows]; if (con->colspan > 1) { - LOG("gots one with colspan %d\n", con->colspan); + LOG("gots one with colspan %d (at %d c, %d r)\n", con->colspan, cols, rows); while (con->colspan > 1 && - workspace->table[cols + (con->colspan - 1)][rows]->currently_focused != NULL) + (!cell_exists(cols + (con->colspan-1), rows) || + workspace->table[cols + (con->colspan - 1)][rows]->currently_focused != NULL)) con->colspan--; LOG("fixed it to %d\n", con->colspan); } if (con->rowspan > 1) { - LOG("gots one with rowspan %d\n", con->rowspan); + LOG("gots one with rowspan %d (at %d c, %d r)\n", con->rowspan, cols, rows); while (con->rowspan > 1 && - workspace->table[cols][rows + (con->rowspan - 1)]->currently_focused != NULL) + (!cell_exists(cols, rows + (con->rowspan - 1)) || + workspace->table[cols][rows + (con->rowspan - 1)]->currently_focused != NULL)) con->rowspan--; LOG("fixed it to %d\n", con->rowspan); }