From: Michael Stapelberg Date: Fri, 16 Apr 2010 18:59:21 +0000 (+0200) Subject: clean up old workspace when switching (makes test 2 of t/16-*.t pass) X-Git-Tag: tree-pr1~254 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=138a790cd01b43d56bec0ba00abee08bcdeb230d;p=i3%2Fi3 clean up old workspace when switching (makes test 2 of t/16-*.t pass) --- 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);