summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-09 20:58:00 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-09 20:58:00 -0500
commit124085eba96362403a757061032659c0a06aa22e (patch)
treef46fd9854bd80e0b29e8ddc67ab77e9dd614ac31
parentReset container dimensions when moving into workspace from direction (diff)
downloadsway-124085eba96362403a757061032659c0a06aa22e.tar.gz
sway-124085eba96362403a757061032659c0a06aa22e.tar.zst
sway-124085eba96362403a757061032659c0a06aa22e.zip
swaybar: obey height if given
If there is a bar height given, use that as the height rather than as a minimum height. This matches i3-gaps behavior.
-rw-r--r--sway/config/bar.c2
-rw-r--r--sway/sway-bar.5.scd2
-rw-r--r--swaybar/render.c20
3 files changed, 15 insertions, 9 deletions
diff --git a/sway/config/bar.c b/sway/config/bar.c
index 670219f1..069c0003 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -96,7 +96,7 @@ struct bar_config *default_bar_config(void) {
96 bar->pango_markup = false; 96 bar->pango_markup = false;
97 bar->swaybar_command = NULL; 97 bar->swaybar_command = NULL;
98 bar->font = NULL; 98 bar->font = NULL;
99 bar->height = -1; 99 bar->height = 0;
100 bar->workspace_buttons = true; 100 bar->workspace_buttons = true;
101 bar->wrap_scroll = false; 101 bar->wrap_scroll = false;
102 bar->separator_symbol = NULL; 102 bar->separator_symbol = NULL;
diff --git a/sway/sway-bar.5.scd b/sway/sway-bar.5.scd
index 2357591d..419c4427 100644
--- a/sway/sway-bar.5.scd
+++ b/sway/sway-bar.5.scd
@@ -69,7 +69,7 @@ Sway allows configuring swaybar in the sway configuration file.
69 use. 69 use.
70 70
71*height* <height> 71*height* <height>
72 Sets the height of the bar. Default height will match the font size. 72 Sets the height of the bar. Default height (0) will match the font size.
73 73
74*bindsym* [--release] button<n> <command> 74*bindsym* [--release] button<n> <command>
75 Executes _command_ when mouse button _n_ has been pressed (or if _released_ 75 Executes _command_ when mouse button _n_ has been pressed (or if _released_
diff --git a/swaybar/render.c b/swaybar/render.c
index 9fe4ee9c..e149d3a2 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -44,7 +44,8 @@ static uint32_t render_status_line_error(cairo_t *cairo,
44 44
45 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 45 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
46 uint32_t ideal_surface_height = ideal_height / output->scale; 46 uint32_t ideal_surface_height = ideal_height / output->scale;
47 if (output->height < ideal_surface_height) { 47 if (!output->bar->config->height &&
48 output->height < ideal_surface_height) {
48 return ideal_surface_height; 49 return ideal_surface_height;
49 } 50 }
50 *x -= text_width + margin; 51 *x -= text_width + margin;
@@ -76,7 +77,8 @@ static uint32_t render_status_line_text(cairo_t *cairo,
76 77
77 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 78 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
78 uint32_t ideal_surface_height = ideal_height / output->scale; 79 uint32_t ideal_surface_height = ideal_height / output->scale;
79 if (output->height < ideal_surface_height) { 80 if (!output->bar->config->height &&
81 output->height < ideal_surface_height) {
80 return ideal_surface_height; 82 return ideal_surface_height;
81 } 83 }
82 84
@@ -151,7 +153,8 @@ static uint32_t render_status_block(cairo_t *cairo,
151 double block_width = width; 153 double block_width = width;
152 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 154 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
153 uint32_t ideal_surface_height = ideal_height / output->scale; 155 uint32_t ideal_surface_height = ideal_height / output->scale;
154 if (output->height < ideal_surface_height) { 156 if (!output->bar->config->height &&
157 output->height < ideal_surface_height) {
155 return ideal_surface_height; 158 return ideal_surface_height;
156 } 159 }
157 160
@@ -173,7 +176,8 @@ static uint32_t render_status_block(cairo_t *cairo,
173 output->scale, false, "%s", config->sep_symbol); 176 output->scale, false, "%s", config->sep_symbol);
174 uint32_t _ideal_height = sep_height + ws_vertical_padding * 2; 177 uint32_t _ideal_height = sep_height + ws_vertical_padding * 2;
175 uint32_t _ideal_surface_height = _ideal_height / output->scale; 178 uint32_t _ideal_surface_height = _ideal_height / output->scale;
176 if (output->height < _ideal_surface_height) { 179 if (!output->bar->config->height &&
180 output->height < _ideal_surface_height) {
177 return _ideal_surface_height; 181 return _ideal_surface_height;
178 } 182 }
179 if (sep_width > sep_block_width) { 183 if (sep_width > sep_block_width) {
@@ -328,7 +332,8 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
328 uint32_t ideal_height = text_height + ws_vertical_padding * 2 332 uint32_t ideal_height = text_height + ws_vertical_padding * 2
329 + border_width * 2; 333 + border_width * 2;
330 uint32_t ideal_surface_height = ideal_height / output->scale; 334 uint32_t ideal_surface_height = ideal_height / output->scale;
331 if (output->height < ideal_surface_height) { 335 if (!output->bar->config->height &&
336 output->height < ideal_surface_height) {
332 return ideal_surface_height; 337 return ideal_surface_height;
333 } 338 }
334 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; 339 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
@@ -394,7 +399,8 @@ static uint32_t render_workspace_button(cairo_t *cairo,
394 uint32_t ideal_height = ws_vertical_padding * 2 + text_height 399 uint32_t ideal_height = ws_vertical_padding * 2 + text_height
395 + border_width * 2; 400 + border_width * 2;
396 uint32_t ideal_surface_height = ideal_height / output->scale; 401 uint32_t ideal_surface_height = ideal_height / output->scale;
397 if (output->height < ideal_surface_height) { 402 if (!output->bar->config->height &&
403 output->height < ideal_surface_height) {
398 return ideal_surface_height; 404 return ideal_surface_height;
399 } 405 }
400 406
@@ -521,7 +527,7 @@ void render_frame(struct swaybar_output *output) {
521 cairo_restore(cairo); 527 cairo_restore(cairo);
522 uint32_t height = render_to_cairo(cairo, output); 528 uint32_t height = render_to_cairo(cairo, output);
523 int config_height = output->bar->config->height; 529 int config_height = output->bar->config->height;
524 if (config_height >= 0 && height < (uint32_t)config_height) { 530 if (config_height > 0) {
525 height = config_height; 531 height = config_height;
526 } 532 }
527 if (height != output->height || output->width == 0) { 533 if (height != output->height || output->width == 0) {