From 3056caf6e32caf40e5ad8cd71051c9158931d014 Mon Sep 17 00:00:00 2001 From: Akos Horvath Date: Sat, 22 Oct 2022 21:34:14 +0200 Subject: [PATCH] add config variable for emtpy workspaces --- include/config_directives.h | 1 + include/configuration.h | 3 +++ src/config.c | 2 ++ src/config_directives.c | 4 ++++ src/main.c | 6 +++++- src/workspace.c | 6 +++--- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/config_directives.h b/include/config_directives.h index f910d591..03062820 100644 --- a/include/config_directives.h +++ b/include/config_directives.h @@ -51,6 +51,7 @@ CFGFUN(floating_maximum_size, const long width, const long height); CFGFUN(default_orientation, const char *orientation); CFGFUN(workspace_layout, const char *layout); CFGFUN(workspace_back_and_forth, const char *value); +CFGFUN(empty_workspaces, const char *value); CFGFUN(focus_follows_mouse, const char *value); CFGFUN(mouse_warping, const char *value); CFGFUN(focus_wrapping, const char *value); diff --git a/include/configuration.h b/include/configuration.h index 19d2f714..8abea9ce 100644 --- a/include/configuration.h +++ b/include/configuration.h @@ -119,6 +119,9 @@ struct Config { /** Default orientation for new containers */ int default_orientation; + /** Init empty workspaces on startup */ + bool empty_workspaces; + /** By default, focus follows mouse. If the user explicitly wants to * turn this off (and instead rely only on the keyboard for changing * focus), we allow them to do this with this relatively special option. diff --git a/src/config.c b/src/config.c index bf3ec6dc..61962a87 100644 --- a/src/config.c +++ b/src/config.c @@ -210,6 +210,8 @@ bool load_configuration(const char *override_configpath, config_load_t load_type config.show_marks = true; + config.empty_workspaces = false; + config.default_border = BS_NORMAL; config.default_floating_border = BS_NORMAL; config.default_border_width = logical_px(2); diff --git a/src/config_directives.c b/src/config_directives.c index 81adf351..a786b3c5 100644 --- a/src/config_directives.c +++ b/src/config_directives.c @@ -411,6 +411,10 @@ CFGFUN(hide_edge_borders, const char *borders) { config.hide_edge_borders = HEBM_NONE; } +CFGFUN(empty_workspaces, const char *value) { + config.empty_workspaces = boolstr(value); +} + CFGFUN(focus_follows_mouse, const char *value) { config.disable_focus_follows_mouse = !boolstr(value); } diff --git a/src/main.c b/src/main.c index 0f9f7151..d80bd4e3 100644 --- a/src/main.c +++ b/src/main.c @@ -1199,7 +1199,11 @@ int main(int argc, char *argv[]) { atexit(i3_exit); sd_notify(1, "READY=1"); - workspace_init(); + + if (config.empty_workspaces) { + workspace_init(); + } + ev_loop(main_loop, 0); /* Free these heap allocations just to satisfy LeakSanitizer. */ diff --git a/src/workspace.c b/src/workspace.c index c4caec88..ecca0be3 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -514,8 +514,9 @@ void workspace_show(Con *workspace) { * 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))) { + + if (old && TAILQ_EMPTY(&(old->nodes_head)) && TAILQ_EMPTY(&(old->floating_head)) + && !config.empty_workspaces) { 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); @@ -535,7 +536,6 @@ void workspace_show(Con *workspace) { ewmh_update_desktop_properties(); } } - */ workspace->fullscreen_mode = CF_OUTPUT; LOG("focused now = %p / %s\n", focused, focused->name);