2002-07-15 Emilio Lopes > * bar.c (marked_message): shift the bar so that the marked area is always visible. diff -ur ratpoison-1.1.1/src/bar.c ratpoison-1.1.1-ecl/src/bar.c --- ratpoison-1.1.1/src/bar.c Sun Feb 3 01:43:13 2002 +++ ratpoison-1.1.1-ecl/src/bar.c Mon Jul 15 10:14:00 2002 @@ -191,20 +191,6 @@ alarm (defaults.bar_timeout); alarm_signalled = 0; - XMoveResizeWindow (dpy, s->bar_window, - bar_x (s, width), bar_y (s), - width, - height); - - XRaiseWindow (dpy, s->bar_window); - XClearWindow (dpy, s->bar_window); - XSync (dpy, False); - XDrawString (dpy, s->bar_window, s->normal_gc, - defaults.bar_x_padding, - defaults.bar_y_padding + defaults.font->max_bounds.ascent, - msg, strlen (msg)); - XSync (dpy, False); - /* Crop to boundary conditions. */ if (mark_start < 0) mark_start = 0; @@ -226,12 +212,27 @@ mark_end = tmp; } - /* xor the string representing the current window */ - if (mark_start != mark_end) + + if (mark_start == mark_end) + { + XMoveResizeWindow (dpy, s->bar_window, + bar_x (s, width), bar_y (s), + width, height); + XRaiseWindow (dpy, s->bar_window); + XClearWindow (dpy, s->bar_window); + XSync (dpy, False); + XDrawString (dpy, s->bar_window, s->normal_gc, + defaults.bar_x_padding, + defaults.bar_y_padding + defaults.font->max_bounds.ascent, + msg, strlen (msg)); + XSync (dpy, False); + } + else { int start; int end; - int width; + int mark_width; + int barx = bar_x (s, width); if (mark_start == 0) start = 0; @@ -243,21 +244,55 @@ else end = XTextWidth (defaults.font, msg, mark_end) + defaults.bar_x_padding; - width = end - start; + mark_width = end - start; + + PRINT_DEBUG ("start = %d, end = %d, width = %d\n", start, end, mark_width); - PRINT_DEBUG ("start = %d, end = %d, width = %d\n", start, end, width); + /* Make sure the marked area is visible */ + if (width > s->root_attr.width) { +#ifdef WINDOW_LIST_CENTER_CURRENT + int dmid = barx + (start + end) / 2 - s->root_attr.width / 2; + if (dmid >= 0) + { + int dend = barx + width - s->root_attr.width; + barx = barx - (dmid <= dend ? dmid : dend); + } + else + { + dmid = -dmid; + barx = barx + (dmid <= -barx ? dmid : -barx); + } +#else + if (barx + start < 0) + barx = -start; + if (barx + end > s->root_attr.width) + barx = s->root_attr.width - end; +#endif + } + PRINT_DEBUG ("original bar_x = %d, new bar_x = %d\n", bar_x (s, width), barx); + + XMoveResizeWindow (dpy, s->bar_window, barx, bar_y (s), width, height); + XRaiseWindow (dpy, s->bar_window); + XClearWindow (dpy, s->bar_window); + XSync (dpy, False); + XDrawString (dpy, s->bar_window, s->normal_gc, + defaults.bar_x_padding, + defaults.bar_y_padding + defaults.font->max_bounds.ascent, + msg, strlen (msg)); + XSync (dpy, False); + /* xor the string representing the current window */ lgv.foreground = current_screen()->fg_color; lgv.function = GXxor; mask = GCForeground | GCFunction; lgc = XCreateGC(dpy, s->root, mask, &lgv); - XFillRectangle (dpy, s->bar_window, lgc, start, 0, width, height); + XFillRectangle (dpy, s->bar_window, lgc, start, 0, mark_width, height); lgv.foreground = s->bg_color; lgc = XCreateGC(dpy, s->root, mask, &lgv); - XFillRectangle (dpy, s->bar_window, lgc, start, 0, width, height); + XFillRectangle (dpy, s->bar_window, lgc, start, 0, mark_width, height); } /* Keep a record of the message. */ diff -ur ratpoison-1.1.1/src/conf.h ratpoison-1.1.1-ecl/src/conf.h --- ratpoison-1.1.1/src/conf.h Fri Feb 1 10:08:58 2002 +++ ratpoison-1.1.1-ecl/src/conf.h Mon Jul 15 10:02:33 2002 @@ -43,9 +43,13 @@ /* Number of history items to store. */ #define INPUT_MAX_HISTORY 50 +/* Try to center the current window when displaying the window + list. */ +#define WINDOW_LIST_CENTER_CURRENT + /* Treat windows with maxsize hints as if they were a transient window (don't hide the windows underneath, and center them) */ #define MAXSIZE_WINDOWS_ARE_TRANSIENTS