From: Fernando Tarlá Cardoso Lemos Date: Wed, 23 Nov 2011 23:12:36 +0000 (-0200) Subject: Invalidate cached pixmaps on reload and redraw. X-Git-Tag: 4.2~217 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=340592a532b5259c3a3f575de5a9639fad4d1459;p=i3%2Fi3 Invalidate cached pixmaps on reload and redraw. After a reload, the drawing parameters for the decorations might have changed, so we need to invalidate the cache and force a redraw of the currently visible decorations. Also, don't leak the previous font when reloading by freeing it before parsing the config. --- diff --git a/include/data.h b/include/data.h index 3bc425d9..40fffbfc 100644 --- a/include/data.h +++ b/include/data.h @@ -119,7 +119,6 @@ struct deco_render_params { Rect con_deco_rect; uint32_t background; bool con_is_leaf; - xcb_font_t font; }; /** diff --git a/include/libi3.h b/include/libi3.h index 17f8a5eb..b8ed6c31 100644 --- a/include/libi3.h +++ b/include/libi3.h @@ -186,6 +186,18 @@ uint32_t get_mod_mask_for(uint32_t keysym, */ i3Font load_font(const char *pattern, const bool fallback); +/** + * Defines the font to be used for the forthcoming calls. + * + */ +void set_font(i3Font *font); + +/** + * Frees the resources taken by the current font. + * + */ +void free_font(); + /** * Converts the given string to UTF-8 from UCS-2 big endian. The return value * must be freed after use. @@ -202,13 +214,6 @@ char *convert_ucs2_to_utf8(xcb_char2b_t *text, size_t num_glyphs); */ xcb_char2b_t *convert_utf8_to_ucs2(char *input, size_t *real_strlen); -/** - * Defines the font to be used for the forthcoming draw_text and - * predict_text_width calls. - * - */ -void set_font(i3Font *font); - /** * Defines the colors to be used for the forthcoming draw_text calls. * diff --git a/libi3/font.c b/libi3/font.c index 045972d9..5dfdf3d3 100644 --- a/libi3/font.c +++ b/libi3/font.c @@ -73,14 +73,24 @@ i3Font load_font(const char *pattern, const bool fallback) { } /* - * Defines the font to be used for the forthcoming draw_text and - * predict_text_width calls. + * Defines the font to be used for the forthcoming calls. * */ void set_font(i3Font *font) { savedFont = font; } +/* + * Frees the resources taken by the current font. + * + */ +void free_font() { + /* Close the font and free the info */ + xcb_close_font(conn, savedFont->id); + if (savedFont->info) + free(savedFont->info); +} + /* * Defines the colors to be used for the forthcoming draw_text calls. * diff --git a/src/config.c b/src/config.c index 2d7fb3bf..673f297e 100644 --- a/src/config.c +++ b/src/config.c @@ -320,6 +320,14 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, TAILQ_FOREACH(ws, workspaces, workspaces) workspace_set_name(ws, NULL); #endif + + /* Invalidate pixmap caches in case font or colors changed */ + Con *con; + TAILQ_FOREACH(con, &all_cons, all_cons) + FREE(con->deco_render_params); + + /* Get rid of the current font */ + free_font(); } SLIST_INIT(&modes); @@ -374,6 +382,13 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, set_font(&config.font); } + /* Redraw the currently visible decorations on reload, so that + * the possibly new drawing parameters changed. */ + if (reload) { + x_deco_recurse(croot); + xcb_flush(conn); + } + #if 0 /* Set an empty name for every workspace which got no name */ Workspace *ws; diff --git a/src/x.c b/src/x.c index aaa5b188..070fae91 100644 --- a/src/x.c +++ b/src/x.c @@ -307,7 +307,6 @@ void x_draw_decoration(Con *con) { p->con_deco_rect = con->deco_rect; p->background = config.client.background; p->con_is_leaf = con_is_leaf(con); - p->font = config.font.id; if (con->deco_render_params != NULL && (con->window == NULL || !con->window->name_x_changed) &&