void update_window_names (screen_info *s) { char str[100]; /* window names <= 99 char */ int i; int width = calc_bar_width (s->font); a_window *cur; int cur_x = 5; if (!s->bar_is_raised) return; XMoveResizeWindow (dpy, s->bar_window, bar_x (s, width), bar_y (s), width, (FONT_HEIGHT (s->font) + BAR_PADDING * 2)); XClearWindow (dpy, s->bar_window); XRaiseWindow (dpy, s->bar_window); if (a_window_head == NULL) return; for (i=0, cur = a_window_head; cur; cur = cur->next) { if (cur->state == STATE_UNMAPPED) continue; sprintf (str, "%d-%s", i, cur->name); if ( a_current_window == cur) { XDrawString (dpy, s->bar_window, s->bold_gc, cur_x, BAR_PADDING + s->font->max_bounds.ascent, str, strlen (str)); } else { XDrawString (dpy, s->bar_window, s->normal_gc, cur_x, BAR_PADDING + s->font->max_bounds.ascent, str, strlen (str)); } cur_x += 10 + XTextWidth (s->font, str, strlen (str)); i++; } }
/* Raise the bar and put it in the right spot */ static void prepare_bar (rp_screen *s, int width, int height, int multiline) { width = width < s->width ? width : s->width; height = height < s->height ? height : s->height; XMoveResizeWindow (dpy, s->bar_window, bar_x (s, width), bar_y (s, height), width, height); /* Map the bar if needed */ if (!s->bar_is_raised) { s->bar_is_raised = BAR_IS_MESSAGE; if (defaults.bar_sticky && !multiline) XMapWindow (dpy, s->bar_window); else XMapRaised (dpy, s->bar_window); /* Switch to the default colormap */ if (current_window()) XUninstallColormap (dpy, current_window()->colormap); XInstallColormap (dpy, s->def_cmap); } if (multiline || !defaults.bar_sticky) XRaiseWindow (dpy, s->bar_window); XClearWindow (dpy, s->bar_window); XSync (dpy, False); }
static void update_input_window (rp_screen *s, rp_input_line *line) { int prompt_width, input_width, total_width; int char_len = 0, height; GC lgc; XGCValues gcv; prompt_width = rp_text_width (s, line->prompt, -1); input_width = rp_text_width (s, line->buffer, line->length); total_width = defaults.bar_x_padding * 2 + prompt_width + input_width + MAX_FONT_WIDTH (defaults.font); height = (FONT_HEIGHT (s) + defaults.bar_y_padding * 2); if (RP_IS_UTF8_START (line->buffer[line->position])) do char_len++; while (RP_IS_UTF8_CONT (line->buffer[line->position + char_len])); else char_len = 1; if (total_width < defaults.input_window_size + prompt_width) { total_width = defaults.input_window_size + prompt_width; } XMoveResizeWindow (dpy, s->input_window, bar_x (s, total_width), bar_y (s, height), total_width, (FONT_HEIGHT (s) + defaults.bar_y_padding * 2)); XClearWindow (dpy, s->input_window); XSync (dpy, False); rp_draw_string (s, s->input_window, STYLE_NORMAL, defaults.bar_x_padding, defaults.bar_y_padding + FONT_ASCENT(s), line->prompt, -1); rp_draw_string (s, s->input_window, STYLE_NORMAL, defaults.bar_x_padding + prompt_width, defaults.bar_y_padding + FONT_ASCENT(s), line->buffer, line->length); gcv.function = GXxor; gcv.foreground = s->fg_color ^ s->bg_color; lgc = XCreateGC (dpy, s->input_window, GCFunction | GCForeground, &gcv); /* Draw a cheap-o cursor - MkIII */ XFillRectangle (dpy, s->input_window, lgc, defaults.bar_x_padding + prompt_width + rp_text_width (s, line->buffer, line->position), defaults.bar_y_padding, rp_text_width (s, &line->buffer[line->position], char_len), FONT_HEIGHT (s)); XFlush (dpy); XFreeGC (dpy, lgc); }