Merge pull request #1453 from acrisci/feature/bar-update-font-reload
Update bar font config on reload
This commit is contained in:
commit
b7d3fe7b70
|
@ -159,6 +159,9 @@ void got_bar_config_update(char *event) {
|
||||||
if (found_id == NULL)
|
if (found_id == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* reconfigure the bar based on the current outputs */
|
||||||
|
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL);
|
||||||
|
|
||||||
free_colors(&(config.colors));
|
free_colors(&(config.colors));
|
||||||
|
|
||||||
/* update the configuration with the received settings */
|
/* update the configuration with the received settings */
|
||||||
|
@ -169,6 +172,8 @@ void got_bar_config_update(char *event) {
|
||||||
reconfig_windows(true);
|
reconfig_windows(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* update fonts and colors */
|
||||||
|
init_xcb_late(config.fontname);
|
||||||
init_colors(&(config.colors));
|
init_colors(&(config.colors));
|
||||||
realloc_sl_buffer();
|
realloc_sl_buffer();
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,8 @@ uint32_t get_mod_mask_for(uint32_t keysym,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a font for usage, also getting its height. If fallback is true,
|
* Loads a font for usage, also getting its height. If fallback is true,
|
||||||
* the fonts 'fixed' or '-misc-*' will be loaded instead of exiting.
|
* the fonts 'fixed' or '-misc-*' will be loaded instead of exiting. If any
|
||||||
|
* font was previously loaded, it will be freed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
i3Font load_font(const char *pattern, const bool fallback);
|
i3Font load_font(const char *pattern, const bool fallback);
|
||||||
|
@ -302,7 +303,8 @@ i3Font load_font(const char *pattern, const bool fallback);
|
||||||
void set_font(i3Font *font);
|
void set_font(i3Font *font);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources taken by the current font.
|
* Frees the resources taken by the current font. If no font was previously
|
||||||
|
* loaded, it simply returns.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void free_font(void);
|
void free_font(void);
|
||||||
|
|
15
libi3/font.c
15
libi3/font.c
|
@ -160,10 +160,14 @@ static int predict_text_width_pango(const char *text, size_t text_len) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loads a font for usage, also getting its metrics. If fallback is true,
|
* Loads a font for usage, also getting its metrics. If fallback is true,
|
||||||
* the fonts 'fixed' or '-misc-*' will be loaded instead of exiting.
|
* the fonts 'fixed' or '-misc-*' will be loaded instead of exiting. If any
|
||||||
|
* font was previously loaded, it will be freed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
i3Font load_font(const char *pattern, const bool fallback) {
|
i3Font load_font(const char *pattern, const bool fallback) {
|
||||||
|
/* if any font was previously loaded, free it now */
|
||||||
|
free_font();
|
||||||
|
|
||||||
i3Font font;
|
i3Font font;
|
||||||
font.type = FONT_TYPE_NONE;
|
font.type = FONT_TYPE_NONE;
|
||||||
|
|
||||||
|
@ -257,10 +261,15 @@ void set_font(i3Font *font) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Frees the resources taken by the current font.
|
* Frees the resources taken by the current font. If no font was previously
|
||||||
|
* loaded, it simply returns.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void free_font(void) {
|
void free_font(void) {
|
||||||
|
/* if there is no saved font, simply return */
|
||||||
|
if (savedFont == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
free(savedFont->pattern);
|
free(savedFont->pattern);
|
||||||
switch (savedFont->type) {
|
switch (savedFont->type) {
|
||||||
case FONT_TYPE_NONE:
|
case FONT_TYPE_NONE:
|
||||||
|
@ -283,6 +292,8 @@ void free_font(void) {
|
||||||
assert(false);
|
assert(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
savedFont = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue