mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-11 05:33:55 -04:00
render: csd_title(): use render_osd() to render the current window title
This commit is contained in:
parent
bbc26da87b
commit
468587b67f
1 changed files with 25 additions and 11 deletions
36
render.c
36
render.c
|
|
@ -1643,26 +1643,40 @@ render_csd_title(struct terminal *term, const struct csd_data *info,
|
||||||
{
|
{
|
||||||
xassert(term->window->csd_mode == CSD_YES);
|
xassert(term->window->csd_mode == CSD_YES);
|
||||||
|
|
||||||
struct wl_surface *surf = term->window->csd.surface[CSD_SURF_TITLE].surf;
|
struct wl_surf_subsurf *surf = &term->window->csd.surface[CSD_SURF_TITLE];
|
||||||
xassert(info->width > 0 && info->height > 0);
|
xassert(info->width > 0 && info->height > 0);
|
||||||
|
|
||||||
xassert(info->width % term->scale == 0);
|
xassert(info->width % term->scale == 0);
|
||||||
xassert(info->height % term->scale == 0);
|
xassert(info->height % term->scale == 0);
|
||||||
|
|
||||||
uint32_t _color = term->conf->colors.fg;
|
uint32_t bg = term->conf->csd.color.title_set
|
||||||
uint16_t alpha = 0xffff;
|
? term->conf->csd.color.title
|
||||||
|
: 0xffu << 24 | term->conf->colors.fg;
|
||||||
|
uint32_t fg = term->conf->csd.color.buttons_set
|
||||||
|
? term->conf->csd.color.buttons
|
||||||
|
: term->conf->colors.bg;
|
||||||
|
|
||||||
if (term->conf->csd.color.title_set) {
|
if (!term->visual_focus) {
|
||||||
_color = term->conf->csd.color.title;
|
bg = color_dim(bg);
|
||||||
alpha = _color >> 24 | (_color >> 24 << 8);
|
fg = color_dim(fg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!term->visual_focus)
|
const wchar_t *title_text = L"";
|
||||||
_color = color_dim(_color);
|
wchar_t *_title_text = NULL;
|
||||||
|
|
||||||
pixman_color_t color = color_hex_to_pixman_with_alpha(_color, alpha);
|
int chars = mbstowcs(NULL, term->window_title, 0);
|
||||||
render_csd_part(term, surf, buf, info->width, info->height, &color);
|
if (chars >= 0) {
|
||||||
csd_commit(term, surf, buf);
|
_title_text = xmalloc((chars + 1) * sizeof(wchar_t));
|
||||||
|
mbstowcs(_title_text, term->window_title, chars + 1);
|
||||||
|
title_text = _title_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int margin = 10 * term->scale;
|
||||||
|
render_osd(term, surf->surf, surf->sub, buf, title_text, fg, bg,
|
||||||
|
margin, (buf->height - term->fonts[0]->height) / 2);
|
||||||
|
|
||||||
|
csd_commit(term, surf->surf, buf);
|
||||||
|
free(_title_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue