From 05d14d6386222f5c1ff36752160afd68aebdb113 Mon Sep 17 00:00:00 2001
From: Daniel Mueller <deso@posteo.net>
Date: Fri, 29 Sep 2017 21:13:37 -0700
Subject: [PATCH 01/14] Do not close unused workspaces

i3 takes dynamics a bit too far for my taste: with the deletion of every
unused workspace it quickly becomes non-obvious which workspaces numbers
are used. A quick glance at the workspace list no longer is enough to
determine which workspace you are on, you have to read the number in
addition.
This change removes some of those dynamics by no longer causing i3 to
remove unused workspaces. Once created, a workspace is there to stay.
---
 src/con.c       | 12 ------------
 src/workspace.c | 27 ---------------------------
 2 files changed, 39 deletions(-)

diff --git a/src/con.c b/src/con.c
index b9b38e..871915 100644
--- a/src/con.c
+++ b/src/con.c
@@ -2217,18 +2217,6 @@ static void con_on_remove_child(Con *con) {
 
     /* For workspaces, close them only if they're not visible anymore */
     if (con->type == CT_WORKSPACE) {
-        if (TAILQ_EMPTY(&(con->focus_head)) && !workspace_is_visible(con)) {
-            LOG("Closing old workspace (%p / %s), it is empty\n", con, con->name);
-            yajl_gen gen = ipc_marshal_workspace_event("empty", con, NULL);
-            tree_close_internal(con, DONT_KILL_WINDOW, false);
-
-            const unsigned char *payload;
-            ylength length;
-            y(get_buf, &payload, &length);
-            ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
-
-            y(free);
-        }
         return;
     }
 
diff --git a/src/workspace.c b/src/workspace.c
index 4b7889..67dcd3 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -522,33 +522,6 @@ void workspace_show(Con *workspace) {
     ipc_send_workspace_event("focus", workspace, current);
 
     DLOG("old = %p / %s\n", old, (old ? old->name : "(null)"));
-    /* Close old workspace if necessary. This must be done *after* doing
-     * urgency handling, because tree_close_internal() will do a con_focus() on the next
-     * client, which will clear the urgency flag too early. Also, there is no
-     * way for con_focus() to know about when to clear urgency immediately and
-     * when to defer it. */
-    if (old && TAILQ_EMPTY(&(old->nodes_head)) && TAILQ_EMPTY(&(old->floating_head))) {
-        /* check if this workspace is currently visible */
-        if (!workspace_is_visible(old)) {
-            LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name);
-            yajl_gen gen = ipc_marshal_workspace_event("empty", old, NULL);
-            tree_close_internal(old, DONT_KILL_WINDOW, false);
-
-            const unsigned char *payload;
-            ylength length;
-            y(get_buf, &payload, &length);
-            ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
-
-            y(free);
-
-            /* Avoid calling output_push_sticky_windows later with a freed container. */
-            if (old == old_focus) {
-                old_focus = NULL;
-            }
-
-            ewmh_update_desktop_properties();
-        }
-    }
 
     workspace->fullscreen_mode = CF_OUTPUT;
     LOG("focused now = %p / %s\n", focused, focused->name);
-- 
2.52.0

