summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-10-20 22:52:56 +0200
committerGitHub <noreply@github.com>2018-10-20 22:52:56 +0200
commit3f02218b54645a68a7496eb15b7bb16d26b75ae2 (patch)
tree55fe01811bc8ac0785ce9798335bfd15553fa708
parent6e6476c3d5b84edee57b5afb452d202d2fc283a6 (diff)
parent1844a5bafbf5a6ca0b40a1db4757d1bafb1805cd (diff)
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 fa761925c..71aff691e 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -28,7 +28,6 @@
static void bar_init(struct swaybar *bar) {
bar->config = init_config();
- bar->visible = true;
wl_list_init(&bar->outputs);
}
@@ -227,9 +226,6 @@ static void xdg_output_handle_done(void *data,
output->surface = wl_compositor_create_surface(bar->compositor);
assert(output->surface);
- if (bar->visible) {
- add_layer_surface(output);
- }
}
}
@@ -377,10 +373,15 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
pointer->cursor_surface = wl_compositor_create_surface(bar->compositor);
assert(pointer->cursor_surface);
+ bar->visible = true;
if (bar->config->workspace_buttons) {
- if (ipc_get_workspaces(bar)) {
- set_bar_dirty(bar);
+ ipc_get_workspaces(bar);
+ }
+ if (determine_bar_visibility(bar, false)) {
+ wl_list_for_each(output, &bar->outputs, link) {
+ add_layer_surface(output);
}
+ set_bar_dirty(bar);
}
return true;
}
diff --git a/swaybar/render.c b/swaybar/render.c
index 097eb4628..85e7542f8 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) {
}
cairo_paint(cairo);
- uint32_t max_height = 0;
+ int th;
+ get_text_size(cairo, config->font, NULL, &th, NULL, output->scale, false, "");
+ uint32_t max_height = (th + WS_VERTICAL_PADDING * 4) / output->scale;
/*
* Each render_* function takes the actual height of the bar, and returns
* the ideal height. If the actual height is too short, the render function