diff options
author | emersion <contact@emersion.fr> | 2018-11-28 17:57:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-28 17:57:35 +0100 |
commit | 2c31e826755c74e530cfc9b70e3e028cfaa85918 (patch) | |
tree | dcfac10d1996db167aba5e79059c41d1fff3f14f /swaybar | |
parent | 5341e034df75f387184f85cb6a5fc0c95faf537e (diff) | |
parent | 1bd8463481c5272094a084a76ab558a45e18bd15 (diff) |
Merge pull request #3208 from RedSoxFan/bar-gaps
Implement bar gaps
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) { /* height */ config->height = 0; + /* gaps */ + config->gaps.top = 0; + config->gaps.right = 0; + config->gaps.bottom = 0; + config->gaps.left = 0; + /* colors */ config->colors.background = 0x000000FF; 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( return false; } json_object *markup, *mode, *hidden_state, *position, *status_command; - json_object *font, *bar_height, *wrap_scroll, *workspace_buttons; + json_object *font, *gaps, *bar_height, *wrap_scroll, *workspace_buttons; json_object *strip_workspace_numbers, *strip_workspace_name; json_object *binding_mode_indicator, *verbose, *colors, *sep_symbol; json_object *outputs, *bindings; @@ -162,6 +162,7 @@ static bool ipc_parse_config( json_object_object_get_ex(bar_config, "position", &position); json_object_object_get_ex(bar_config, "status_command", &status_command); json_object_object_get_ex(bar_config, "font", &font); + json_object_object_get_ex(bar_config, "gaps", &gaps); json_object_object_get_ex(bar_config, "bar_height", &bar_height); json_object_object_get_ex(bar_config, "wrap_scroll", &wrap_scroll); json_object_object_get_ex(bar_config, "workspace_buttons", &workspace_buttons); @@ -207,6 +208,24 @@ static bool ipc_parse_config( if (bar_height) { config->height = json_object_get_int(bar_height); } + if (gaps) { + json_object *top = json_object_object_get(gaps, "top"); + if (top) { + config->gaps.top = json_object_get_int(top); + } + json_object *right = json_object_object_get(gaps, "right"); + if (right) { + config->gaps.right = json_object_get_int(right); + } + json_object *bottom = json_object_object_get(gaps, "bottom"); + if (bottom) { + config->gaps.bottom = json_object_get_int(bottom); + } + json_object *left = json_object_object_get(gaps, "left"); + if (left) { + config->gaps.left = json_object_get_int(left); + } + } if (markup) { config->pango_markup = json_object_get_boolean(markup); } @@ -446,6 +465,27 @@ static bool handle_barconfig_update(struct swaybar *bar, config->mode = strdup(json_object_get_string(json_mode)); wlr_log(WLR_DEBUG, "Changing bar mode to %s", config->mode); + json_object *gaps; + json_object_object_get_ex(json_config, "gaps", &gaps); + if (gaps) { + json_object *top = json_object_object_get(gaps, "top"); + if (top) { + config->gaps.top = json_object_get_int(top); + } + json_object *right = json_object_object_get(gaps, "right"); + if (right) { + config->gaps.right = json_object_get_int(right); + } + json_object *bottom = json_object_object_get(gaps, "bottom"); + if (bottom) { + config->gaps.bottom = json_object_get_int(bottom); + } + json_object *left = json_object_object_get(gaps, "left"); + if (left) { + config->gaps.left = json_object_get_int(left); + } + } + return determine_bar_visibility(bar, true); } 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) { if (height != output->height || output->width == 0) { // Reconfigure surface zwlr_layer_surface_v1_set_size(output->layer_surface, 0, height); + zwlr_layer_surface_v1_set_margin(output->layer_surface, + output->bar->config->gaps.top, + output->bar->config->gaps.right, + output->bar->config->gaps.bottom, + output->bar->config->gaps.left); if (strcmp(output->bar->config->mode, "dock") == 0) { zwlr_layer_surface_v1_set_exclusive_zone(output->layer_surface, height); } |