summaryrefslogtreecommitdiff
path: root/bar.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2000-08-27 23:21:00 +0000
committersabetts <sabetts>2000-08-27 23:21:00 +0000
commit98a3dea008502975d0b4958a8dc2c4f37bfa6b80 (patch)
treeec6b94f9b93632859e314bb12f544ae01f413000 /bar.c
parent2f020a0d37e9bfb0b8ebc40062622ae4f200e4a1 (diff)
downloadratpoison-98a3dea008502975d0b4958a8dc2c4f37bfa6b80.zip
integrated the number sources. windows now keep the number they're
given.
Diffstat (limited to 'bar.c')
-rw-r--r--bar.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/bar.c b/bar.c
index 6554f9a..e7107d8 100644
--- a/bar.c
+++ b/bar.c
@@ -70,17 +70,15 @@ static int
calc_bar_width (XFontStruct *font)
{
char str[100]; /* window names are capped at 99 chars */
- int i;
int size = 1;
rp_window *cur;
- for (i=0, cur = rp_window_head; cur; cur = cur->next)
+ for (cur = rp_window_head; cur; cur = cur->next)
{
if (cur->state == STATE_UNMAPPED) continue;
- sprintf (str, "%d-%s", i, cur->name);
+ sprintf (str, "%d-%s", cur->number, cur->name);
size += 10 + XTextWidth (font, str, strlen (str));
- i++;
}
return size;
@@ -104,7 +102,6 @@ void
update_window_names (screen_info *s)
{
char str[100]; /* window names are capped at 99 chars */
- int i;
int width = calc_bar_width (s->font);
rp_window *cur;
int cur_x = 5;
@@ -119,11 +116,15 @@ update_window_names (screen_info *s)
XRaiseWindow (dpy, s->bar_window);
if (rp_window_head == NULL) return;
- for (i=0, cur = rp_window_head; cur; cur = cur->next)
+
+ /* Draw them in reverse order they were added in, so the oldest
+ windows appear on the left and the newest on the right end of the
+ program bar. */
+ for (cur = rp_window_tail; cur; cur = cur->prev)
{
if (cur->state == STATE_UNMAPPED) continue;
- sprintf (str, "%d-%s", i, cur->name);
+ sprintf (str, "%d-%s", cur->number, cur->name);
if ( rp_current_window == cur)
{
XDrawString (dpy, s->bar_window, s->bold_gc, cur_x,
@@ -136,6 +137,5 @@ update_window_names (screen_info *s)
}
cur_x += 10 + XTextWidth (s->font, str, strlen (str));
- i++;
}
}