diff options
-rw-r--r-- | src/actions.c | 3 | ||||
-rw-r--r-- | src/globals.h | 1 | ||||
-rw-r--r-- | src/group.c | 13 |
3 files changed, 8 insertions, 9 deletions
diff --git a/src/actions.c b/src/actions.c index 2aa53d1..292ffc4 100644 --- a/src/actions.c +++ b/src/actions.c @@ -5041,6 +5041,9 @@ cmd_gdelete (int interactive, struct cmdarg **args) case GROUP_DELETE_GROUP_NONEMPTY: return cmdret_new (RET_FAILURE, "gdelete: non-empty group"); break; + case GROUP_DELETE_LAST_GROUP: + return cmdret_new (RET_FAILURE, "gdelete: cannot delete the last group"); + break; default: return cmdret_new (RET_FAILURE, "gdelete: unknown return code (this shouldn't happen)"); } diff --git a/src/globals.h b/src/globals.h index b7aaa00..c56bbca 100644 --- a/src/globals.h +++ b/src/globals.h @@ -64,6 +64,7 @@ /* Error codes for group_delete_group() */ #define GROUP_DELETE_GROUP_OK 0 #define GROUP_DELETE_GROUP_NONEMPTY 1 +#define GROUP_DELETE_LAST_GROUP 2 /* The list of groups. */ extern struct list_head rp_groups; diff --git a/src/group.c b/src/group.c index 7f29bd8..4065db9 100644 --- a/src/group.c +++ b/src/group.c @@ -551,6 +551,10 @@ group_delete_group (rp_group *g) if (list_empty (&(g->mapped_windows)) && list_empty (&(g->unmapped_windows))) { + /* don't delete the last group */ + if (list_size (&rp_groups) == 1) + return GROUP_DELETE_LAST_GROUP; + /* we can safely delete the group */ if (g == rp_current_group) { @@ -560,15 +564,6 @@ group_delete_group (rp_group *g) list_del (&(g->node)); group_free (g); - - if (list_empty (&rp_groups)) - { - /* Create the first group in the list (We always need at least - one). */ - g = group_new (numset_request (group_numset), DEFAULT_GROUP_NAME); - set_current_group_1 (g); - list_add_tail (&g->node, &rp_groups); - } return GROUP_DELETE_GROUP_OK; } else |