summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2019-01-13 20:36:08 -0500
committerLibravatar GitHub <noreply@github.com>2019-01-13 20:36:08 -0500
commitfc93cd20dc108544c7cc8fced7aebed58c58a770 (patch)
tree87eb259f5f02c6bcf5240bf677d9569ee9e72518
parentMerge pull request #3398 from RedSoxFan/toggle-input-events (diff)
parentswaybar: obey height if given (diff)
downloadsway-fc93cd20dc108544c7cc8fced7aebed58c58a770.tar.gz
sway-fc93cd20dc108544c7cc8fced7aebed58c58a770.tar.zst
sway-fc93cd20dc108544c7cc8fced7aebed58c58a770.zip
Merge pull request #3397 from RedSoxFan/fix-swaybar-height
swaybar: obey height if given
-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 101562d1..701bf051 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 b345b392..e1a4a937 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 993c8228..12dd3b07 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -45,7 +45,8 @@ static uint32_t render_status_line_error(cairo_t *cairo,
45 45
46 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 46 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
47 uint32_t ideal_surface_height = ideal_height / output->scale; 47 uint32_t ideal_surface_height = ideal_height / output->scale;
48 if (output->height < ideal_surface_height) { 48 if (!output->bar->config->height &&
49 output->height < ideal_surface_height) {
49 return ideal_surface_height; 50 return ideal_surface_height;
50 } 51 }
51 *x -= text_width + margin; 52 *x -= text_width + margin;
@@ -77,7 +78,8 @@ static uint32_t render_status_line_text(cairo_t *cairo,
77 78
78 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 79 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
79 uint32_t ideal_surface_height = ideal_height / output->scale; 80 uint32_t ideal_surface_height = ideal_height / output->scale;
80 if (output->height < ideal_surface_height) { 81 if (!output->bar->config->height &&
82 output->height < ideal_surface_height) {
81 return ideal_surface_height; 83 return ideal_surface_height;
82 } 84 }
83 85
@@ -164,7 +166,8 @@ static uint32_t render_status_block(cairo_t *cairo,
164 double block_width = width; 166 double block_width = width;
165 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 167 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
166 uint32_t ideal_surface_height = ideal_height / output->scale; 168 uint32_t ideal_surface_height = ideal_height / output->scale;
167 if (output->height < ideal_surface_height) { 169 if (!output->bar->config->height &&
170 output->height < ideal_surface_height) {
168 return ideal_surface_height; 171 return ideal_surface_height;
169 } 172 }
170 173
@@ -186,7 +189,8 @@ static uint32_t render_status_block(cairo_t *cairo,
186 output->scale, false, "%s", config->sep_symbol); 189 output->scale, false, "%s", config->sep_symbol);
187 uint32_t _ideal_height = sep_height + ws_vertical_padding * 2; 190 uint32_t _ideal_height = sep_height + ws_vertical_padding * 2;
188 uint32_t _ideal_surface_height = _ideal_height / output->scale; 191 uint32_t _ideal_surface_height = _ideal_height / output->scale;
189 if (output->height < _ideal_surface_height) { 192 if (!output->bar->config->height &&
193 output->height < _ideal_surface_height) {
190 return _ideal_surface_height; 194 return _ideal_surface_height;
191 } 195 }
192 if (sep_width > sep_block_width) { 196 if (sep_width > sep_block_width) {
@@ -333,7 +337,8 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
333 uint32_t ideal_height = text_height + ws_vertical_padding * 2 337 uint32_t ideal_height = text_height + ws_vertical_padding * 2
334 + border_width * 2; 338 + border_width * 2;
335 uint32_t ideal_surface_height = ideal_height / output->scale; 339 uint32_t ideal_surface_height = ideal_height / output->scale;
336 if (output->height < ideal_surface_height) { 340 if (!output->bar->config->height &&
341 output->height < ideal_surface_height) {
337 return ideal_surface_height; 342 return ideal_surface_height;
338 } 343 }
339 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; 344 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
@@ -399,7 +404,8 @@ static uint32_t render_workspace_button(cairo_t *cairo,
399 uint32_t ideal_height = ws_vertical_padding * 2 + text_height 404 uint32_t ideal_height = ws_vertical_padding * 2 + text_height
400 + border_width * 2; 405 + border_width * 2;
401 uint32_t ideal_surface_height = ideal_height / output->scale; 406 uint32_t ideal_surface_height = ideal_height / output->scale;
402 if (output->height < ideal_surface_height) { 407 if (!output->bar->config->height &&
408 output->height < ideal_surface_height) {
403 return ideal_surface_height; 409 return ideal_surface_height;
404 } 410 }
405 411
@@ -526,7 +532,7 @@ void render_frame(struct swaybar_output *output) {
526 cairo_restore(cairo); 532 cairo_restore(cairo);
527 uint32_t height = render_to_cairo(cairo, output); 533 uint32_t height = render_to_cairo(cairo, output);
528 int config_height = output->bar->config->height; 534 int config_height = output->bar->config->height;
529 if (config_height >= 0 && height < (uint32_t)config_height) { 535 if (config_height > 0) {
530 height = config_height; 536 height = config_height;
531 } 537 }
532 if (height != output->height || output->width == 0) { 538 if (height != output->height || output->width == 0) {