aboutsummaryrefslogtreecommitdiff
path: root/swaybar
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar')
-rw-r--r--swaybar/config.c1
-rw-r--r--swaybar/ipc.c6
-rw-r--r--swaybar/render.c20
3 files changed, 24 insertions, 3 deletions
diff --git a/swaybar/config.c b/swaybar/config.c
index 52297310..abedaec0 100644
--- a/swaybar/config.c
+++ b/swaybar/config.c
@@ -35,6 +35,7 @@ struct swaybar_config *init_config(void) {
config->binding_mode_indicator = true;
config->wrap_scroll = false;
config->workspace_buttons = true;
+ config->workspace_min_width = 0;
config->bindings = create_list();
wl_list_init(&config->outputs);
config->status_padding = 1;
diff --git a/swaybar/ipc.c b/swaybar/ipc.c
index 6aa604eb..6bbe9408 100644
--- a/swaybar/ipc.c
+++ b/swaybar/ipc.c
@@ -270,6 +270,12 @@ static bool ipc_parse_config(
config->workspace_buttons = json_object_get_boolean(workspace_buttons);
}
+ json_object *workspace_min_width =
+ json_object_object_get(bar_config, "workspace_min_width");
+ if (workspace_min_width) {
+ config->workspace_min_width = json_object_get_int(workspace_min_width);
+ }
+
json_object *wrap_scroll = json_object_object_get(bar_config, "wrap_scroll");
if (wrap_scroll) {
config->wrap_scroll = json_object_get_boolean(wrap_scroll);
diff --git a/swaybar/render.c b/swaybar/render.c
index 3a626e1c..8f38174f 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -402,7 +402,11 @@ static uint32_t predict_workspace_button_length(cairo_t *cairo,
return 0;
}
- return ws_horizontal_padding * 2 + text_width + border_width * 2;
+ uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
+ if (width < config->workspace_min_width * output->scale) {
+ width = config->workspace_min_width * output->scale;
+ }
+ return width;
}
static uint32_t predict_workspace_buttons_length(cairo_t *cairo,
@@ -446,7 +450,11 @@ static uint32_t predict_binding_mode_indicator_length(cairo_t *cairo,
output->height < ideal_surface_height) {
return 0;
}
- return text_width + ws_horizontal_padding * 2 + border_width * 2;
+ uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
+ if (width < config->workspace_min_width * output->scale) {
+ width = config->workspace_min_width * output->scale;
+ }
+ return width;
}
static uint32_t render_status_line_i3bar(cairo_t *cairo,
@@ -518,6 +526,9 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
return ideal_surface_height;
}
uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
+ if (width < config->workspace_min_width * output->scale) {
+ width = config->workspace_min_width * output->scale;
+ }
uint32_t height = output->height * output->scale;
cairo_set_source_u32(cairo, config->colors.binding_mode.background);
@@ -585,7 +596,10 @@ static uint32_t render_workspace_button(cairo_t *cairo,
return ideal_surface_height;
}
- uint32_t width = ws_horizontal_padding * 2 + text_width + border_width * 2;
+ uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
+ if (width < config->workspace_min_width * output->scale) {
+ width = config->workspace_min_width * output->scale;
+ }
cairo_set_source_u32(cairo, box_colors.background);
cairo_rectangle(cairo, *x, 0, width, height);