diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-04-03 22:52:40 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-04-03 22:52:40 -0400 |
commit | 38bdd4bdebc4938f25af90bc4f79e278f61808e0 (patch) | |
tree | f7500132c44c86713b4be66bcb8a6fd854678b20 /swaybar/render.c | |
parent | Adjust height calculation, naming (diff) | |
download | sway-38bdd4bdebc4938f25af90bc4f79e278f61808e0.tar.gz sway-38bdd4bdebc4938f25af90bc4f79e278f61808e0.tar.zst sway-38bdd4bdebc4938f25af90bc4f79e278f61808e0.zip |
Address review feedback
Diffstat (limited to 'swaybar/render.c')
-rw-r--r-- | swaybar/render.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/swaybar/render.c b/swaybar/render.c index 1f84fdba..be58301d 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -20,7 +20,7 @@ static const double BORDER_WIDTH = 1; | |||
20 | 20 | ||
21 | static uint32_t render_status_line_error(cairo_t *cairo, | 21 | static uint32_t render_status_line_error(cairo_t *cairo, |
22 | struct swaybar_output *output, struct swaybar_config *config, | 22 | struct swaybar_output *output, struct swaybar_config *config, |
23 | const char *error, double *x, uint32_t width, uint32_t surface_height) { | 23 | const char *error, double *x, uint32_t surface_height) { |
24 | if (!error) { | 24 | if (!error) { |
25 | return 0; | 25 | return 0; |
26 | } | 26 | } |
@@ -51,8 +51,7 @@ static uint32_t render_status_line_error(cairo_t *cairo, | |||
51 | 51 | ||
52 | static uint32_t render_status_line_text(cairo_t *cairo, | 52 | static uint32_t render_status_line_text(cairo_t *cairo, |
53 | struct swaybar_output *output, struct swaybar_config *config, | 53 | struct swaybar_output *output, struct swaybar_config *config, |
54 | const char *text, bool focused, double *x, | 54 | const char *text, bool focused, double *x, uint32_t surface_height) { |
55 | uint32_t width, uint32_t surface_height) { | ||
56 | if (!text) { | 55 | if (!text) { |
57 | return 0; | 56 | return 0; |
58 | } | 57 | } |
@@ -159,7 +158,7 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
159 | get_text_size(cairo, config->font, &sep_width, &_height, | 158 | get_text_size(cairo, config->font, &sep_width, &_height, |
160 | output->scale, false, "%s", config->sep_symbol); | 159 | output->scale, false, "%s", config->sep_symbol); |
161 | uint32_t _ideal_height = _height + ws_vertical_padding * 2; | 160 | uint32_t _ideal_height = _height + ws_vertical_padding * 2; |
162 | if (height < _ideal_height / output->scale) { | 161 | if ((uint32_t)_height < _ideal_height / output->scale) { |
163 | return _height / output->scale; | 162 | return _height / output->scale; |
164 | } | 163 | } |
165 | if (sep_width > block->separator_block_width) { | 164 | if (sep_width > block->separator_block_width) { |
@@ -256,7 +255,7 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
256 | static uint32_t render_status_line_i3bar(cairo_t *cairo, | 255 | static uint32_t render_status_line_i3bar(cairo_t *cairo, |
257 | struct swaybar_config *config, struct swaybar_output *output, | 256 | struct swaybar_config *config, struct swaybar_output *output, |
258 | struct status_line *status, bool focused, | 257 | struct status_line *status, bool focused, |
259 | double *x, uint32_t width, uint32_t surface_height) { | 258 | double *x, uint32_t surface_height) { |
260 | uint32_t max_height = 0; | 259 | uint32_t max_height = 0; |
261 | bool edge = true; | 260 | bool edge = true; |
262 | struct i3bar_block *block; | 261 | struct i3bar_block *block; |
@@ -272,17 +271,17 @@ static uint32_t render_status_line_i3bar(cairo_t *cairo, | |||
272 | static uint32_t render_status_line(cairo_t *cairo, | 271 | static uint32_t render_status_line(cairo_t *cairo, |
273 | struct swaybar_config *config, struct swaybar_output *output, | 272 | struct swaybar_config *config, struct swaybar_output *output, |
274 | struct status_line *status, bool focused, | 273 | struct status_line *status, bool focused, |
275 | double *x, uint32_t width, uint32_t surface_height) { | 274 | double *x, uint32_t surface_height) { |
276 | switch (status->protocol) { | 275 | switch (status->protocol) { |
277 | case PROTOCOL_ERROR: | 276 | case PROTOCOL_ERROR: |
278 | return render_status_line_error(cairo, output, config, | 277 | return render_status_line_error(cairo, output, config, |
279 | status->text, x, width, surface_height); | 278 | status->text, x, surface_height); |
280 | case PROTOCOL_TEXT: | 279 | case PROTOCOL_TEXT: |
281 | return render_status_line_text(cairo, output, config, | 280 | return render_status_line_text(cairo, output, config, |
282 | status->text, focused, x, width, surface_height); | 281 | status->text, focused, x, surface_height); |
283 | case PROTOCOL_I3BAR: | 282 | case PROTOCOL_I3BAR: |
284 | return render_status_line_i3bar(cairo, config, output, | 283 | return render_status_line_i3bar(cairo, config, output, |
285 | status, focused, x, width, surface_height); | 284 | status, focused, x, surface_height); |
286 | case PROTOCOL_UNDEF: | 285 | case PROTOCOL_UNDEF: |
287 | return 0; | 286 | return 0; |
288 | } | 287 | } |
@@ -368,7 +367,7 @@ static uint32_t render_workspace_button(cairo_t *cairo, | |||
368 | box_colors = config->colors.inactive_workspace; | 367 | box_colors = config->colors.inactive_workspace; |
369 | } | 368 | } |
370 | 369 | ||
371 | uint32_t height = surface_height *output->scale; | 370 | uint32_t height = surface_height * output->scale; |
372 | 371 | ||
373 | int text_width, text_height; | 372 | int text_width, text_height; |
374 | get_text_size(cairo, config->font, &text_width, &text_height, | 373 | get_text_size(cairo, config->font, &text_width, &text_height, |
@@ -442,8 +441,8 @@ static uint32_t render_to_cairo(cairo_t *cairo, | |||
442 | */ | 441 | */ |
443 | double x = output->width * output->scale; | 442 | double x = output->width * output->scale; |
444 | if (bar->status) { | 443 | if (bar->status) { |
445 | uint32_t h = render_status_line(cairo, config, output, bar->status, | 444 | uint32_t h = render_status_line(cairo, config, output, |
446 | output->focused, &x, output->width, output->height); | 445 | bar->status, output->focused, &x, output->height); |
447 | max_height = h > max_height ? h : max_height; | 446 | max_height = h > max_height ? h : max_height; |
448 | } | 447 | } |
449 | x = 0; | 448 | x = 0; |