diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-11-28 11:23:48 -0500 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-11-28 11:24:14 -0500 |
commit | 1bd8463481c5272094a084a76ab558a45e18bd15 (patch) | |
tree | dcfac10d1996db167aba5e79059c41d1fff3f14f /swaybar | |
parent | Merge pull request #3212 from martinetd/move_floating (diff) | |
download | sway-1bd8463481c5272094a084a76ab558a45e18bd15.tar.gz sway-1bd8463481c5272094a084a76ab558a45e18bd15.tar.zst sway-1bd8463481c5272094a084a76ab558a45e18bd15.zip |
Implement bar gaps
Adds the bar subcommand `gaps <amount>|<horizontal> <vertical>|<top>
<right> <bottom> <left>` to set gaps for swaybar. Due to restrictions on
margins for a layer_surface, only the sides that are anchored to an edge
of the screen can have gaps. Since there is support for per-side outer
gaps for workspaces, those should be able to be used instead for the
last side.
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/config.c | 6 | ||||
-rw-r--r-- | swaybar/ipc.c | 42 | ||||
-rw-r--r-- | swaybar/render.c | 5 |
3 files changed, 52 insertions, 1 deletions
diff --git a/swaybar/config.c b/swaybar/config.c index 16febb2e..10c78c8a 100644 --- a/swaybar/config.c +++ b/swaybar/config.c | |||
@@ -40,6 +40,12 @@ struct swaybar_config *init_config(void) { | |||
40 | /* height */ | 40 | /* height */ |
41 | config->height = 0; | 41 | config->height = 0; |
42 | 42 | ||
43 | /* gaps */ | ||
44 | config->gaps.top = 0; | ||
45 | config->gaps.right = 0; | ||
46 | config->gaps.bottom = 0; | ||
47 | config->gaps.left = 0; | ||
48 | |||
43 | /* colors */ | 49 | /* colors */ |
44 | config->colors.background = 0x000000FF; | 50 | config->colors.background = 0x000000FF; |
45 | config->colors.focused_background = 0x000000FF; | 51 | config->colors.focused_background = 0x000000FF; |
diff --git a/swaybar/ipc.c b/swaybar/ipc.c index db4360c1..2b930786 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c | |||
@@ -153,7 +153,7 @@ static bool ipc_parse_config( | |||
153 | return false; | 153 | return false; |
154 | } | 154 | } |
155 | json_object *markup, *mode, *hidden_state, *position, *status_command; | 155 | json_object *markup, *mode, *hidden_state, *position, *status_command; |
156 | json_object *font, *bar_height, *wrap_scroll, *workspace_buttons; | 156 | json_object *font, *gaps, *bar_height, *wrap_scroll, *workspace_buttons; |
157 | json_object *strip_workspace_numbers, *strip_workspace_name; | 157 | json_object *strip_workspace_numbers, *strip_workspace_name; |
158 | json_object *binding_mode_indicator, *verbose, *colors, *sep_symbol; | 158 | json_object *binding_mode_indicator, *verbose, *colors, *sep_symbol; |
159 | json_object *outputs, *bindings; | 159 | json_object *outputs, *bindings; |
@@ -162,6 +162,7 @@ static bool ipc_parse_config( | |||
162 | json_object_object_get_ex(bar_config, "position", &position); | 162 | json_object_object_get_ex(bar_config, "position", &position); |
163 | json_object_object_get_ex(bar_config, "status_command", &status_command); | 163 | json_object_object_get_ex(bar_config, "status_command", &status_command); |
164 | json_object_object_get_ex(bar_config, "font", &font); | 164 | json_object_object_get_ex(bar_config, "font", &font); |
165 | json_object_object_get_ex(bar_config, "gaps", &gaps); | ||
165 | json_object_object_get_ex(bar_config, "bar_height", &bar_height); | 166 | json_object_object_get_ex(bar_config, "bar_height", &bar_height); |
166 | json_object_object_get_ex(bar_config, "wrap_scroll", &wrap_scroll); | 167 | json_object_object_get_ex(bar_config, "wrap_scroll", &wrap_scroll); |
167 | json_object_object_get_ex(bar_config, "workspace_buttons", &workspace_buttons); | 168 | json_object_object_get_ex(bar_config, "workspace_buttons", &workspace_buttons); |
@@ -207,6 +208,24 @@ static bool ipc_parse_config( | |||
207 | if (bar_height) { | 208 | if (bar_height) { |
208 | config->height = json_object_get_int(bar_height); | 209 | config->height = json_object_get_int(bar_height); |
209 | } | 210 | } |
211 | if (gaps) { | ||
212 | json_object *top = json_object_object_get(gaps, "top"); | ||
213 | if (top) { | ||
214 | config->gaps.top = json_object_get_int(top); | ||
215 | } | ||
216 | json_object *right = json_object_object_get(gaps, "right"); | ||
217 | if (right) { | ||
218 | config->gaps.right = json_object_get_int(right); | ||
219 | } | ||
220 | json_object *bottom = json_object_object_get(gaps, "bottom"); | ||
221 | if (bottom) { | ||
222 | config->gaps.bottom = json_object_get_int(bottom); | ||
223 | } | ||
224 | json_object *left = json_object_object_get(gaps, "left"); | ||
225 | if (left) { | ||
226 | config->gaps.left = json_object_get_int(left); | ||
227 | } | ||
228 | } | ||
210 | if (markup) { | 229 | if (markup) { |
211 | config->pango_markup = json_object_get_boolean(markup); | 230 | config->pango_markup = json_object_get_boolean(markup); |
212 | } | 231 | } |
@@ -446,6 +465,27 @@ static bool handle_barconfig_update(struct swaybar *bar, | |||
446 | config->mode = strdup(json_object_get_string(json_mode)); | 465 | config->mode = strdup(json_object_get_string(json_mode)); |
447 | wlr_log(WLR_DEBUG, "Changing bar mode to %s", config->mode); | 466 | wlr_log(WLR_DEBUG, "Changing bar mode to %s", config->mode); |
448 | 467 | ||
468 | json_object *gaps; | ||
469 | json_object_object_get_ex(json_config, "gaps", &gaps); | ||
470 | if (gaps) { | ||
471 | json_object *top = json_object_object_get(gaps, "top"); | ||
472 | if (top) { | ||
473 | config->gaps.top = json_object_get_int(top); | ||
474 | } | ||
475 | json_object *right = json_object_object_get(gaps, "right"); | ||
476 | if (right) { | ||
477 | config->gaps.right = json_object_get_int(right); | ||
478 | } | ||
479 | json_object *bottom = json_object_object_get(gaps, "bottom"); | ||
480 | if (bottom) { | ||
481 | config->gaps.bottom = json_object_get_int(bottom); | ||
482 | } | ||
483 | json_object *left = json_object_object_get(gaps, "left"); | ||
484 | if (left) { | ||
485 | config->gaps.left = json_object_get_int(left); | ||
486 | } | ||
487 | } | ||
488 | |||
449 | return determine_bar_visibility(bar, true); | 489 | return determine_bar_visibility(bar, true); |
450 | } | 490 | } |
451 | 491 | ||
diff --git a/swaybar/render.c b/swaybar/render.c index 8269a840..77cfecbf 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -506,6 +506,11 @@ void render_frame(struct swaybar_output *output) { | |||
506 | if (height != output->height || output->width == 0) { | 506 | if (height != output->height || output->width == 0) { |
507 | // Reconfigure surface | 507 | // Reconfigure surface |
508 | zwlr_layer_surface_v1_set_size(output->layer_surface, 0, height); | 508 | zwlr_layer_surface_v1_set_size(output->layer_surface, 0, height); |
509 | zwlr_layer_surface_v1_set_margin(output->layer_surface, | ||
510 | output->bar->config->gaps.top, | ||
511 | output->bar->config->gaps.right, | ||
512 | output->bar->config->gaps.bottom, | ||
513 | output->bar->config->gaps.left); | ||
509 | if (strcmp(output->bar->config->mode, "dock") == 0) { | 514 | if (strcmp(output->bar->config->mode, "dock") == 0) { |
510 | zwlr_layer_surface_v1_set_exclusive_zone(output->layer_surface, height); | 515 | zwlr_layer_surface_v1_set_exclusive_zone(output->layer_surface, height); |
511 | } | 516 | } |