diff options
-rw-r--r-- | swaybar/main.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/swaybar/main.c b/swaybar/main.c index 243ef2a9..4d23e087 100644 --- a/swaybar/main.c +++ b/swaybar/main.c | |||
@@ -229,6 +229,17 @@ void bar_ipc_init(int outputi, const char *bar_id) { | |||
229 | desktop_shell_set_panel_position(registry->desktop_shell, parse_position(json_object_get_string(position))); | 229 | desktop_shell_set_panel_position(registry->desktop_shell, parse_position(json_object_get_string(position))); |
230 | } | 230 | } |
231 | 231 | ||
232 | if (bar_height) { | ||
233 | if (json_object_get_int(bar_height) == -1) { | ||
234 | int width, height; | ||
235 | get_text_size(window, &width, &height, "Test string for measuring purposes"); | ||
236 | window->height = height + MARGIN * 2; | ||
237 | } | ||
238 | else { | ||
239 | window->height = json_object_get_int(bar_height) + MARGIN * 2; | ||
240 | } | ||
241 | } | ||
242 | |||
232 | if (_colors) { | 243 | if (_colors) { |
233 | json_object *background, *statusline, *separator; | 244 | json_object *background, *statusline, *separator; |
234 | json_object *focused_workspace_border, *focused_workspace_bg, *focused_workspace_text; | 245 | json_object *focused_workspace_border, *focused_workspace_bg, *focused_workspace_text; |
@@ -321,7 +332,7 @@ void render() { | |||
321 | int width, height; | 332 | int width, height; |
322 | get_text_size(window, &width, &height, "%s", line); | 333 | get_text_size(window, &width, &height, "%s", line); |
323 | 334 | ||
324 | cairo_move_to(window->cairo, window->width - MARGIN - width, MARGIN); | 335 | cairo_move_to(window->cairo, window->width - MARGIN - width, (window->height - height) / 2 ); |
325 | pango_printf(window, "%s", line); | 336 | pango_printf(window, "%s", line); |
326 | 337 | ||
327 | // Workspaces | 338 | // Workspaces |
@@ -350,7 +361,7 @@ void render() { | |||
350 | cairo_stroke(window->cairo); | 361 | cairo_stroke(window->cairo); |
351 | 362 | ||
352 | cairo_set_source_u32(window->cairo, box_colors.text); | 363 | cairo_set_source_u32(window->cairo, box_colors.text); |
353 | cairo_move_to(window->cairo, x + MARGIN, MARGIN); | 364 | cairo_move_to(window->cairo, x + MARGIN, (window->height - height) / 2 ); |
354 | pango_printf(window, "%s", ws->name); | 365 | pango_printf(window, "%s", ws->name); |
355 | 366 | ||
356 | x += width + MARGIN * 2 + MARGIN; | 367 | x += width + MARGIN * 2 + MARGIN; |
@@ -466,6 +477,12 @@ int main(int argc, char **argv) { | |||
466 | 477 | ||
467 | int desired_output = atoi(argv[optind]); | 478 | int desired_output = atoi(argv[optind]); |
468 | struct output_state *output = registry->outputs->items[desired_output]; | 479 | struct output_state *output = registry->outputs->items[desired_output]; |
480 | |||
481 | window = window_setup(registry, output->width, 30, false); | ||
482 | if (!window) { | ||
483 | sway_abort("Failed to create window."); | ||
484 | } | ||
485 | desktop_shell_set_panel(registry->desktop_shell, output->output, window->surface); | ||
469 | 486 | ||
470 | bar_ipc_init(desired_output, bar_id); | 487 | bar_ipc_init(desired_output, bar_id); |
471 | 488 | ||
@@ -491,15 +508,6 @@ int main(int argc, char **argv) { | |||
491 | line[0] = '\0'; | 508 | line[0] = '\0'; |
492 | } | 509 | } |
493 | 510 | ||
494 | window = window_setup(registry, output->width, 30, false); | ||
495 | if (!window) { | ||
496 | sway_abort("Failed to create window."); | ||
497 | } | ||
498 | desktop_shell_set_panel(registry->desktop_shell, output->output, window->surface); | ||
499 | |||
500 | int width, height; | ||
501 | get_text_size(window, &width, &height, "Test string for measuring purposes"); | ||
502 | window->height = height + MARGIN * 2; | ||
503 | 511 | ||
504 | poll_for_update(); | 512 | poll_for_update(); |
505 | 513 | ||