aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/render.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/render.c')
-rw-r--r--swaybar/render.c186
1 files changed, 92 insertions, 94 deletions
diff --git a/swaybar/render.c b/swaybar/render.c
index fcc8be1d..5f89d0c9 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -53,22 +53,21 @@ static uint32_t render_status_line_error(struct render_context *ctx, double *x)
53 return 0; 53 return 0;
54 } 54 }
55 55
56 uint32_t height = output->height * output->scale; 56 uint32_t height = output->height;
57 57
58 cairo_t *cairo = ctx->cairo; 58 cairo_t *cairo = ctx->cairo;
59 cairo_set_source_u32(cairo, 0xFF0000FF); 59 cairo_set_source_u32(cairo, 0xFF0000FF);
60 60
61 int margin = 3 * output->scale; 61 int margin = 3;
62 double ws_vertical_padding = 62 double ws_vertical_padding = output->bar->config->status_padding;
63 output->bar->config->status_padding * output->scale;
64 63
65 char *font = output->bar->config->font; 64 char *font = output->bar->config->font;
66 int text_width, text_height; 65 int text_width, text_height;
67 get_text_size(cairo, font, &text_width, &text_height, NULL, 66 get_text_size(cairo, font, &text_width, &text_height, NULL,
68 output->scale, false, "%s", error); 67 1, false, "%s", error);
69 68
70 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 69 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
71 uint32_t ideal_surface_height = ideal_height / output->scale; 70 uint32_t ideal_surface_height = ideal_height;
72 if (!output->bar->config->height && 71 if (!output->bar->config->height &&
73 output->height < ideal_surface_height) { 72 output->height < ideal_surface_height) {
74 return ideal_surface_height; 73 return ideal_surface_height;
@@ -78,7 +77,7 @@ static uint32_t render_status_line_error(struct render_context *ctx, double *x)
78 double text_y = height / 2.0 - text_height / 2.0; 77 double text_y = height / 2.0 - text_height / 2.0;
79 cairo_move_to(cairo, *x, (int)floor(text_y)); 78 cairo_move_to(cairo, *x, (int)floor(text_y));
80 choose_text_aa_mode(ctx, 0xFF0000FF); 79 choose_text_aa_mode(ctx, 0xFF0000FF);
81 pango_printf(cairo, font, output->scale, false, "%s", error); 80 pango_printf(cairo, font, 1, false, "%s", error);
82 *x -= margin; 81 *x -= margin;
83 return output->height; 82 return output->height;
84} 83}
@@ -98,25 +97,24 @@ static uint32_t render_status_line_text(struct render_context *ctx, double *x) {
98 97
99 int text_width, text_height; 98 int text_width, text_height;
100 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 99 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
101 output->scale, config->pango_markup, "%s", text); 100 1, config->pango_markup, "%s", text);
102 101
103 double ws_vertical_padding = config->status_padding * output->scale; 102 double ws_vertical_padding = config->status_padding;
104 int margin = 3 * output->scale; 103 int margin = 3;
105 104
106 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 105 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
107 uint32_t ideal_surface_height = ideal_height / output->scale; 106 uint32_t ideal_surface_height = ideal_height;
108 if (!output->bar->config->height && 107 if (!output->bar->config->height &&
109 output->height < ideal_surface_height) { 108 output->height < ideal_surface_height) {
110 return ideal_surface_height; 109 return ideal_surface_height;
111 } 110 }
112 111
113 *x -= text_width + margin; 112 *x -= text_width + margin;
114 uint32_t height = output->height * output->scale; 113 uint32_t height = output->height;
115 double text_y = height / 2.0 - text_height / 2.0; 114 double text_y = height / 2.0 - text_height / 2.0;
116 cairo_move_to(cairo, *x, (int)floor(text_y)); 115 cairo_move_to(cairo, *x, (int)floor(text_y));
117 choose_text_aa_mode(ctx, fontcolor); 116 choose_text_aa_mode(ctx, fontcolor);
118 pango_printf(cairo, config->font, output->scale, 117 pango_printf(cairo, config->font, 1, config->pango_markup, "%s", text);
119 config->pango_markup, "%s", text);
120 *x -= margin; 118 *x -= margin;
121 return output->height; 119 return output->height;
122} 120}
@@ -165,10 +163,10 @@ static enum hotspot_event_handling block_hotspot_callback(
165 struct i3bar_block *block = data; 163 struct i3bar_block *block = data;
166 struct status_line *status = output->bar->status; 164 struct status_line *status = output->bar->status;
167 return i3bar_block_send_click(status, block, x, y, 165 return i3bar_block_send_click(status, block, x, y,
168 x - (double)hotspot->x / output->scale, 166 x - (double)hotspot->x,
169 y - (double)hotspot->y / output->scale, 167 y - (double)hotspot->y,
170 (double)hotspot->width / output->scale, 168 (double)hotspot->width,
171 (double)hotspot->height / output->scale, 169 (double)hotspot->height,
172 output->scale, button); 170 output->scale, button);
173} 171}
174 172
@@ -191,17 +189,17 @@ static uint32_t render_status_block(struct render_context *ctx,
191 struct swaybar_output *output = ctx->output; 189 struct swaybar_output *output = ctx->output;
192 struct swaybar_config *config = output->bar->config; 190 struct swaybar_config *config = output->bar->config;
193 int text_width, text_height; 191 int text_width, text_height;
194 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 192 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 1,
195 output->scale, block->markup, "%s", text); 193 block->markup, "%s", text);
196 194
197 int margin = 3 * output->scale; 195 int margin = 3;
198 double ws_vertical_padding = config->status_padding * output->scale; 196 double ws_vertical_padding = config->status_padding;
199 197
200 int width = text_width; 198 int width = text_width;
201 if (block->min_width_str) { 199 if (block->min_width_str) {
202 int w; 200 int w;
203 get_text_size(cairo, config->font, &w, NULL, NULL, 201 get_text_size(cairo, config->font, &w, NULL, NULL, 1, block->markup,
204 output->scale, block->markup, "%s", block->min_width_str); 202 "%s", block->min_width_str);
205 block->min_width = w; 203 block->min_width = w;
206 } 204 }
207 if (width < block->min_width) { 205 if (width < block->min_width) {
@@ -210,7 +208,7 @@ static uint32_t render_status_block(struct render_context *ctx,
210 208
211 double block_width = width; 209 double block_width = width;
212 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 210 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
213 uint32_t ideal_surface_height = ideal_height / output->scale; 211 uint32_t ideal_surface_height = ideal_height;
214 if (!output->bar->config->height && 212 if (!output->bar->config->height &&
215 output->height < ideal_surface_height) { 213 output->height < ideal_surface_height) {
216 return ideal_surface_height; 214 return ideal_surface_height;
@@ -218,12 +216,12 @@ static uint32_t render_status_block(struct render_context *ctx,
218 216
219 *x -= width; 217 *x -= width;
220 if ((block->border || block->urgent) && block->border_left > 0) { 218 if ((block->border || block->urgent) && block->border_left > 0) {
221 *x -= (block->border_left * output->scale + margin); 219 *x -= (block->border_left + margin);
222 block_width += block->border_left * output->scale + margin; 220 block_width += block->border_left + margin;
223 } 221 }
224 if ((block->border || block->urgent) && block->border_right > 0) { 222 if ((block->border || block->urgent) && block->border_right > 0) {
225 *x -= (block->border_right * output->scale + margin); 223 *x -= (block->border_right + margin);
226 block_width += block->border_right * output->scale + margin; 224 block_width += block->border_right + margin;
227 } 225 }
228 226
229 int sep_width, sep_height; 227 int sep_width, sep_height;
@@ -231,9 +229,9 @@ static uint32_t render_status_block(struct render_context *ctx,
231 if (!edge) { 229 if (!edge) {
232 if (config->sep_symbol) { 230 if (config->sep_symbol) {
233 get_text_size(cairo, config->font, &sep_width, &sep_height, NULL, 231 get_text_size(cairo, config->font, &sep_width, &sep_height, NULL,
234 output->scale, false, "%s", config->sep_symbol); 232 1, false, "%s", config->sep_symbol);
235 uint32_t _ideal_height = sep_height + ws_vertical_padding * 2; 233 uint32_t _ideal_height = sep_height + ws_vertical_padding * 2;
236 uint32_t _ideal_surface_height = _ideal_height / output->scale; 234 uint32_t _ideal_surface_height = _ideal_height;
237 if (!output->bar->config->height && 235 if (!output->bar->config->height &&
238 output->height < _ideal_surface_height) { 236 output->height < _ideal_surface_height) {
239 return _ideal_surface_height; 237 return _ideal_surface_height;
@@ -244,10 +242,10 @@ static uint32_t render_status_block(struct render_context *ctx,
244 } 242 }
245 *x -= sep_block_width; 243 *x -= sep_block_width;
246 } else if (config->status_edge_padding) { 244 } else if (config->status_edge_padding) {
247 *x -= config->status_edge_padding * output->scale; 245 *x -= config->status_edge_padding;
248 } 246 }
249 247
250 uint32_t height = output->height * output->scale; 248 uint32_t height = output->height;
251 if (output->bar->status->click_events) { 249 if (output->bar->status->click_events) {
252 struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot)); 250 struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot));
253 hotspot->x = *x; 251 hotspot->x = *x;
@@ -277,17 +275,17 @@ static uint32_t render_status_block(struct render_context *ctx,
277 ? config->colors.urgent_workspace.border : block->border; 275 ? config->colors.urgent_workspace.border : block->border;
278 if (border_color && block->border_top > 0) { 276 if (border_color && block->border_top > 0) {
279 render_sharp_line(cairo, border_color, x_pos, y_pos, 277 render_sharp_line(cairo, border_color, x_pos, y_pos,
280 block_width, block->border_top * output->scale); 278 block_width, block->border_top);
281 } 279 }
282 if (border_color && block->border_bottom > 0) { 280 if (border_color && block->border_bottom > 0) {
283 render_sharp_line(cairo, border_color, x_pos, 281 render_sharp_line(cairo, border_color, x_pos,
284 y_pos + render_height - block->border_bottom * output->scale, 282 y_pos + render_height - block->border_bottom,
285 block_width, block->border_bottom * output->scale); 283 block_width, block->border_bottom);
286 } 284 }
287 if (border_color && block->border_left > 0) { 285 if (border_color && block->border_left > 0) {
288 render_sharp_line(cairo, border_color, x_pos, y_pos, 286 render_sharp_line(cairo, border_color, x_pos, y_pos,
289 block->border_left * output->scale, render_height); 287 block->border_left, render_height);
290 x_pos += block->border_left * output->scale + margin; 288 x_pos += block->border_left + margin;
291 } 289 }
292 290
293 double offset = 0; 291 double offset = 0;
@@ -306,15 +304,14 @@ static uint32_t render_status_block(struct render_context *ctx,
306 color = block->urgent ? config->colors.urgent_workspace.text : color; 304 color = block->urgent ? config->colors.urgent_workspace.text : color;
307 cairo_set_source_u32(cairo, color); 305 cairo_set_source_u32(cairo, color);
308 choose_text_aa_mode(ctx, color); 306 choose_text_aa_mode(ctx, color);
309 pango_printf(cairo, config->font, output->scale, 307 pango_printf(cairo, config->font, 1, block->markup, "%s", text);
310 block->markup, "%s", text);
311 x_pos += width; 308 x_pos += width;
312 309
313 if (block->border && block->border_right > 0) { 310 if (block->border && block->border_right > 0) {
314 x_pos += margin; 311 x_pos += margin;
315 render_sharp_line(cairo, border_color, x_pos, y_pos, 312 render_sharp_line(cairo, border_color, x_pos, y_pos,
316 block->border_right * output->scale, render_height); 313 block->border_right, render_height);
317 x_pos += block->border_right * output->scale; 314 x_pos += block->border_right;
318 } 315 }
319 316
320 if (!edge && block->separator) { 317 if (!edge && block->separator) {
@@ -329,7 +326,7 @@ static uint32_t render_status_block(struct render_context *ctx,
329 double sep_y = height / 2.0 - sep_height / 2.0; 326 double sep_y = height / 2.0 - sep_height / 2.0;
330 cairo_move_to(cairo, offset, (int)floor(sep_y)); 327 cairo_move_to(cairo, offset, (int)floor(sep_y));
331 choose_text_aa_mode(ctx, color); 328 choose_text_aa_mode(ctx, color);
332 pango_printf(cairo, config->font, output->scale, false, 329 pango_printf(cairo, config->font, 1, false,
333 "%s", config->sep_symbol); 330 "%s", config->sep_symbol);
334 } else { 331 } else {
335 cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); 332 cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
@@ -352,18 +349,18 @@ static void predict_status_block_pos(cairo_t *cairo,
352 struct swaybar_config *config = output->bar->config; 349 struct swaybar_config *config = output->bar->config;
353 350
354 int text_width, text_height; 351 int text_width, text_height;
355 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 352 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 1,
356 output->scale, block->markup, "%s", block->full_text); 353 block->markup, "%s", block->full_text);
357 354
358 int margin = 3 * output->scale; 355 int margin = 3;
359 double ws_vertical_padding = config->status_padding * output->scale; 356 double ws_vertical_padding = config->status_padding;
360 357
361 int width = text_width; 358 int width = text_width;
362 359
363 if (block->min_width_str) { 360 if (block->min_width_str) {
364 int w; 361 int w;
365 get_text_size(cairo, config->font, &w, NULL, NULL, 362 get_text_size(cairo, config->font, &w, NULL, NULL,
366 output->scale, block->markup, "%s", block->min_width_str); 363 1, block->markup, "%s", block->min_width_str);
367 block->min_width = w; 364 block->min_width = w;
368 } 365 }
369 if (width < block->min_width) { 366 if (width < block->min_width) {
@@ -371,7 +368,7 @@ static void predict_status_block_pos(cairo_t *cairo,
371 } 368 }
372 369
373 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 370 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
374 uint32_t ideal_surface_height = ideal_height / output->scale; 371 uint32_t ideal_surface_height = ideal_height;
375 if (!output->bar->config->height && 372 if (!output->bar->config->height &&
376 output->height < ideal_surface_height) { 373 output->height < ideal_surface_height) {
377 return; 374 return;
@@ -379,10 +376,10 @@ static void predict_status_block_pos(cairo_t *cairo,
379 376
380 *x -= width; 377 *x -= width;
381 if ((block->border || block->urgent) && block->border_left > 0) { 378 if ((block->border || block->urgent) && block->border_left > 0) {
382 *x -= (block->border_left * output->scale + margin); 379 *x -= (block->border_left + margin);
383 } 380 }
384 if ((block->border || block->urgent) && block->border_right > 0) { 381 if ((block->border || block->urgent) && block->border_right > 0) {
385 *x -= (block->border_right * output->scale + margin); 382 *x -= (block->border_right + margin);
386 } 383 }
387 384
388 int sep_width, sep_height; 385 int sep_width, sep_height;
@@ -390,9 +387,9 @@ static void predict_status_block_pos(cairo_t *cairo,
390 if (!edge) { 387 if (!edge) {
391 if (config->sep_symbol) { 388 if (config->sep_symbol) {
392 get_text_size(cairo, config->font, &sep_width, &sep_height, NULL, 389 get_text_size(cairo, config->font, &sep_width, &sep_height, NULL,
393 output->scale, false, "%s", config->sep_symbol); 390 1, false, "%s", config->sep_symbol);
394 uint32_t _ideal_height = sep_height + ws_vertical_padding * 2; 391 uint32_t _ideal_height = sep_height + ws_vertical_padding * 2;
395 uint32_t _ideal_surface_height = _ideal_height / output->scale; 392 uint32_t _ideal_surface_height = _ideal_height;
396 if (!output->bar->config->height && 393 if (!output->bar->config->height &&
397 output->height < _ideal_surface_height) { 394 output->height < _ideal_surface_height) {
398 return; 395 return;
@@ -403,13 +400,13 @@ static void predict_status_block_pos(cairo_t *cairo,
403 } 400 }
404 *x -= sep_block_width; 401 *x -= sep_block_width;
405 } else if (config->status_edge_padding) { 402 } else if (config->status_edge_padding) {
406 *x -= config->status_edge_padding * output->scale; 403 *x -= config->status_edge_padding;
407 } 404 }
408} 405}
409 406
410static double predict_status_line_pos(cairo_t *cairo, 407static double predict_status_line_pos(cairo_t *cairo,
411 struct swaybar_output *output, double x) { 408 struct swaybar_output *output, double x) {
412 bool edge = x == output->width * output->scale; 409 bool edge = x == output->width;
413 struct i3bar_block *block; 410 struct i3bar_block *block;
414 wl_list_for_each(block, &output->bar->status->blocks, link) { 411 wl_list_for_each(block, &output->bar->status->blocks, link) {
415 predict_status_block_pos(cairo, output, block, &x, edge); 412 predict_status_block_pos(cairo, output, block, &x, edge);
@@ -424,24 +421,24 @@ static uint32_t predict_workspace_button_length(cairo_t *cairo,
424 struct swaybar_config *config = output->bar->config; 421 struct swaybar_config *config = output->bar->config;
425 422
426 int text_width, text_height; 423 int text_width, text_height;
427 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 424 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 1,
428 output->scale, config->pango_markup, "%s", ws->label); 425 config->pango_markup, "%s", ws->label);
429 426
430 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; 427 int ws_vertical_padding = WS_VERTICAL_PADDING;
431 int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale; 428 int ws_horizontal_padding = WS_HORIZONTAL_PADDING;
432 int border_width = BORDER_WIDTH * output->scale; 429 int border_width = BORDER_WIDTH;
433 430
434 uint32_t ideal_height = ws_vertical_padding * 2 + text_height 431 uint32_t ideal_height = ws_vertical_padding * 2 + text_height
435 + border_width * 2; 432 + border_width * 2;
436 uint32_t ideal_surface_height = ideal_height / output->scale; 433 uint32_t ideal_surface_height = ideal_height;
437 if (!output->bar->config->height && 434 if (!output->bar->config->height &&
438 output->height < ideal_surface_height) { 435 output->height < ideal_surface_height) {
439 return 0; 436 return 0;
440 } 437 }
441 438
442 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; 439 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
443 if (width < config->workspace_min_width * output->scale) { 440 if (width < config->workspace_min_width) {
444 width = config->workspace_min_width * output->scale; 441 width = config->workspace_min_width;
445 } 442 }
446 return width; 443 return width;
447} 444}
@@ -473,23 +470,23 @@ static uint32_t predict_binding_mode_indicator_length(cairo_t *cairo,
473 470
474 int text_width, text_height; 471 int text_width, text_height;
475 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 472 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
476 output->scale, output->bar->mode_pango_markup, 473 1, output->bar->mode_pango_markup,
477 "%s", mode); 474 "%s", mode);
478 475
479 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; 476 int ws_vertical_padding = WS_VERTICAL_PADDING;
480 int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale; 477 int ws_horizontal_padding = WS_HORIZONTAL_PADDING;
481 int border_width = BORDER_WIDTH * output->scale; 478 int border_width = BORDER_WIDTH;
482 479
483 uint32_t ideal_height = text_height + ws_vertical_padding * 2 480 uint32_t ideal_height = text_height + ws_vertical_padding * 2
484 + border_width * 2; 481 + border_width * 2;
485 uint32_t ideal_surface_height = ideal_height / output->scale; 482 uint32_t ideal_surface_height = ideal_height;
486 if (!output->bar->config->height && 483 if (!output->bar->config->height &&
487 output->height < ideal_surface_height) { 484 output->height < ideal_surface_height) {
488 return 0; 485 return 0;
489 } 486 }
490 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; 487 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
491 if (width < config->workspace_min_width * output->scale) { 488 if (width < config->workspace_min_width) {
492 width = config->workspace_min_width * output->scale; 489 width = config->workspace_min_width;
493 } 490 }
494 return width; 491 return width;
495} 492}
@@ -497,7 +494,7 @@ static uint32_t predict_binding_mode_indicator_length(cairo_t *cairo,
497static uint32_t render_status_line_i3bar(struct render_context *ctx, double *x) { 494static uint32_t render_status_line_i3bar(struct render_context *ctx, double *x) {
498 struct swaybar_output *output = ctx->output; 495 struct swaybar_output *output = ctx->output;
499 uint32_t max_height = 0; 496 uint32_t max_height = 0;
500 bool edge = *x == output->width * output->scale; 497 bool edge = *x == output->width;
501 struct i3bar_block *block; 498 struct i3bar_block *block;
502 bool use_short_text = false; 499 bool use_short_text = false;
503 500
@@ -505,7 +502,7 @@ static uint32_t render_status_line_i3bar(struct render_context *ctx, double *x)
505 double reserved_width = 502 double reserved_width =
506 predict_workspace_buttons_length(cairo, output) + 503 predict_workspace_buttons_length(cairo, output) +
507 predict_binding_mode_indicator_length(cairo, output) + 504 predict_binding_mode_indicator_length(cairo, output) +
508 3 * output->scale; // require a bit of space for margin 505 3; // require a bit of space for margin
509 506
510 double predicted_full_pos = 507 double predicted_full_pos =
511 predict_status_line_pos(cairo, output, *x); 508 predict_status_line_pos(cairo, output, *x);
@@ -550,26 +547,26 @@ static uint32_t render_binding_mode_indicator(struct render_context *ctx,
550 struct swaybar_config *config = output->bar->config; 547 struct swaybar_config *config = output->bar->config;
551 int text_width, text_height; 548 int text_width, text_height;
552 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 549 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
553 output->scale, output->bar->mode_pango_markup, 550 1, output->bar->mode_pango_markup,
554 "%s", mode); 551 "%s", mode);
555 552
556 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; 553 int ws_vertical_padding = WS_VERTICAL_PADDING;
557 int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale; 554 int ws_horizontal_padding = WS_HORIZONTAL_PADDING;
558 int border_width = BORDER_WIDTH * output->scale; 555 int border_width = BORDER_WIDTH;
559 556
560 uint32_t ideal_height = text_height + ws_vertical_padding * 2 557 uint32_t ideal_height = text_height + ws_vertical_padding * 2
561 + border_width * 2; 558 + border_width * 2;
562 uint32_t ideal_surface_height = ideal_height / output->scale; 559 uint32_t ideal_surface_height = ideal_height;
563 if (!output->bar->config->height && 560 if (!output->bar->config->height &&
564 output->height < ideal_surface_height) { 561 output->height < ideal_surface_height) {
565 return ideal_surface_height; 562 return ideal_surface_height;
566 } 563 }
567 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; 564 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
568 if (width < config->workspace_min_width * output->scale) { 565 if (width < config->workspace_min_width) {
569 width = config->workspace_min_width * output->scale; 566 width = config->workspace_min_width;
570 } 567 }
571 568
572 uint32_t height = output->height * output->scale; 569 uint32_t height = output->height;
573 cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); 570 cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
574 cairo_set_source_u32(cairo, config->colors.binding_mode.background); 571 cairo_set_source_u32(cairo, config->colors.binding_mode.background);
575 ctx->background_color = config->colors.binding_mode.background; 572 ctx->background_color = config->colors.binding_mode.background;
@@ -590,8 +587,8 @@ static uint32_t render_binding_mode_indicator(struct render_context *ctx,
590 cairo_set_source_u32(cairo, config->colors.binding_mode.text); 587 cairo_set_source_u32(cairo, config->colors.binding_mode.text);
591 cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y)); 588 cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y));
592 choose_text_aa_mode(ctx, config->colors.binding_mode.text); 589 choose_text_aa_mode(ctx, config->colors.binding_mode.text);
593 pango_printf(cairo, config->font, output->scale, 590 pango_printf(cairo, config->font, 1, output->bar->mode_pango_markup,
594 output->bar->mode_pango_markup, "%s", mode); 591 "%s", mode);
595 return output->height; 592 return output->height;
596} 593}
597 594
@@ -620,28 +617,28 @@ static uint32_t render_workspace_button(struct render_context *ctx,
620 box_colors = config->colors.inactive_workspace; 617 box_colors = config->colors.inactive_workspace;
621 } 618 }
622 619
623 uint32_t height = output->height * output->scale; 620 uint32_t height = output->height;
624 621
625 cairo_t *cairo = ctx->cairo; 622 cairo_t *cairo = ctx->cairo;
626 int text_width, text_height; 623 int text_width, text_height;
627 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 624 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
628 output->scale, config->pango_markup, "%s", ws->label); 625 1, config->pango_markup, "%s", ws->label);
629 626
630 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; 627 int ws_vertical_padding = WS_VERTICAL_PADDING;
631 int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale; 628 int ws_horizontal_padding = WS_HORIZONTAL_PADDING;
632 int border_width = BORDER_WIDTH * output->scale; 629 int border_width = BORDER_WIDTH;
633 630
634 uint32_t ideal_height = ws_vertical_padding * 2 + text_height 631 uint32_t ideal_height = ws_vertical_padding * 2 + text_height
635 + border_width * 2; 632 + border_width * 2;
636 uint32_t ideal_surface_height = ideal_height / output->scale; 633 uint32_t ideal_surface_height = ideal_height;
637 if (!output->bar->config->height && 634 if (!output->bar->config->height &&
638 output->height < ideal_surface_height) { 635 output->height < ideal_surface_height) {
639 return ideal_surface_height; 636 return ideal_surface_height;
640 } 637 }
641 638
642 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; 639 uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2;
643 if (width < config->workspace_min_width * output->scale) { 640 if (width < config->workspace_min_width) {
644 width = config->workspace_min_width * output->scale; 641 width = config->workspace_min_width;
645 } 642 }
646 643
647 cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); 644 cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
@@ -664,7 +661,7 @@ static uint32_t render_workspace_button(struct render_context *ctx,
664 cairo_set_source_u32(cairo, box_colors.text); 661 cairo_set_source_u32(cairo, box_colors.text);
665 cairo_move_to(cairo, *x + width / 2 - text_width / 2, (int)floor(text_y)); 662 cairo_move_to(cairo, *x + width / 2 - text_width / 2, (int)floor(text_y));
666 choose_text_aa_mode(ctx, box_colors.text); 663 choose_text_aa_mode(ctx, box_colors.text);
667 pango_printf(cairo, config->font, output->scale, config->pango_markup, 664 pango_printf(cairo, config->font, 1, config->pango_markup,
668 "%s", ws->label); 665 "%s", ws->label);
669 666
670 struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot)); 667 struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot));
@@ -697,8 +694,8 @@ static uint32_t render_to_cairo(struct render_context *ctx) {
697 cairo_paint(cairo); 694 cairo_paint(cairo);
698 695
699 int th; 696 int th;
700 get_text_size(cairo, config->font, NULL, &th, NULL, output->scale, false, ""); 697 get_text_size(cairo, config->font, NULL, &th, NULL, 1, false, "");
701 uint32_t max_height = (th + WS_VERTICAL_PADDING * 4) / output->scale; 698 uint32_t max_height = (th + WS_VERTICAL_PADDING * 4);
702 /* 699 /*
703 * Each render_* function takes the actual height of the bar, and returns 700 * Each render_* function takes the actual height of the bar, and returns
704 * the ideal height. If the actual height is too short, the render function 701 * the ideal height. If the actual height is too short, the render function
@@ -706,7 +703,7 @@ static uint32_t render_to_cairo(struct render_context *ctx) {
706 * height is too tall, the render function should adapt its drawing to 703 * height is too tall, the render function should adapt its drawing to
707 * utilize the available space. 704 * utilize the available space.
708 */ 705 */
709 double x = output->width * output->scale; 706 double x = output->width;
710#if HAVE_TRAY 707#if HAVE_TRAY
711 if (bar->tray) { 708 if (bar->tray) {
712 uint32_t h = render_tray(cairo, output, &x); 709 uint32_t h = render_tray(cairo, output, &x);
@@ -762,6 +759,7 @@ void render_frame(struct swaybar_output *output) {
762 cairo_surface_t *recorder = cairo_recording_surface_create( 759 cairo_surface_t *recorder = cairo_recording_surface_create(
763 CAIRO_CONTENT_COLOR_ALPHA, NULL); 760 CAIRO_CONTENT_COLOR_ALPHA, NULL);
764 cairo_t *cairo = cairo_create(recorder); 761 cairo_t *cairo = cairo_create(recorder);
762 cairo_scale(cairo, output->scale, output->scale);
765 cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); 763 cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST);
766 ctx.cairo = cairo; 764 ctx.cairo = cairo;
767 765