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:
parent
67c2c03f76
commit
340592a532
|
@ -119,7 +119,6 @@ struct deco_render_params {
|
|||
Rect con_deco_rect;
|
||||
uint32_t background;
|
||||
bool con_is_leaf;
|
||||
xcb_font_t font;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
14
libi3/font.c
14
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.
|
||||
*
|
||||
|
|
15
src/config.c
15
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;
|
||||
|
|
1
src/x.c
1
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) &&
|
||||
|
|
Loading…
Reference in New Issue