aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar
diff options
context:
space:
mode:
authorLibravatar Tarmack <git@tarmack.eu>2020-10-03 15:45:26 +0200
committerLibravatar Simon Ser <contact@emersion.fr>2020-10-11 19:12:42 +0200
commit989123a2a5933367e5c7c39c3793f4814e026bf1 (patch)
tree8a13986177a3380b3d3c965ceb2526e6ceb9c88d /swaybar
parentxwayland: support views that change override-redirect status (diff)
downloadsway-989123a2a5933367e5c7c39c3793f4814e026bf1.tar.gz
sway-989123a2a5933367e5c7c39c3793f4814e026bf1.tar.zst
sway-989123a2a5933367e5c7c39c3793f4814e026bf1.zip
Add support for workspace_min_width bar option.
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) {
35 config->binding_mode_indicator = true; 35 config->binding_mode_indicator = true;
36 config->wrap_scroll = false; 36 config->wrap_scroll = false;
37 config->workspace_buttons = true; 37 config->workspace_buttons = true;
38 config->workspace_min_width = 0;
38 config->bindings = create_list(); 39 config->bindings = create_list();
39 wl_list_init(&config->outputs); 40 wl_list_init(&config->outputs);
40 config->status_padding = 1; 41 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(
270 config->workspace_buttons = json_object_get_boolean(workspace_buttons); 270 config->workspace_buttons = json_object_get_boolean(workspace_buttons);
271 } 271 }
272 272
273 json_object *workspace_min_width =
274 json_object_object_get(bar_config, "workspace_min_width");
275 if (workspace_min_width) {
276 config->workspace_min_width = json_object_get_int(workspace_min_width);
277 }
278
273 json_object *wrap_scroll = json_object_object_get(bar_config, "wrap_scroll"); 279 json_object *wrap_scroll = json_object_object_get(bar_config, "wrap_scroll");
274 if (wrap_scroll) { 280 if (wrap_scroll) {
275 config->wrap_scroll = json_object_get_boolean(wrap_scroll); 281 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,
402 return 0; 402 return 0;
403 } 403 }
404 404
405 return ws_horizontal_padding * 2 + text_width + border_width * 2; 405 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
406 if (width < config->workspace_min_width * output->scale) {
407 width = config->workspace_min_width * output->scale;
408 }
409 return width;
406} 410}
407 411
408static uint32_t predict_workspace_buttons_length(cairo_t *cairo, 412static uint32_t predict_workspace_buttons_length(cairo_t *cairo,
@@ -446,7 +450,11 @@ static uint32_t predict_binding_mode_indicator_length(cairo_t *cairo,
446 output->height < ideal_surface_height) { 450 output->height < ideal_surface_height) {
447 return 0; 451 return 0;
448 } 452 }
449 return text_width + ws_horizontal_padding * 2 + border_width * 2; 453 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
454 if (width < config->workspace_min_width * output->scale) {
455 width = config->workspace_min_width * output->scale;
456 }
457 return width;
450} 458}
451 459
452static uint32_t render_status_line_i3bar(cairo_t *cairo, 460static uint32_t render_status_line_i3bar(cairo_t *cairo,
@@ -518,6 +526,9 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
518 return ideal_surface_height; 526 return ideal_surface_height;
519 } 527 }
520 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; 528 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
529 if (width < config->workspace_min_width * output->scale) {
530 width = config->workspace_min_width * output->scale;
531 }
521 532
522 uint32_t height = output->height * output->scale; 533 uint32_t height = output->height * output->scale;
523 cairo_set_source_u32(cairo, config->colors.binding_mode.background); 534 cairo_set_source_u32(cairo, config->colors.binding_mode.background);
@@ -585,7 +596,10 @@ static uint32_t render_workspace_button(cairo_t *cairo,
585 return ideal_surface_height; 596 return ideal_surface_height;
586 } 597 }
587 598
588 uint32_t width = ws_horizontal_padding * 2 + text_width + border_width * 2; 599 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
600 if (width < config->workspace_min_width * output->scale) {
601 width = config->workspace_min_width * output->scale;
602 }
589 603
590 cairo_set_source_u32(cairo, box_colors.background); 604 cairo_set_source_u32(cairo, box_colors.background);
591 cairo_rectangle(cairo, *x, 0, width, height); 605 cairo_rectangle(cairo, *x, 0, width, height);