aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--swaybar/input.c8
-rw-r--r--swaybar/render.c186
-rw-r--r--swaynag/render.c58
3 files changed, 124 insertions, 128 deletions
diff --git a/swaybar/input.c b/swaybar/input.c
index 6e13f177..c8c8f0d4 100644
--- a/swaybar/input.c
+++ b/swaybar/input.c
@@ -142,13 +142,11 @@ static bool check_bindings(struct swaybar *bar, uint32_t button,
142 142
143static bool process_hotspots(struct swaybar_output *output, 143static bool process_hotspots(struct swaybar_output *output,
144 double x, double y, uint32_t button) { 144 double x, double y, uint32_t button) {
145 double px = x * output->scale;
146 double py = y * output->scale;
147 struct swaybar_hotspot *hotspot; 145 struct swaybar_hotspot *hotspot;
148 wl_list_for_each(hotspot, &output->hotspots, link) { 146 wl_list_for_each(hotspot, &output->hotspots, link) {
149 if (px >= hotspot->x && py >= hotspot->y 147 if (x >= hotspot->x && y >= hotspot->y
150 && px < hotspot->x + hotspot->width 148 && x < hotspot->x + hotspot->width
151 && py < hotspot->y + hotspot->height) { 149 && y < hotspot->y + hotspot->height) {
152 if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot, x, y, 150 if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot, x, y,
153 button, hotspot->data)) { 151 button, hotspot->data)) {
154 return true; 152 return true;
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
diff --git a/swaynag/render.c b/swaynag/render.c
index 2a7f869a..c159294e 100644
--- a/swaynag/render.c
+++ b/swaynag/render.c
@@ -10,19 +10,19 @@
10static uint32_t render_message(cairo_t *cairo, struct swaynag *swaynag) { 10static uint32_t render_message(cairo_t *cairo, struct swaynag *swaynag) {
11 int text_width, text_height; 11 int text_width, text_height;
12 get_text_size(cairo, swaynag->type->font, &text_width, &text_height, NULL, 12 get_text_size(cairo, swaynag->type->font, &text_width, &text_height, NULL,
13 swaynag->scale, true, "%s", swaynag->message); 13 1, true, "%s", swaynag->message);
14 14
15 int padding = swaynag->type->message_padding * swaynag->scale; 15 int padding = swaynag->type->message_padding;
16 16
17 uint32_t ideal_height = text_height + padding * 2; 17 uint32_t ideal_height = text_height + padding * 2;
18 uint32_t ideal_surface_height = ideal_height / swaynag->scale; 18 uint32_t ideal_surface_height = ideal_height;
19 if (swaynag->height < ideal_surface_height) { 19 if (swaynag->height < ideal_surface_height) {
20 return ideal_surface_height; 20 return ideal_surface_height;
21 } 21 }
22 22
23 cairo_set_source_u32(cairo, swaynag->type->text); 23 cairo_set_source_u32(cairo, swaynag->type->text);
24 cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); 24 cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2);
25 pango_printf(cairo, swaynag->type->font, swaynag->scale, false, 25 pango_printf(cairo, swaynag->type->font, 1, false,
26 "%s", swaynag->message); 26 "%s", swaynag->message);
27 27
28 return ideal_surface_height; 28 return ideal_surface_height;
@@ -32,10 +32,10 @@ static void render_details_scroll_button(cairo_t *cairo,
32 struct swaynag *swaynag, struct swaynag_button *button) { 32 struct swaynag *swaynag, struct swaynag_button *button) {
33 int text_width, text_height; 33 int text_width, text_height;
34 get_text_size(cairo, swaynag->type->font, &text_width, &text_height, NULL, 34 get_text_size(cairo, swaynag->type->font, &text_width, &text_height, NULL,
35 swaynag->scale, true, "%s", button->text); 35 1, true, "%s", button->text);
36 36
37 int border = swaynag->type->button_border_thickness * swaynag->scale; 37 int border = swaynag->type->button_border_thickness;
38 int padding = swaynag->type->button_padding * swaynag->scale; 38 int padding = swaynag->type->button_padding;
39 39
40 cairo_set_source_u32(cairo, swaynag->type->details_background); 40 cairo_set_source_u32(cairo, swaynag->type->details_background);
41 cairo_rectangle(cairo, button->x, button->y, 41 cairo_rectangle(cairo, button->x, button->y,
@@ -50,7 +50,7 @@ static void render_details_scroll_button(cairo_t *cairo,
50 cairo_set_source_u32(cairo, swaynag->type->button_text); 50 cairo_set_source_u32(cairo, swaynag->type->button_text);
51 cairo_move_to(cairo, button->x + border + padding, 51 cairo_move_to(cairo, button->x + border + padding,
52 button->y + border + (button->height - text_height) / 2); 52 button->y + border + (button->height - text_height) / 2);
53 pango_printf(cairo, swaynag->type->font, swaynag->scale, true, 53 pango_printf(cairo, swaynag->type->font, 1, true,
54 "%s", button->text); 54 "%s", button->text);
55} 55}
56 56
@@ -58,33 +58,33 @@ static int get_detailed_scroll_button_width(cairo_t *cairo,
58 struct swaynag *swaynag) { 58 struct swaynag *swaynag) {
59 int up_width, down_width, temp_height; 59 int up_width, down_width, temp_height;
60 get_text_size(cairo, swaynag->type->font, &up_width, &temp_height, NULL, 60 get_text_size(cairo, swaynag->type->font, &up_width, &temp_height, NULL,
61 swaynag->scale, true, 61 1, true,
62 "%s", swaynag->details.button_up.text); 62 "%s", swaynag->details.button_up.text);
63 get_text_size(cairo, swaynag->type->font, &down_width, &temp_height, NULL, 63 get_text_size(cairo, swaynag->type->font, &down_width, &temp_height, NULL,
64 swaynag->scale, true, 64 1, true,
65 "%s", swaynag->details.button_down.text); 65 "%s", swaynag->details.button_down.text);
66 66
67 int text_width = up_width > down_width ? up_width : down_width; 67 int text_width = up_width > down_width ? up_width : down_width;
68 int border = swaynag->type->button_border_thickness * swaynag->scale; 68 int border = swaynag->type->button_border_thickness;
69 int padding = swaynag->type->button_padding * swaynag->scale; 69 int padding = swaynag->type->button_padding;
70 70
71 return text_width + border * 2 + padding * 2; 71 return text_width + border * 2 + padding * 2;
72} 72}
73 73
74static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag, 74static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag,
75 uint32_t y) { 75 uint32_t y) {
76 uint32_t width = swaynag->width * swaynag->scale; 76 uint32_t width = swaynag->width;
77 77
78 int border = swaynag->type->details_border_thickness * swaynag->scale; 78 int border = swaynag->type->details_border_thickness;
79 int padding = swaynag->type->message_padding * swaynag->scale; 79 int padding = swaynag->type->message_padding;
80 int decor = padding + border; 80 int decor = padding + border;
81 81
82 swaynag->details.x = decor; 82 swaynag->details.x = decor;
83 swaynag->details.y = y * swaynag->scale + decor; 83 swaynag->details.y = y + decor;
84 swaynag->details.width = width - decor * 2; 84 swaynag->details.width = width - decor * 2;
85 85
86 PangoLayout *layout = get_pango_layout(cairo, swaynag->type->font, 86 PangoLayout *layout = get_pango_layout(cairo, swaynag->type->font,
87 swaynag->details.message, swaynag->scale, false); 87 swaynag->details.message, 1, false);
88 pango_layout_set_width(layout, 88 pango_layout_set_width(layout,
89 (swaynag->details.width - padding * 2) * PANGO_SCALE); 89 (swaynag->details.width - padding * 2) * PANGO_SCALE);
90 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); 90 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
@@ -164,7 +164,7 @@ static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag,
164 pango_cairo_show_layout(cairo, layout); 164 pango_cairo_show_layout(cairo, layout);
165 g_object_unref(layout); 165 g_object_unref(layout);
166 166
167 return ideal_height / swaynag->scale; 167 return ideal_height;
168} 168}
169 169
170static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag, 170static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag,
@@ -173,13 +173,13 @@ static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag,
173 173
174 int text_width, text_height; 174 int text_width, text_height;
175 get_text_size(cairo, swaynag->type->font, &text_width, &text_height, NULL, 175 get_text_size(cairo, swaynag->type->font, &text_width, &text_height, NULL,
176 swaynag->scale, true, "%s", button->text); 176 1, true, "%s", button->text);
177 177
178 int border = swaynag->type->button_border_thickness * swaynag->scale; 178 int border = swaynag->type->button_border_thickness;
179 int padding = swaynag->type->button_padding * swaynag->scale; 179 int padding = swaynag->type->button_padding;
180 180
181 uint32_t ideal_height = text_height + padding * 2 + border * 2; 181 uint32_t ideal_height = text_height + padding * 2 + border * 2;
182 uint32_t ideal_surface_height = ideal_height / swaynag->scale; 182 uint32_t ideal_surface_height = ideal_height;
183 if (swaynag->height < ideal_surface_height) { 183 if (swaynag->height < ideal_surface_height) {
184 return ideal_surface_height; 184 return ideal_surface_height;
185 } 185 }
@@ -201,7 +201,7 @@ static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag,
201 201
202 cairo_set_source_u32(cairo, swaynag->type->button_text); 202 cairo_set_source_u32(cairo, swaynag->type->button_text);
203 cairo_move_to(cairo, button->x + padding, button->y + padding); 203 cairo_move_to(cairo, button->x + padding, button->y + padding);
204 pango_printf(cairo, swaynag->type->font, swaynag->scale, true, 204 pango_printf(cairo, swaynag->type->font, 1, true,
205 "%s", button->text); 205 "%s", button->text);
206 206
207 *x = button->x - border; 207 *x = button->x - border;
@@ -220,13 +220,12 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) {
220 max_height = h > max_height ? h : max_height; 220 max_height = h > max_height ? h : max_height;
221 221
222 int x = swaynag->width - swaynag->type->button_margin_right; 222 int x = swaynag->width - swaynag->type->button_margin_right;
223 x *= swaynag->scale;
224 for (int i = 0; i < swaynag->buttons->length; i++) { 223 for (int i = 0; i < swaynag->buttons->length; i++) {
225 h = render_button(cairo, swaynag, i, &x); 224 h = render_button(cairo, swaynag, i, &x);
226 max_height = h > max_height ? h : max_height; 225 max_height = h > max_height ? h : max_height;
227 x -= swaynag->type->button_gap * swaynag->scale; 226 x -= swaynag->type->button_gap;
228 if (i == 0) { 227 if (i == 0) {
229 x -= swaynag->type->button_gap_close * swaynag->scale; 228 x -= swaynag->type->button_gap_close;
230 } 229 }
231 } 230 }
232 231
@@ -235,14 +234,14 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) {
235 max_height = h > max_height ? h : max_height; 234 max_height = h > max_height ? h : max_height;
236 } 235 }
237 236
238 int border = swaynag->type->bar_border_thickness * swaynag->scale; 237 int border = swaynag->type->bar_border_thickness;
239 if (max_height > swaynag->height) { 238 if (max_height > swaynag->height) {
240 max_height += border; 239 max_height += border;
241 } 240 }
242 cairo_set_source_u32(cairo, swaynag->type->border_bottom); 241 cairo_set_source_u32(cairo, swaynag->type->border_bottom);
243 cairo_rectangle(cairo, 0, 242 cairo_rectangle(cairo, 0,
244 swaynag->height * swaynag->scale - border, 243 swaynag->height - border,
245 swaynag->width * swaynag->scale, 244 swaynag->width,
246 border); 245 border);
247 cairo_fill(cairo); 246 cairo_fill(cairo);
248 247
@@ -257,6 +256,7 @@ void render_frame(struct swaynag *swaynag) {
257 cairo_surface_t *recorder = cairo_recording_surface_create( 256 cairo_surface_t *recorder = cairo_recording_surface_create(
258 CAIRO_CONTENT_COLOR_ALPHA, NULL); 257 CAIRO_CONTENT_COLOR_ALPHA, NULL);
259 cairo_t *cairo = cairo_create(recorder); 258 cairo_t *cairo = cairo_create(recorder);
259 cairo_scale(cairo, swaynag->scale, swaynag->scale);
260 cairo_save(cairo); 260 cairo_save(cairo);
261 cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR); 261 cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR);
262 cairo_paint(cairo); 262 cairo_paint(cairo);