Bugfix: Correctly destroy and remove stack_windows when the container is cleaned up

This commit is contained in:
Michael Stapelberg 2009-03-04 21:30:02 +01:00
parent 0ce298250b
commit 8fe84697f3
1 changed files with 19 additions and 4 deletions

View File

@ -23,6 +23,7 @@
#include "data.h" #include "data.h"
#include "table.h" #include "table.h"
#include "util.h" #include "util.h"
#include "i3.h"
int current_workspace = 0; int current_workspace = 0;
Workspace workspaces[10]; Workspace workspaces[10];
@ -106,7 +107,7 @@ bool cell_exists(int col, int row) {
(row >= 0 && row < c_ws->rows); (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 (; cols < workspace->cols; cols++)
for (int rows = 0; rows < workspace->rows; rows++) { for (int rows = 0; rows < workspace->rows; rows++) {
Container *old_container = workspace->table[cols-1][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) CIRCLEQ_FOREACH(client, &(old_container->clients), clients)
client->container = new_container; 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); free(old_container);
printf("moving cols = %d to cols -1 = %d\n", cols, cols-1); 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 (; rows < workspace->rows; rows++)
for (int cols = 0; cols < workspace->cols; cols++) { for (int cols = 0; cols < workspace->cols; cols++) {
Container *old_container = workspace->table[cols][rows-1], 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) CIRCLEQ_FOREACH(client, &(old_container->clients), clients)
client->container = new_container; 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); free(old_container);
printf("moving rows = %d to rows -1 = %d\n", rows, rows - 1); 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) { if (completely_empty) {
printf("Removing completely empty column %d\n", cols); printf("Removing completely empty column %d\n", cols);
if (cols < (workspace->cols - 1)) if (cols < (workspace->cols - 1))
move_columns_from(workspace, cols+1); move_columns_from(conn, workspace, cols+1);
shrink_table_cols(workspace); shrink_table_cols(workspace);
if (workspace->current_col >= workspace->cols) if (workspace->current_col >= workspace->cols)
@ -187,7 +202,7 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
if (completely_empty) { if (completely_empty) {
printf("Removing completely empty row %d\n", rows); printf("Removing completely empty row %d\n", rows);
if (rows < (workspace->rows - 1)) if (rows < (workspace->rows - 1))
move_rows_from(workspace, rows+1); move_rows_from(conn, workspace, rows+1);
shrink_table_rows(workspace); shrink_table_rows(workspace);
if (workspace->current_row >= workspace->rows) if (workspace->current_row >= workspace->rows)