aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-10-20 22:52:56 +0200
committerLibravatar GitHub <noreply@github.com>2018-10-20 22:52:56 +0200
commit3f02218b54645a68a7496eb15b7bb16d26b75ae2 (patch)
tree55fe01811bc8ac0785ce9798335bfd15553fa708
parentMerge pull request #2900 from Hi-Angel/master (diff)
parentswaybar: render with minimum height, nominally text height (diff)
downloadsway-1.0-beta.1.tar.gz
sway-1.0-beta.1.tar.zst
sway-1.0-beta.1.zip
Merge pull request #2901 from ianyfan/swaybar1.0-beta.1
swaybar: render with minimum height, nominally text height
-rw-r--r--swaybar/bar.c13
-rw-r--r--swaybar/render.c4
2 files changed, 10 insertions, 7 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index fa761925..71aff691 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -28,7 +28,6 @@
28 28
29static void bar_init(struct swaybar *bar) { 29static void bar_init(struct swaybar *bar) {
30 bar->config = init_config(); 30 bar->config = init_config();
31 bar->visible = true;
32 wl_list_init(&bar->outputs); 31 wl_list_init(&bar->outputs);
33} 32}
34 33
@@ -227,9 +226,6 @@ static void xdg_output_handle_done(void *data,
227 226
228 output->surface = wl_compositor_create_surface(bar->compositor); 227 output->surface = wl_compositor_create_surface(bar->compositor);
229 assert(output->surface); 228 assert(output->surface);
230 if (bar->visible) {
231 add_layer_surface(output);
232 }
233 } 229 }
234} 230}
235 231
@@ -377,10 +373,15 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
377 pointer->cursor_surface = wl_compositor_create_surface(bar->compositor); 373 pointer->cursor_surface = wl_compositor_create_surface(bar->compositor);
378 assert(pointer->cursor_surface); 374 assert(pointer->cursor_surface);
379 375
376 bar->visible = true;
380 if (bar->config->workspace_buttons) { 377 if (bar->config->workspace_buttons) {
381 if (ipc_get_workspaces(bar)) { 378 ipc_get_workspaces(bar);
382 set_bar_dirty(bar); 379 }
380 if (determine_bar_visibility(bar, false)) {
381 wl_list_for_each(output, &bar->outputs, link) {
382 add_layer_surface(output);
383 } 383 }
384 set_bar_dirty(bar);
384 } 385 }
385 return true; 386 return true;
386} 387}
diff --git a/swaybar/render.c b/swaybar/render.c
index 097eb462..85e7542f 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -448,7 +448,9 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaybar_output *output) {
448 } 448 }
449 cairo_paint(cairo); 449 cairo_paint(cairo);
450 450
451 uint32_t max_height = 0; 451 int th;
452 get_text_size(cairo, config->font, NULL, &th, NULL, output->scale, false, "");
453 uint32_t max_height = (th + WS_VERTICAL_PADDING * 4) / output->scale;
452 /* 454 /*
453 * Each render_* function takes the actual height of the bar, and returns 455 * Each render_* function takes the actual height of the bar, and returns
454 * the ideal height. If the actual height is too short, the render function 456 * the ideal height. If the actual height is too short, the render function