summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog22
-rw-r--r--NEWS3
-rw-r--r--doc/ratpoison.texi5
-rw-r--r--src/actions.c32
-rw-r--r--src/actions.h7
-rw-r--r--src/globals.h4
-rw-r--r--src/group.c40
-rw-r--r--src/group.h1
-rw-r--r--src/manage.c2
-rw-r--r--src/split.c2
10 files changed, 110 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 82beb58..8ee4eaf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2003-08-22 Shawn Betts <sabetts@sfu.ca>
+
+ * src/split.c (remove_all_splits): only hide the windows in the
+ current screen.
+
+ * src/group.h (group_delete_group): new prototype
+
+ * src/group.c (group_last_window): find the last window in the
+ current screen.
+ (group_next_window): find next window in current screen.
+ (group_prev_window): find previous window in current screen.
+
+ * src/manage.c (force_maximize): call XSync() after first resize.
+
+ * src/globals.h (GROUP_DELETE_GROUP_OK): new define
+ (GROUP_DELETE_GROUP_NONEMPTY): likewise
+
+ * src/actions.h (cmd_gdelete): new prototype
+
+ * src/actions.c (user_commands): new command gdelete
+ (cmd_gdelete): new command
+
2003-08-10 Shawn Betts <sabetts@sfu.ca>
* src/editor.c (editor_enter): return EDIT_ABORT if there was an
diff --git a/NEWS b/NEWS
index 5e3f6d0..159cf44 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
ratpoison NEWS --- history of user-visible changes. -*- outline -*-
* Changes since 1.3.0-beta2
+** new command gdelete
+Delete a group.
+
** contrib/allwindows.sh script
A script that lists all groups and the windows in each group.
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index 0c5de9b..a4bc7f0 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -735,6 +735,11 @@ to select a frame whose number is greater than 9 unless the number is
passed as an argument.
@end deffn
+@deffn Command gdelete @var{group}
+Delete a group. @var{group} is optional. If it is not specified
+ratpoison will attempt to delete the current group. Only empty groups
+can be deleted. To empty a group see @command{gmerge}.
+
@deffn Command getenv @var{env}
Display the value of the environment variable, @var{env}.
@end deffn
diff --git a/src/actions.c b/src/actions.c
index 9b70e47..700ffd1 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -102,7 +102,8 @@ static user_command user_commands[] =
{"gprev", cmd_gprev, arg_VOID},
{"gnew", cmd_gnew, arg_VOID},
{"gnewbg", cmd_gnewbg, arg_VOID},
- {"gselect", cmd_gselect, arg_VOID},
+ {"gselect", cmd_gselect, arg_STRING},
+ {"gdelete", cmd_gdelete, arg_STRING},
{"groups", cmd_groups, arg_VOID},
{"gmove", cmd_gmove, arg_VOID},
{"gmerge", cmd_gmerge, arg_VOID},
@@ -3817,7 +3818,36 @@ cmd_listhook (int interactive, char *data)
free(buffer);
return tmp;
}
+}
+
+char *
+cmd_gdelete (int interactive, char *data)
+{
+ rp_group *g;
+ if (data == NULL)
+ g = rp_current_group;
+ else
+ {
+ g = find_group (data);
+ if (!g)
+ {
+ message (" gdelete: cannot find group ");
+ return NULL;
+ }
+ }
+
+ switch (group_delete_group (g))
+ {
+ case GROUP_DELETE_GROUP_OK:
+ break;
+ case GROUP_DELETE_GROUP_NONEMPTY:
+ message (" gdelete: non-empty group ");
+ break;
+ default:
+ message (" gdelete: Unknown return code (this shouldn't happen) ");
+ }
+ return NULL;
}
diff --git a/src/actions.h b/src/actions.h
index c899d4a..98a50d3 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -41,6 +41,7 @@ int spawn(char *data);
char * command (int interactive, char *data);
char *cmd_abort (int interactive, char *data);
+char *cmd_addhook (int interactive, char *data);
char *cmd_alias (int interactive, char *data);
char *cmd_banish (int interactive, char *data);
char *cmd_bind (int interactive, char *data);
@@ -77,6 +78,7 @@ char *cmd_focusright (int interactive, char *data);
char *cmd_focusup (int interactive, char *data);
char *cmd_frestore (int interactively, char *data);
char *cmd_fselect (int interactive, char *data);
+char *cmd_gdelete (int interactive, char *data);
char *cmd_getenv (int interactive, char *data);
char *cmd_gmerge (int interactive, char *data);
char *cmd_gmove (int interactive, char *data);
@@ -95,6 +97,7 @@ char *cmd_last (int interactive, char *data);
char *cmd_lastmsg (int interactive, char *data);
char *cmd_license (int interactive, char *data);
char *cmd_link (int interactive, char *data);
+char *cmd_listhook (int interactive, char *data);
char *cmd_meta (int interactive, char *data);
char *cmd_msgwait (int interactive, char *data);
char *cmd_newwm(int interactive, char *which);
@@ -109,6 +112,7 @@ char *cmd_prev_frame (int interactive, char *data);
char *cmd_prevscreen (int interactive, char *data);
char *cmd_quit(int interactive, char *data);
char *cmd_redisplay (int interactive, char *data);
+char *cmd_remhook (int interactive, char *data);
char *cmd_remove (int interactive, char *data);
char *cmd_rename (int interactive, char *data);
char *cmd_resize (int interactive, char *data);
@@ -132,9 +136,6 @@ char *cmd_verbexec (int interactive, char *data);
char *cmd_version (int interactive, char *data);
char *cmd_warp(int interactive, char *data);
char *cmd_windows (int interactive, char *data);
-char *cmd_addhook (int interactive, char *data);
-char *cmd_remhook (int interactive, char *data);
-char *cmd_listhook (int interactive, char *data);
void initialize_default_keybindings (void);
void free_keybindings ();
diff --git a/src/globals.h b/src/globals.h
index 7c25741..0bb5ba2 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -45,6 +45,10 @@
#define COMPLETION_NEXT 0
#define COMPLETION_PREVIOUS 1
+/* Error codes for group_delete_group() */
+#define GROUP_DELETE_GROUP_OK 0
+#define GROUP_DELETE_GROUP_NONEMPTY 1
+
/* The list of groups. */
extern struct list_head rp_groups;
diff --git a/src/group.c b/src/group.c
index 98923df..c4815ec 100644
--- a/src/group.c
+++ b/src/group.c
@@ -324,12 +324,14 @@ group_last_window (rp_group *g)
int last_access = 0;
rp_window_elem *most_recent = NULL;
rp_window_elem *cur;
+ rp_screen *s = current_screen();
list_for_each_entry (cur, &g->mapped_windows, node)
{
if (cur->win->last_access >= last_access
&& cur->win != current_window()
- && !find_windows_frame (cur->win))
+ && !find_windows_frame (cur->win)
+ && cur->win->scr == s)
{
most_recent = cur;
last_access = cur->win->last_access;
@@ -363,7 +365,7 @@ group_next_window (rp_group *g, rp_window *win)
cur != we;
cur = list_next_entry (cur, &g->mapped_windows, node))
{
- if (!find_windows_frame (cur->win))
+ if (!find_windows_frame (cur->win) && cur->win->scr == current_screen())
{
return cur->win;
}
@@ -393,7 +395,7 @@ group_prev_window (rp_group *g, rp_window *win)
cur != we;
cur = list_prev_entry (cur, &g->mapped_windows, node))
{
- if (!find_windows_frame (cur->win))
+ if (!find_windows_frame (cur->win) && cur->win->scr == current_screen())
{
return cur->win;
}
@@ -476,3 +478,35 @@ set_current_group (rp_group *g)
/* Call the switch group hook. */
hook_run (&rp_switch_group_hook);
}
+
+int
+group_delete_group (rp_group *g)
+{
+ if (list_empty (&(g->mapped_windows))
+ && list_empty (&(g->unmapped_windows)))
+ {
+ /* we can safely delete the group */
+ if (g == rp_current_group)
+ {
+ rp_current_group = group_next_group ();
+ }
+
+ 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);
+ rp_current_group = g;
+ list_add_tail (&g->node, &rp_groups);
+ }
+ return GROUP_DELETE_GROUP_OK;
+ }
+ else
+ {
+ return GROUP_DELETE_GROUP_NONEMPTY;
+ }
+}
+
diff --git a/src/group.h b/src/group.h
index 4104d6e..781c2ea 100644
--- a/src/group.h
+++ b/src/group.h
@@ -8,6 +8,7 @@ void group_add_window (rp_group *g, rp_window *w);
void group_resort_window (rp_group *g, rp_window_elem *w);
void group_free (rp_group *g);
rp_group *group_new (int number, char *name);
+int group_delete_group (rp_group *g);
void group_del_window (rp_group *g, rp_window *win);
void groups_del_window (rp_window *win);
diff --git a/src/manage.c b/src/manage.c
index 414b74a..2330721 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -705,6 +705,8 @@ force_maximize (rp_window *win)
XResizeWindow (dpy, win->w, win->width + 1, win->height + 1);
}
+ XSync (dpy, False);
+
/* Resize the window to its proper maximum size. */
XMoveResizeWindow (dpy, win->w, win->x, win->y, win->width, win->height);
XSetWindowBorderWidth (dpy, win->w, win->border);
diff --git a/src/split.c b/src/split.c
index c0405af..3345523 100644
--- a/src/split.c
+++ b/src/split.c
@@ -384,7 +384,7 @@ remove_all_splits ()
/* Hide all the windows not in the current frame. */
list_for_each_entry (win, &rp_mapped_window, node)
{
- if (win->frame_number != s->current_frame)
+ if (win->frame_number != s->current_frame && win->scr == s)
hide_window (win);
}