diff -Naur --exclude tags ratpoison/doc/ratpoison.1 ratpoison.defbarloc/doc/ratpoison.1 --- ratpoison/doc/ratpoison.1 Sat Jan 26 09:55:34 2002 +++ ratpoison.defbarloc/doc/ratpoison.1 Mon Jan 28 22:31:22 2002 @@ -159,9 +159,8 @@ 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 -Naur --exclude tags ratpoison/doc/ratpoison.texi ratpoison.defbarloc/doc/ratpoison.texi --- ratpoison/doc/ratpoison.texi Sat Jan 26 09:55:34 2002 +++ ratpoison.defbarloc/doc/ratpoison.texi Mon Jan 28 22:18:27 2002 @@ -380,10 +380,8 @@ @item curframe Indicate which frame is the current frame. address@hidden defbarloc @var{loc} -Set the message bar location. @var{loc} can be one of address@hidden, @samp{northwest}, @samp{southeast}, address@hidden, or their abbreviations. address@hidden 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 -Naur --exclude tags ratpoison/src/actions.c ratpoison.defbarloc/src/actions.c --- ratpoison/src/actions.c Sat Jan 26 23:51:54 2002 +++ ratpoison.defbarloc/src/actions.c Mon Jan 28 22:33:34 2002 @@ -85,7 +85,7 @@ /address@hidden (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}, @@ -1695,37 +1695,27 @@ } 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 -Naur --exclude tags ratpoison/src/actions.h ratpoison.defbarloc/src/actions.h --- ratpoison/src/actions.h Thu Jan 24 21:57:44 2002 +++ ratpoison.defbarloc/src/actions.h Mon Jan 28 22:11:04 2002 @@ -80,7 +80,7 @@ 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 -Naur --exclude tags ratpoison/src/bar.c ratpoison.defbarloc/src/bar.c --- ratpoison/src/bar.c Thu Jan 24 21:57:44 2002 +++ ratpoison.defbarloc/src/bar.c Mon Jan 28 21:46:06 2002 @@ -82,21 +82,55 @@ 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