diff options
author | Ian Fan <ianfan0@gmail.com> | 2018-10-12 20:23:01 +0100 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2018-10-14 13:33:12 +0100 |
commit | fed11d1c7b388e999414dd8cec4b8982ba5ce950 (patch) | |
tree | 06ab708d92e6727006aa8912a26a5b3851cc6cd4 /swaybar | |
parent | swaybar: only send initial workspace request if workspace buttons are enabled (diff) | |
download | sway-fed11d1c7b388e999414dd8cec4b8982ba5ce950.tar.gz sway-fed11d1c7b388e999414dd8cec4b8982ba5ce950.tar.zst sway-fed11d1c7b388e999414dd8cec4b8982ba5ce950.zip |
swaybar: move mode & mode_pango_markup to bar struct
This distinguishes the binding mode from the distinct config mode, as
well as removing mode_pango_markup from the config struct where it
should not be present.
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/bar.c | 1 | ||||
-rw-r--r-- | swaybar/ipc.c | 11 | ||||
-rw-r--r-- | swaybar/render.c | 14 |
3 files changed, 13 insertions, 13 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index ecf1bf82..77294136 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -631,4 +631,5 @@ void bar_teardown(struct swaybar *bar) { | |||
631 | status_line_free(bar->status); | 631 | status_line_free(bar->status); |
632 | } | 632 | } |
633 | free(bar->id); | 633 | free(bar->id); |
634 | free(bar->mode); | ||
634 | } | 635 | } |
diff --git a/swaybar/ipc.c b/swaybar/ipc.c index 26b7eca6..8568f957 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c | |||
@@ -386,12 +386,8 @@ bool handle_ipc_readable(struct swaybar *bar) { | |||
386 | json_object *json_change, *json_pango_markup; | 386 | json_object *json_change, *json_pango_markup; |
387 | if (json_object_object_get_ex(result, "change", &json_change)) { | 387 | if (json_object_object_get_ex(result, "change", &json_change)) { |
388 | const char *change = json_object_get_string(json_change); | 388 | const char *change = json_object_get_string(json_change); |
389 | free(bar->config->mode); | 389 | free(bar->mode); |
390 | if (strcmp(change, "default") == 0) { | 390 | bar->mode = strcmp(change, "default") != 0 ? strdup(change) : NULL; |
391 | bar->config->mode = NULL; | ||
392 | } else { | ||
393 | bar->config->mode = strdup(change); | ||
394 | } | ||
395 | } else { | 391 | } else { |
396 | wlr_log(WLR_ERROR, "failed to parse response"); | 392 | wlr_log(WLR_ERROR, "failed to parse response"); |
397 | json_object_put(result); | 393 | json_object_put(result); |
@@ -400,8 +396,7 @@ bool handle_ipc_readable(struct swaybar *bar) { | |||
400 | } | 396 | } |
401 | if (json_object_object_get_ex(result, | 397 | if (json_object_object_get_ex(result, |
402 | "pango_markup", &json_pango_markup)) { | 398 | "pango_markup", &json_pango_markup)) { |
403 | bar->config->mode_pango_markup = json_object_get_boolean( | 399 | bar->mode_pango_markup = json_object_get_boolean(json_pango_markup); |
404 | json_pango_markup); | ||
405 | } | 400 | } |
406 | json_object_put(result); | 401 | json_object_put(result); |
407 | break; | 402 | break; |
diff --git a/swaybar/render.c b/swaybar/render.c index 2a06a79b..d226ba32 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -296,11 +296,15 @@ static uint32_t render_status_line(cairo_t *cairo, | |||
296 | 296 | ||
297 | static uint32_t render_binding_mode_indicator(cairo_t *cairo, | 297 | static uint32_t render_binding_mode_indicator(cairo_t *cairo, |
298 | struct swaybar_output *output, double x) { | 298 | struct swaybar_output *output, double x) { |
299 | const char *mode = output->bar->mode; | ||
300 | if (!mode) { | ||
301 | return 0; | ||
302 | } | ||
303 | |||
299 | struct swaybar_config *config = output->bar->config; | 304 | struct swaybar_config *config = output->bar->config; |
300 | const char *mode = config->mode; | ||
301 | int text_width, text_height; | 305 | int text_width, text_height; |
302 | get_text_size(cairo, config->font, &text_width, &text_height, NULL, | 306 | get_text_size(cairo, config->font, &text_width, &text_height, NULL, |
303 | output->scale, config->mode_pango_markup, | 307 | output->scale, output->bar->mode_pango_markup, |
304 | "%s", mode); | 308 | "%s", mode); |
305 | 309 | ||
306 | int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; | 310 | int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; |
@@ -333,8 +337,8 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo, | |||
333 | double text_y = height / 2.0 - text_height / 2.0; | 337 | double text_y = height / 2.0 - text_height / 2.0; |
334 | cairo_set_source_u32(cairo, config->colors.binding_mode.text); | 338 | cairo_set_source_u32(cairo, config->colors.binding_mode.text); |
335 | cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y)); | 339 | cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y)); |
336 | pango_printf(cairo, config->font, output->scale, config->mode_pango_markup, | 340 | pango_printf(cairo, config->font, output->scale, |
337 | "%s", mode); | 341 | output->bar->mode_pango_markup, "%s", mode); |
338 | return output->height; | 342 | return output->height; |
339 | } | 343 | } |
340 | 344 | ||
@@ -465,7 +469,7 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaybar_output *output) { | |||
465 | max_height = h > max_height ? h : max_height; | 469 | max_height = h > max_height ? h : max_height; |
466 | } | 470 | } |
467 | } | 471 | } |
468 | if (config->binding_mode_indicator && config->mode) { | 472 | if (config->binding_mode_indicator) { |
469 | uint32_t h = render_binding_mode_indicator(cairo, output, x); | 473 | uint32_t h = render_binding_mode_indicator(cairo, output, x); |
470 | max_height = h > max_height ? h : max_height; | 474 | max_height = h > max_height ? h : max_height; |
471 | } | 475 | } |