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.
This commit is contained in:
Fernando Tarlá Cardoso Lemos 2011-11-23 21:12:36 -02:00 committed by Michael Stapelberg
parent 67c2c03f76
commit 340592a532
5 changed files with 39 additions and 11 deletions

View File

@ -119,7 +119,6 @@ struct deco_render_params {
Rect con_deco_rect; Rect con_deco_rect;
uint32_t background; uint32_t background;
bool con_is_leaf; bool con_is_leaf;
xcb_font_t font;
}; };
/** /**

View File

@ -186,6 +186,18 @@ uint32_t get_mod_mask_for(uint32_t keysym,
*/ */
i3Font load_font(const char *pattern, const bool fallback); 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 * Converts the given string to UTF-8 from UCS-2 big endian. The return value
* must be freed after use. * 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); 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. * Defines the colors to be used for the forthcoming draw_text calls.
* *

View File

@ -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 * Defines the font to be used for the forthcoming calls.
* predict_text_width calls.
* *
*/ */
void set_font(i3Font *font) { void set_font(i3Font *font) {
savedFont = 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. * Defines the colors to be used for the forthcoming draw_text calls.
* *

View File

@ -320,6 +320,14 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
TAILQ_FOREACH(ws, workspaces, workspaces) TAILQ_FOREACH(ws, workspaces, workspaces)
workspace_set_name(ws, NULL); workspace_set_name(ws, NULL);
#endif #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); SLIST_INIT(&modes);
@ -374,6 +382,13 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
set_font(&config.font); 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 #if 0
/* Set an empty name for every workspace which got no name */ /* Set an empty name for every workspace which got no name */
Workspace *ws; Workspace *ws;

View File

@ -307,7 +307,6 @@ void x_draw_decoration(Con *con) {
p->con_deco_rect = con->deco_rect; p->con_deco_rect = con->deco_rect;
p->background = config.client.background; p->background = config.client.background;
p->con_is_leaf = con_is_leaf(con); p->con_is_leaf = con_is_leaf(con);
p->font = config.font.id;
if (con->deco_render_params != NULL && if (con->deco_render_params != NULL &&
(con->window == NULL || !con->window->name_x_changed) && (con->window == NULL || !con->window->name_x_changed) &&