From 8fe84697f3e682c450203406db549976028071ce Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 4 Mar 2009 21:30:02 +0100 Subject: [PATCH] Bugfix: Correctly destroy and remove stack_windows when the container is cleaned up --- src/table.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/table.c b/src/table.c index abe63c7e..a3066f47 100644 --- a/src/table.c +++ b/src/table.c @@ -23,6 +23,7 @@ #include "data.h" #include "table.h" #include "util.h" +#include "i3.h" int current_workspace = 0; Workspace workspaces[10]; @@ -106,7 +107,7 @@ bool cell_exists(int col, int row) { (row >= 0 && row < c_ws->rows); } -static void move_columns_from(Workspace *workspace, int cols) { +static void move_columns_from(xcb_connection_t *conn, Workspace *workspace, int cols) { for (; cols < workspace->cols; cols++) for (int rows = 0; rows < workspace->rows; rows++) { Container *old_container = workspace->table[cols-1][rows], @@ -117,6 +118,13 @@ static void move_columns_from(Workspace *workspace, int cols) { CIRCLEQ_FOREACH(client, &(old_container->clients), clients) client->container = new_container; + struct Stack_Window *stack_win; + SLIST_FOREACH(stack_win, &stack_wins, stack_windows) + if (stack_win == &(old_container->stack_win)) { + xcb_destroy_window(conn, stack_win->window); + SLIST_REMOVE(&stack_wins, stack_win, Stack_Window, stack_windows); + } + free(old_container); printf("moving cols = %d to cols -1 = %d\n", cols, cols-1); @@ -129,7 +137,7 @@ static void move_columns_from(Workspace *workspace, int cols) { } } -static void move_rows_from(Workspace *workspace, int rows) { +static void move_rows_from(xcb_connection_t *conn, Workspace *workspace, int rows) { for (; rows < workspace->rows; rows++) for (int cols = 0; cols < workspace->cols; cols++) { Container *old_container = workspace->table[cols][rows-1], @@ -140,6 +148,13 @@ static void move_rows_from(Workspace *workspace, int rows) { CIRCLEQ_FOREACH(client, &(old_container->clients), clients) client->container = new_container; + struct Stack_Window *stack_win; + SLIST_FOREACH(stack_win, &stack_wins, stack_windows) + if (stack_win == &(old_container->stack_win)) { + xcb_destroy_window(conn, stack_win->window); + SLIST_REMOVE(&stack_wins, stack_win, Stack_Window, stack_windows); + } + free(old_container); printf("moving rows = %d to rows -1 = %d\n", rows, rows - 1); @@ -168,7 +183,7 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) { if (completely_empty) { printf("Removing completely empty column %d\n", cols); if (cols < (workspace->cols - 1)) - move_columns_from(workspace, cols+1); + move_columns_from(conn, workspace, cols+1); shrink_table_cols(workspace); if (workspace->current_col >= workspace->cols) @@ -187,7 +202,7 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) { if (completely_empty) { printf("Removing completely empty row %d\n", rows); if (rows < (workspace->rows - 1)) - move_rows_from(workspace, rows+1); + move_rows_from(conn, workspace, rows+1); shrink_table_rows(workspace); if (workspace->current_row >= workspace->rows)