From 62b0df06408029f86fdfe8d27a98f113943e7cc6 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 26 Jan 2013 09:55:38 +0100 Subject: [PATCH] Make i3-nagbar use the same font as configured for i3 --- include/libi3.h | 3 +++ libi3/font.c | 16 +++++++++++----- src/config_parser.c | 4 +++- src/key_press.c | 4 +++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/include/libi3.h b/include/libi3.h index 6714cc5b..53f3383d 100644 --- a/include/libi3.h +++ b/include/libi3.h @@ -47,6 +47,9 @@ struct Font { /** The height of the font, built from font_ascent + font_descent */ int height; + /** The pattern/name used to load the font. */ + char *pattern; + union { struct { /** The xcb-id for the font */ diff --git a/libi3/font.c b/libi3/font.c index a2162c47..8239b1f4 100644 --- a/libi3/font.c +++ b/libi3/font.c @@ -2,7 +2,7 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE) * */ #include @@ -143,13 +143,17 @@ i3Font load_font(const char *pattern, const bool fallback) { #if PANGO_SUPPORT /* Try to load a pango font if specified */ if (strlen(pattern) > strlen("pango:") && !strncmp(pattern, "pango:", strlen("pango:"))) { - pattern += strlen("pango:"); - if (load_pango_font(&font, pattern)) + const char *font_pattern = pattern + strlen("pango:"); + if (load_pango_font(&font, font_pattern)) { + font.pattern = sstrdup(pattern); return font; + } } else if (strlen(pattern) > strlen("xft:") && !strncmp(pattern, "xft:", strlen("xft:"))) { - pattern += strlen("xft:"); - if (load_pango_font(&font, pattern)) + const char *font_pattern = pattern + strlen("xft:"); + if (load_pango_font(&font, font_pattern)) { + font.pattern = sstrdup(pattern); return font; + } } #endif @@ -189,6 +193,7 @@ i3Font load_font(const char *pattern, const bool fallback) { } } + font.pattern = sstrdup(pattern); LOG("Using X font %s\n", pattern); /* Get information (height/name) for this font */ @@ -222,6 +227,7 @@ void set_font(i3Font *font) { * */ void free_font(void) { + free(savedFont->pattern); switch (savedFont->type) { case FONT_TYPE_NONE: /* Nothing to do */ diff --git a/src/config_parser.c b/src/config_parser.c index 7391896b..1cdc7acb 100644 --- a/src/config_parser.c +++ b/src/config_parser.c @@ -4,7 +4,7 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE) * * config_parser.c: hand-written parser to parse configuration directives. * @@ -1059,6 +1059,8 @@ void parse_file(const char *f) { sasprintf(&pageraction, "i3-sensible-pager \"%s\"\n", errorfilename); char *argv[] = { NULL, /* will be replaced by the executable path */ + "-f", + config.font.pattern, "-t", (context->has_errors ? "error" : "warning"), "-m", diff --git a/src/key_press.c b/src/key_press.c index ca5c3a0b..2f77a2a4 100644 --- a/src/key_press.c +++ b/src/key_press.c @@ -4,7 +4,7 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE) * * key_press.c: key press handler * @@ -145,6 +145,8 @@ void handle_key_press(xcb_key_press_event_t *event) { sasprintf(&pageraction, "i3-sensible-pager \"%s\"\n", errorfilename); char *argv[] = { NULL, /* will be replaced by the executable path */ + "-f", + config.font.pattern, "-t", "error", "-m", -- 2.39.5