aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/ipc.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-11-28 11:23:48 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-11-28 11:24:14 -0500
commit1bd8463481c5272094a084a76ab558a45e18bd15 (patch)
treedcfac10d1996db167aba5e79059c41d1fff3f14f /swaybar/ipc.c
parentMerge pull request #3212 from martinetd/move_floating (diff)
downloadsway-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/ipc.c')
-rw-r--r--swaybar/ipc.c42
1 files changed, 41 insertions, 1 deletions
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