Make all programs use draw_text.
This commit is contained in:
committed by
Michael Stapelberg
parent
5c2088c87e
commit
eafc7af606
@ -193,7 +193,9 @@ void render_con(Con *con, bool render_fullscreen) {
|
||||
}
|
||||
|
||||
/* find the height for the decorations */
|
||||
int deco_height = config.font.height + 5;
|
||||
int deco_height = config.font.height + 4;
|
||||
if (config.font.height & 0x01)
|
||||
++deco_height;
|
||||
|
||||
/* precalculate the sizes to be able to correct rounding errors */
|
||||
int sizes[children];
|
||||
|
@ -50,12 +50,8 @@ static int sig_draw_window(xcb_window_t win, int width, int height, int font_hei
|
||||
xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ get_colorpixel("#FFFFFF") });
|
||||
|
||||
for (int i = 0; i < sizeof(crash_text) / sizeof(char*); i++) {
|
||||
int text_len = strlen(crash_text[i]);
|
||||
xcb_char2b_t *full_text = convert_utf8_to_ucs2(crash_text[i], &text_len);
|
||||
xcb_image_text_16(conn, text_len, pixmap, pixmap_gc, 8 /* X */,
|
||||
3 + (i + 1) * font_height /* Y = baseline of font */,
|
||||
(xcb_char2b_t*)full_text);
|
||||
free(full_text);
|
||||
draw_text(crash_text[i], strlen(crash_text[i]), false,
|
||||
pixmap, pixmap_gc, 8, 3 + (i - 1) * font_height);
|
||||
}
|
||||
|
||||
/* Copy the contents of the pixmap to the real window */
|
||||
|
38
src/x.c
38
src/x.c
@ -411,22 +411,15 @@ void x_draw_decoration(Con *con) {
|
||||
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
|
||||
uint32_t values[] = { p->color->text, p->color->background, config.font.id };
|
||||
xcb_change_gc(conn, parent->pm_gc, mask, values);
|
||||
int text_offset_y = config.font.height + (con->deco_rect.height - config.font.height) / 2 - 1;
|
||||
int text_offset_y = (con->deco_rect.height - config.font.height) / 2;
|
||||
|
||||
struct Window *win = con->window;
|
||||
if (win == NULL || win->name_x == NULL) {
|
||||
/* this is a non-leaf container, we need to make up a good description */
|
||||
// TODO: use a good description instead of just "another container"
|
||||
xcb_image_text_8(
|
||||
conn,
|
||||
strlen("another container"),
|
||||
parent->pixmap,
|
||||
parent->pm_gc,
|
||||
con->deco_rect.x + 2,
|
||||
con->deco_rect.y + text_offset_y,
|
||||
"another container"
|
||||
);
|
||||
|
||||
draw_text("another container", strlen("another container"), false,
|
||||
parent->pixmap, parent->pm_gc,
|
||||
con->deco_rect.x + 2, con->deco_rect.y + text_offset_y);
|
||||
goto copy_pixmaps;
|
||||
}
|
||||
|
||||
@ -447,26 +440,9 @@ void x_draw_decoration(Con *con) {
|
||||
//DLOG("indent_level = %d, indent_mult = %d\n", indent_level, indent_mult);
|
||||
int indent_px = (indent_level * 5) * indent_mult;
|
||||
|
||||
if (win->uses_net_wm_name)
|
||||
xcb_image_text_16(
|
||||
conn,
|
||||
win->name_len,
|
||||
parent->pixmap,
|
||||
parent->pm_gc,
|
||||
con->deco_rect.x + 2 + indent_px,
|
||||
con->deco_rect.y + text_offset_y,
|
||||
(xcb_char2b_t*)win->name_x
|
||||
);
|
||||
else
|
||||
xcb_image_text_8(
|
||||
conn,
|
||||
win->name_len,
|
||||
parent->pixmap,
|
||||
parent->pm_gc,
|
||||
con->deco_rect.x + 2 + indent_px,
|
||||
con->deco_rect.y + text_offset_y,
|
||||
win->name_x
|
||||
);
|
||||
draw_text(win->name_x, win->name_len, win->uses_net_wm_name,
|
||||
parent->pixmap, parent->pm_gc,
|
||||
con->deco_rect.x + 2 + indent_px, con->deco_rect.y + text_offset_y);
|
||||
|
||||
copy_pixmaps:
|
||||
xcb_copy_area(conn, con->pixmap, con->frame, con->pm_gc, 0, 0, 0, 0, con->rect.width, con->rect.height);
|
||||
|
Reference in New Issue
Block a user