aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorv44r <dv@v44r.com>2019-01-31 10:45:12 +0100
committeremersion <contact@emersion.fr>2019-01-31 15:37:57 +0100
commit204e1f47122d5a48865802dd1fb94fe0f05c2401 (patch)
tree313dd04af04ccdbbca2c8292e1b304a0ffb89ba7
parent1049f360e1d2eae1eb2c1306ca6320a5a9172810 (diff)
Rebase #1636 against current master
-rw-r--r--include/swaybar/i3bar.h2
-rw-r--r--swaybar/i3bar.c3
-rw-r--r--swaybar/render.c6
3 files changed, 9 insertions, 2 deletions
diff --git a/include/swaybar/i3bar.h b/include/swaybar/i3bar.h
index aa4415ff..5b6001ce 100644
--- a/include/swaybar/i3bar.h
+++ b/include/swaybar/i3bar.h
@@ -7,7 +7,7 @@
struct i3bar_block {
struct wl_list link; // status_link::blocks
int ref_count;
- char *full_text, *short_text, *align;
+ char *full_text, *short_text, *align, *min_width_str;
bool urgent;
uint32_t *color;
int min_width;
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c
index da93a132..43e2fe2d 100644
--- a/swaybar/i3bar.c
+++ b/swaybar/i3bar.c
@@ -21,6 +21,7 @@ void i3bar_block_unref(struct i3bar_block *block) {
free(block->full_text);
free(block->short_text);
free(block->align);
+ free(block->min_width_str);
free(block->name);
free(block->instance);
free(block->color);
@@ -78,7 +79,7 @@ static void i3bar_parse_json(struct status_line *status,
block->min_width = json_object_get_int(min_width);
} else if (type == json_type_string) {
/* the width will be calculated when rendering */
- block->min_width = 0;
+ block->min_width_str = strdup(json_object_get_string(min_width));
}
}
block->align = strdup(align ? json_object_get_string(align) : "left");
diff --git a/swaybar/render.c b/swaybar/render.c
index e27f7d4c..116cc595 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -159,6 +159,12 @@ static uint32_t render_status_block(cairo_t *cairo,
double ws_vertical_padding = config->status_padding * output->scale;
int width = text_width;
+ if (block->min_width_str) {
+ int w;
+ get_text_size(cairo, config->font, &w, NULL, NULL,
+ output->scale, block->markup, "%s", block->min_width_str);
+ block->min_width = w;
+ }
if (width < block->min_width) {
width = block->min_width;
}