aboutsummaryrefslogtreecommitdiff
path: root/wayland.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-07-24 09:03:15 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-07-24 09:03:15 +0000
commitb8d68afbb9628c4dbe4104d24b5bf96e196ca926 (patch)
treefea320228976a4812869fb1ac9994a4c530b5b29 /wayland.c
parentreadme: add OSC-9 to list of supported OSC sequences (diff)
parentdoc: foot.ini: mention that csd.font is sized using the title bar size (diff)
Merge branch 'csd-title'
Closes #638
Diffstat (limited to 'wayland.c')
-rw-r--r--wayland.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/wayland.c b/wayland.c
index 0679dee3..a83ef59d 100644
--- a/wayland.c
+++ b/wayland.c
@@ -31,6 +31,36 @@
#include "xmalloc.h"
static void
+csd_reload_font(struct wl_window *win, int old_scale)
+{
+ struct terminal *term = win->term;
+ const struct config *conf = term->conf;
+
+ const int scale = term->scale;
+
+ bool enable_csd = win->csd_mode == CSD_YES && !win->is_fullscreen;
+ if (!enable_csd)
+ return;
+ if (win->csd.font != NULL && scale == old_scale)
+ return;
+
+ fcft_destroy(win->csd.font);
+
+ const char *patterns[conf->csd.font.count];
+ for (size_t i = 0; i < conf->csd.font.count; i++)
+ patterns[i] = conf->csd.font.arr[i].pattern;
+
+ char pixelsize[32];
+ snprintf(pixelsize, sizeof(pixelsize),
+ "pixelsize=%u", conf->csd.title_height * scale * 1 / 2);
+
+ LOG_DBG("loading CSD font \"%s:%s\" (old-scale=%d, scale=%d)",
+ patterns[0], pixelsize, old_scale, scale);
+
+ win->csd.font = fcft_from_name(conf->csd.font.count, patterns, pixelsize);
+}
+
+static void
csd_instantiate(struct wl_window *win)
{
struct wayland *wayl = win->term->wl;
@@ -46,6 +76,8 @@ csd_instantiate(struct wl_window *win)
win, win->csd.surface[CSD_SURF_TITLE].surf, &win->csd.surface[i]);
xassert(ret);
}
+
+ csd_reload_font(win, -1);
}
static void
@@ -53,6 +85,9 @@ csd_destroy(struct wl_window *win)
{
struct terminal *term = win->term;
+ fcft_destroy(term->window->csd.font);
+ term->window->csd.font = NULL;
+
for (size_t i = 0; i < ALEN(win->csd.surface); i++)
wayl_win_subsurface_destroy(&win->csd.surface[i]);
shm_purge(term->render.chains.csd);
@@ -294,6 +329,7 @@ update_term_for_output_change(struct terminal *term)
render_resize(term, term->width / term->scale, term->height / term->scale);
term_font_dpi_changed(term, old_scale);
term_font_subpixel_changed(term);
+ csd_reload_font(term->window, old_scale);
}
static void