diff options
Diffstat (limited to 'swaybar/render.c')
-rw-r--r-- | swaybar/render.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/swaybar/render.c b/swaybar/render.c index 7cbcea07..12dd3b07 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -35,7 +35,8 @@ static uint32_t render_status_line_error(cairo_t *cairo, | |||
35 | cairo_set_source_u32(cairo, 0xFF0000FF); | 35 | cairo_set_source_u32(cairo, 0xFF0000FF); |
36 | 36 | ||
37 | int margin = 3 * output->scale; | 37 | int margin = 3 * output->scale; |
38 | int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; | 38 | double ws_vertical_padding = |
39 | output->bar->config->status_padding * output->scale; | ||
39 | 40 | ||
40 | char *font = output->bar->config->font; | 41 | char *font = output->bar->config->font; |
41 | int text_width, text_height; | 42 | int text_width, text_height; |
@@ -44,7 +45,8 @@ static uint32_t render_status_line_error(cairo_t *cairo, | |||
44 | 45 | ||
45 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; | 46 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; |
46 | uint32_t ideal_surface_height = ideal_height / output->scale; | 47 | uint32_t ideal_surface_height = ideal_height / output->scale; |
47 | if (output->height < ideal_surface_height) { | 48 | if (!output->bar->config->height && |
49 | output->height < ideal_surface_height) { | ||
48 | return ideal_surface_height; | 50 | return ideal_surface_height; |
49 | } | 51 | } |
50 | *x -= text_width + margin; | 52 | *x -= text_width + margin; |
@@ -71,12 +73,13 @@ static uint32_t render_status_line_text(cairo_t *cairo, | |||
71 | get_text_size(cairo, config->font, &text_width, &text_height, NULL, | 73 | get_text_size(cairo, config->font, &text_width, &text_height, NULL, |
72 | output->scale, config->pango_markup, "%s", text); | 74 | output->scale, config->pango_markup, "%s", text); |
73 | 75 | ||
74 | int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; | 76 | double ws_vertical_padding = config->status_padding * output->scale; |
75 | int margin = 3 * output->scale; | 77 | int margin = 3 * output->scale; |
76 | 78 | ||
77 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; | 79 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; |
78 | uint32_t ideal_surface_height = ideal_height / output->scale; | 80 | uint32_t ideal_surface_height = ideal_height / output->scale; |
79 | if (output->height < ideal_surface_height) { | 81 | if (!output->bar->config->height && |
82 | output->height < ideal_surface_height) { | ||
80 | return ideal_surface_height; | 83 | return ideal_surface_height; |
81 | } | 84 | } |
82 | 85 | ||
@@ -153,7 +156,7 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
153 | output->scale, block->markup, "%s", block->full_text); | 156 | output->scale, block->markup, "%s", block->full_text); |
154 | 157 | ||
155 | int margin = 3 * output->scale; | 158 | int margin = 3 * output->scale; |
156 | double ws_vertical_padding = WS_VERTICAL_PADDING * 2 * output->scale; | 159 | double ws_vertical_padding = config->status_padding * output->scale; |
157 | 160 | ||
158 | int width = text_width; | 161 | int width = text_width; |
159 | if (width < block->min_width) { | 162 | if (width < block->min_width) { |
@@ -163,7 +166,8 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
163 | double block_width = width; | 166 | double block_width = width; |
164 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; | 167 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; |
165 | uint32_t ideal_surface_height = ideal_height / output->scale; | 168 | uint32_t ideal_surface_height = ideal_height / output->scale; |
166 | if (output->height < ideal_surface_height) { | 169 | if (!output->bar->config->height && |
170 | output->height < ideal_surface_height) { | ||
167 | return ideal_surface_height; | 171 | return ideal_surface_height; |
168 | } | 172 | } |
169 | 173 | ||
@@ -185,7 +189,8 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
185 | output->scale, false, "%s", config->sep_symbol); | 189 | output->scale, false, "%s", config->sep_symbol); |
186 | uint32_t _ideal_height = sep_height + ws_vertical_padding * 2; | 190 | uint32_t _ideal_height = sep_height + ws_vertical_padding * 2; |
187 | uint32_t _ideal_surface_height = _ideal_height / output->scale; | 191 | uint32_t _ideal_surface_height = _ideal_height / output->scale; |
188 | if (output->height < _ideal_surface_height) { | 192 | if (!output->bar->config->height && |
193 | output->height < _ideal_surface_height) { | ||
189 | return _ideal_surface_height; | 194 | return _ideal_surface_height; |
190 | } | 195 | } |
191 | if (sep_width > sep_block_width) { | 196 | if (sep_width > sep_block_width) { |
@@ -193,8 +198,8 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
193 | } | 198 | } |
194 | } | 199 | } |
195 | *x -= sep_block_width; | 200 | *x -= sep_block_width; |
196 | } else { | 201 | } else if (config->status_edge_padding) { |
197 | *x -= margin; | 202 | *x -= config->status_edge_padding * output->scale; |
198 | } | 203 | } |
199 | 204 | ||
200 | uint32_t height = output->height * output->scale; | 205 | uint32_t height = output->height * output->scale; |
@@ -212,8 +217,8 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
212 | } | 217 | } |
213 | 218 | ||
214 | double x_pos = *x; | 219 | double x_pos = *x; |
215 | double y_pos = WS_VERTICAL_PADDING * output->scale; | 220 | double y_pos = ws_vertical_padding; |
216 | double render_height = height - ws_vertical_padding + output->scale; | 221 | double render_height = height - ws_vertical_padding * 2; |
217 | 222 | ||
218 | uint32_t bg_color = block->urgent | 223 | uint32_t bg_color = block->urgent |
219 | ? config->colors.urgent_workspace.background : block->background; | 224 | ? config->colors.urgent_workspace.background : block->background; |
@@ -286,7 +291,7 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
286 | static uint32_t render_status_line_i3bar(cairo_t *cairo, | 291 | static uint32_t render_status_line_i3bar(cairo_t *cairo, |
287 | struct swaybar_output *output, double *x) { | 292 | struct swaybar_output *output, double *x) { |
288 | uint32_t max_height = 0; | 293 | uint32_t max_height = 0; |
289 | bool edge = true; | 294 | bool edge = *x == output->width * output->scale; |
290 | struct i3bar_block *block; | 295 | struct i3bar_block *block; |
291 | wl_list_for_each(block, &output->bar->status->blocks, link) { | 296 | wl_list_for_each(block, &output->bar->status->blocks, link) { |
292 | uint32_t h = render_status_block(cairo, output, block, x, edge); | 297 | uint32_t h = render_status_block(cairo, output, block, x, edge); |
@@ -332,7 +337,8 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo, | |||
332 | uint32_t ideal_height = text_height + ws_vertical_padding * 2 | 337 | uint32_t ideal_height = text_height + ws_vertical_padding * 2 |
333 | + border_width * 2; | 338 | + border_width * 2; |
334 | uint32_t ideal_surface_height = ideal_height / output->scale; | 339 | uint32_t ideal_surface_height = ideal_height / output->scale; |
335 | if (output->height < ideal_surface_height) { | 340 | if (!output->bar->config->height && |
341 | output->height < ideal_surface_height) { | ||
336 | return ideal_surface_height; | 342 | return ideal_surface_height; |
337 | } | 343 | } |
338 | 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; |
@@ -398,7 +404,8 @@ static uint32_t render_workspace_button(cairo_t *cairo, | |||
398 | uint32_t ideal_height = ws_vertical_padding * 2 + text_height | 404 | uint32_t ideal_height = ws_vertical_padding * 2 + text_height |
399 | + border_width * 2; | 405 | + border_width * 2; |
400 | uint32_t ideal_surface_height = ideal_height / output->scale; | 406 | uint32_t ideal_surface_height = ideal_height / output->scale; |
401 | if (output->height < ideal_surface_height) { | 407 | if (!output->bar->config->height && |
408 | output->height < ideal_surface_height) { | ||
402 | return ideal_surface_height; | 409 | return ideal_surface_height; |
403 | } | 410 | } |
404 | 411 | ||
@@ -525,7 +532,7 @@ void render_frame(struct swaybar_output *output) { | |||
525 | cairo_restore(cairo); | 532 | cairo_restore(cairo); |
526 | uint32_t height = render_to_cairo(cairo, output); | 533 | uint32_t height = render_to_cairo(cairo, output); |
527 | int config_height = output->bar->config->height; | 534 | int config_height = output->bar->config->height; |
528 | if (config_height >= 0 && height < (uint32_t)config_height) { | 535 | if (config_height > 0) { |
529 | height = config_height; | 536 | height = config_height; |
530 | } | 537 | } |
531 | if (height != output->height || output->width == 0) { | 538 | if (height != output->height || output->width == 0) { |