mirror of
https://github.com/swaywm/sway.git
synced 2026-03-30 11:10:59 -04:00
Merge pull request #1636 from jrouleau/master
swaybar: correctly render min_width for strings
This commit is contained in:
commit
ef169fcaeb
3 changed files with 9 additions and 2 deletions
|
|
@ -17,7 +17,7 @@ struct status_line {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct status_block {
|
struct status_block {
|
||||||
char *full_text, *short_text, *align;
|
char *full_text, *short_text, *align, *min_width_str;
|
||||||
bool urgent;
|
bool urgent;
|
||||||
uint32_t color;
|
uint32_t color;
|
||||||
int min_width;
|
int min_width;
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,13 @@ static void render_block(struct window *window, struct config *config, struct st
|
||||||
int textwidth = width;
|
int textwidth = width;
|
||||||
double block_width = width;
|
double block_width = width;
|
||||||
|
|
||||||
|
if (block->min_width_str) {
|
||||||
|
int w, h;
|
||||||
|
get_text_size(window->cairo, window->font, &w, &h,
|
||||||
|
window->scale, block->markup, "%s", block->min_width_str);
|
||||||
|
block->min_width = w;
|
||||||
|
}
|
||||||
|
|
||||||
if (width < block->min_width) {
|
if (width < block->min_width) {
|
||||||
width = block->min_width;
|
width = block->min_width;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ static void parse_json(struct bar *bar, const char *text) {
|
||||||
new->min_width = json_object_get_int(min_width);
|
new->min_width = json_object_get_int(min_width);
|
||||||
} else if (type == json_type_string) {
|
} else if (type == json_type_string) {
|
||||||
/* the width will be calculated when rendering */
|
/* the width will be calculated when rendering */
|
||||||
new->min_width = 0;
|
new->min_width_str = strdup(json_object_get_string(min_width));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue