summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--NEWS5
-rw-r--r--doc/ratpoison.15
-rw-r--r--doc/ratpoison.texi6
-rw-r--r--src/actions.c35
-rw-r--r--src/actions.h2
-rw-r--r--src/bar.c56
-rw-r--r--src/conf.h4
8 files changed, 87 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog
index b847444..37046a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2002-02-01 Shawn Betts <sabetts@vcn.bc.ca>
+
+ * src/actions.c (command): bail out if alias recursion gets too deep.
+
+ * src/conf.h (MAX_ALIAS_RECURSIVE_DEPTH): new define
+
+ * src/bar.c (bar_x): update to work with all X11 gravity values.
+ (bar_y): likewise
+
+ * src/actions.c (cmd_defbargravity): Rename from
+ cmd_defbarloc. Dependant code updated.
+ (cmd_defbargravity): accept all gravity arguments.
+
2002-01-26 shawn <sabetts@vcn.bc.ca>
* configure.in: check for the vsnprintf function and stdarg.h
diff --git a/NEWS b/NEWS
index 34537b5..0ae37ab 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,11 @@
ratpoison NEWS --- history of user-visible changes. -*- outline -*-
* Changes since 1.0.0
+** defbarloc changed to defbargravity
+
** defbarloc
This command take a gravity argument just like the wingravity
-commands. Only north east, north west, south east, and south west
-locations are accepted.
+commands.
** new command defbarborder
This command allows you to customize the border width of ratpoison's
diff --git a/doc/ratpoison.1 b/doc/ratpoison.1
index 15367fa..40227fc 100644
--- a/doc/ratpoison.1
+++ b/doc/ratpoison.1
@@ -159,9 +159,8 @@ Set the border width for the bar.
When called non\-interactively with no arguments, the current
setting is returned.
.TP
-.B defbarloc \fILOC\fP
-Set the message bar location. \fILOC\fP can be one of `northeast', `northwest',
-`southeast', `southwest', or their abbreviations.
+.B defbargravity \fIG\fP
+Set the default alignment for the message bar. See the `gravity' command.
When called non\-interactively with no arguments, the current
setting is returned.
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index f83c0fc..c9c9af8 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -380,10 +380,8 @@ Run a ratpoison command.
@item curframe
Indicate which frame is the current frame.
-@item defbarloc @var{loc}
-Set the message bar location. @var{loc} can be one of
-@samp{northeast}, @samp{northwest}, @samp{southeast},
-@samp{southwest}, or their abbreviations.
+@item defbargravity @var{g}
+Set the default alignment for the message bar. See the @command{gravity} command.
When called non-interactively with no arguments, the current setting is
returned.
diff --git a/src/actions.c b/src/actions.c
index e0d4188..bbb50b9 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -85,7 +85,7 @@ static user_command user_commands[] =
/*@end (tag required for genrpbindings) */
/* Commands to set default behavior. */
- {"defbarloc", cmd_defbarloc, arg_STRING},
+ {"defbargravity", cmd_defbargravity, arg_STRING},
{"msgwait", cmd_msgwait, arg_STRING},
{"defborder", cmd_defborder, arg_STRING},
{"deffont", cmd_deffont, arg_STRING},
@@ -840,6 +840,8 @@ cmd_version (int interactive, void *data)
char *
command (int interactive, char *data)
{
+ /* This static counter is used to exit from recursive alias calls. */
+ static int alias_recursive_depth = 0;
char *result = NULL;
char *cmd, *rest;
char *input;
@@ -894,7 +896,12 @@ command (int interactive, char *data)
if (rest != NULL)
sbuf_printf_concat (s, " %s", rest);
- result = command (interactive, sbuf_get (s));
+ alias_recursive_depth++;
+ if (alias_recursive_depth >= MAX_ALIAS_RECURSIVE_DEPTH)
+ message (" command: alias recursion has exceeded maximum depth ");
+ else
+ result = command (interactive, sbuf_get (s));
+ alias_recursive_depth--;
sbuf_free (s);
goto done;
@@ -1695,37 +1702,27 @@ cmd_msgwait (int interactive, void *data)
}
char *
-cmd_defbarloc (int interactive, void *data)
+cmd_defbargravity (int interactive, void *data)
{
- int loc;
+ int gravity;
if (data == NULL && !interactive)
return xstrdup (wingravity_to_string (defaults.bar_location));
if (data == NULL)
{
- message (" defbarloc: One argument required ");
+ message (" defbargravity: One argument required ");
return NULL;
}
- if ((loc = parse_wingravity (data)) < 0)
+ if ((gravity = parse_wingravity (data)) < 0)
{
- message (" defbarloc: Bad location ");
+ message (" defbargravity: Bad location ");
return NULL;
}
-
- switch (loc)
+ else
{
- case NorthWestGravity:
- case NorthEastGravity:
- case SouthWestGravity:
- case SouthEastGravity:
- defaults.bar_location = loc;
- break;
-
- default:
- message (" defbarloc: Bad location ");
- break;
+ defaults.bar_location = gravity;
}
return NULL;
diff --git a/src/actions.h b/src/actions.h
index 5f76206..a727254 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -80,7 +80,7 @@ char * cmd_defwingravity (int interactive, void *data);
char * cmd_deftransgravity (int interactive, void *data);
char * cmd_defmaxsizegravity (int interactive, void *data);
char * cmd_msgwait (int interactive, void *data);
-char * cmd_defbarloc (int interactive, void *data);
+char * cmd_defbargravity (int interactive, void *data);
char * cmd_deffont (int interactive, void *data);
char * cmd_defpadding (int interactive, void *data);
char * cmd_defborder (int interactive, void *data);
diff --git a/src/bar.c b/src/bar.c
index 44aeac9..617eee2 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -82,21 +82,57 @@ show_bar (screen_info *s)
int
bar_x (screen_info *s, int width)
{
- if (defaults.bar_location == SouthEastGravity
- || defaults.bar_location == NorthEastGravity)
- return s->root_attr.width - width - defaults.bar_border_width * 2;
- else
- return 0;
+ int x = 0;
+
+ switch (defaults.bar_location)
+ {
+ case NorthWestGravity:
+ case WestGravity:
+ case SouthWestGravity:
+ x = 0;
+ break;
+ case NorthGravity:
+ case CenterGravity:
+ case SouthGravity:
+ x = (s->root_attr.width - width - defaults.bar_border_width * 2) / 2;
+ break;
+ case NorthEastGravity:
+ case EastGravity:
+ case SouthEastGravity:
+ x = s->root_attr.width - width - defaults.bar_border_width * 2;
+ break;
+ }
+
+ return x;
}
int
bar_y (screen_info *s)
{
- if (defaults.bar_location == NorthWestGravity
- || defaults.bar_location == NorthEastGravity )
- return 0;
- else
- return s->root_attr.height - (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2) - defaults.bar_border_width * 2;
+ int y = 0;
+
+ switch (defaults.bar_location)
+ {
+ case NorthEastGravity:
+ case NorthGravity:
+ case NorthWestGravity:
+ y = 0;
+ break;
+ case EastGravity:
+ case CenterGravity:
+ case WestGravity:
+ y = (s->root_attr.height - (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2)
+ - defaults.bar_border_width * 2) / 2;
+ break;
+ case SouthEastGravity:
+ case SouthGravity:
+ case SouthWestGravity:
+ y = (s->root_attr.height - (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2)
+ - defaults.bar_border_width * 2);
+ break;
+ }
+
+ return y;
}
void
diff --git a/src/conf.h b/src/conf.h
index fbe1871..ed6d7c2 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -47,6 +47,10 @@
(don't hide the windows underneath, and center them) */
#define MAXSIZE_WINDOWS_ARE_TRANSIENTS
+/* An alias command could recursively call inself infinitely. This
+ stops that behavior. */
+#define MAX_ALIAS_RECURSIVE_DEPTH 16
+
/* Pressing a key sends the mouse to the bottom right corner. This
doesn't work very well yet. */
/* #define HIDE_MOUSE */