summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAli Gholami Rudi <aliqrudi@gmail.com>2008-10-11 09:39:18 +0330
committerShawn <sabetts@juicebox.(none)>2008-10-12 17:11:55 -0700
commit4a180cb969833289eb2dd46548d594f6f37c8a87 (patch)
tree814a35bb6c9e8b8444e641328840e160f664d5c0 /src
parent098fc67c1a277286fc513ccb646e4054889063ab (diff)
downloadratpoison-4a180cb969833289eb2dd46548d594f6f37c8a87.zip
don't delete the last group
Currently gdelete deletes the last group and creates a new empty group. This patch changes gdelete to show a message, instead.
Diffstat (limited to 'src')
-rw-r--r--src/actions.c3
-rw-r--r--src/globals.h1
-rw-r--r--src/group.c13
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