]> git.sur5r.net Git - i3/i3/commitdiff
clean up old workspace when switching (makes test 2 of t/16-*.t pass)
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 16 Apr 2010 18:59:21 +0000 (20:59 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 16 Apr 2010 18:59:21 +0000 (20:59 +0200)
src/workspace.c

index 4d7922a87ee5961d4cc984e049fcc03cecd52c94..9b5593d6500e073bc88794dd2041a30d1eb871b4 100644 (file)
@@ -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);