From 138a790cd01b43d56bec0ba00abee08bcdeb230d Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 16 Apr 2010 20:59:21 +0200 Subject: [PATCH] clean up old workspace when switching (makes test 2 of t/16-*.t pass) --- src/workspace.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/workspace.c b/src/workspace.c index 4d7922a8..9b5593d6 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -33,7 +33,7 @@ Con *workspace_get(const char *num) { } } - LOG("should switch to ws %s\n", num); + LOG("getting ws %s\n", num); if (workspace == NULL) { LOG("need to create this one\n"); output = con_get_output(focused); @@ -96,7 +96,9 @@ bool workspace_is_visible(Workspace *ws) { * */ void workspace_show(const char *num) { - Con *workspace, *current; + Con *workspace, *current, *old; + + old = con_get_workspace(focused); workspace = workspace_get(num); workspace->fullscreen_mode = CF_OUTPUT; @@ -110,6 +112,12 @@ void workspace_show(const char *num) { while (!TAILQ_EMPTY(&(next->focus_head))) next = TAILQ_FIRST(&(next->focus_head)); + + if (TAILQ_EMPTY(&(old->nodes_head))) { + LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name); + tree_close(old); + } + con_focus(next); workspace->fullscreen_mode = CF_OUTPUT; LOG("focused now = %p / %s\n", focused, focused->name); -- 2.39.5