diff options
Diffstat (limited to 'swaybar/render.c')
-rw-r--r-- | swaybar/render.c | 175 |
1 files changed, 112 insertions, 63 deletions
diff --git a/swaybar/render.c b/swaybar/render.c index 6f3b0788..be58301d 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -14,55 +14,72 @@ | |||
14 | #include "swaybar/status_line.h" | 14 | #include "swaybar/status_line.h" |
15 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" | 15 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" |
16 | 16 | ||
17 | static const int ws_horizontal_padding = 5; | 17 | static const int WS_HORIZONTAL_PADDING = 5; |
18 | static const double ws_vertical_padding = 1.5; | 18 | static const double WS_VERTICAL_PADDING = 1.5; |
19 | static const double border_width = 1; | 19 | 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_config *config, const char *error, | 22 | struct swaybar_output *output, struct swaybar_config *config, |
23 | double *x, uint32_t width, uint32_t 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 | } |
27 | |||
28 | uint32_t height = surface_height * output->scale; | ||
29 | |||
27 | cairo_set_source_u32(cairo, 0xFF0000FF); | 30 | cairo_set_source_u32(cairo, 0xFF0000FF); |
28 | static const int margin = 3; | 31 | |
32 | int margin = 3 * output->scale; | ||
33 | int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; | ||
34 | |||
29 | int text_width, text_height; | 35 | int text_width, text_height; |
30 | get_text_size(cairo, config->font, | 36 | get_text_size(cairo, config->font, |
31 | &text_width, &text_height, 1, false, "%s", error); | 37 | &text_width, &text_height, output->scale, false, "%s", error); |
38 | |||
32 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; | 39 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; |
33 | if (height < ideal_height) { | 40 | if (height < ideal_height) { |
34 | return ideal_height; | 41 | return ideal_height / output->scale; |
35 | } | 42 | } |
36 | *x -= text_width + margin; | 43 | *x -= text_width + margin; |
44 | |||
37 | double text_y = height / 2.0 - text_height / 2.0; | 45 | double text_y = height / 2.0 - text_height / 2.0; |
38 | cairo_move_to(cairo, *x, (int)floor(text_y)); | 46 | cairo_move_to(cairo, *x, (int)floor(text_y)); |
39 | pango_printf(cairo, config->font, 1, false, "%s", error); | 47 | pango_printf(cairo, config->font, output->scale, false, "%s", error); |
40 | *x -= margin; | 48 | *x -= margin; |
41 | return ideal_height; | 49 | return ideal_height / output->scale; |
42 | } | 50 | } |
43 | 51 | ||
44 | static uint32_t render_status_line_text(cairo_t *cairo, | 52 | static uint32_t render_status_line_text(cairo_t *cairo, |
45 | struct swaybar_config *config, const char *text, | 53 | struct swaybar_output *output, struct swaybar_config *config, |
46 | bool focused, double *x, uint32_t width, uint32_t height) { | 54 | const char *text, bool focused, double *x, uint32_t surface_height) { |
47 | if (!text) { | 55 | if (!text) { |
48 | return 0; | 56 | return 0; |
49 | } | 57 | } |
58 | |||
59 | uint32_t height = surface_height * output->scale; | ||
60 | |||
50 | cairo_set_source_u32(cairo, focused ? | 61 | cairo_set_source_u32(cairo, focused ? |
51 | config->colors.focused_statusline : config->colors.statusline); | 62 | config->colors.focused_statusline : config->colors.statusline); |
52 | static const int margin = 3; | 63 | |
53 | int text_width, text_height; | 64 | int text_width, text_height; |
54 | get_text_size(cairo, config->font, &text_width, &text_height, | 65 | get_text_size(cairo, config->font, &text_width, &text_height, |
55 | 1, config->pango_markup, "%s", text); | 66 | output->scale, config->pango_markup, "%s", text); |
67 | |||
68 | int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; | ||
69 | int margin = 3 * output->scale; | ||
70 | |||
56 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; | 71 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; |
57 | if (height < ideal_height) { | 72 | if (height < ideal_height) { |
58 | return ideal_height; | 73 | return ideal_height / output->scale; |
59 | } | 74 | } |
75 | |||
60 | *x -= text_width + margin; | 76 | *x -= text_width + margin; |
61 | double text_y = height / 2.0 - text_height / 2.0; | 77 | double text_y = height / 2.0 - text_height / 2.0; |
62 | cairo_move_to(cairo, *x, (int)floor(text_y)); | 78 | cairo_move_to(cairo, *x, (int)floor(text_y)); |
63 | pango_printf(cairo, config->font, 1, config->pango_markup, "%s", text); | 79 | pango_printf(cairo, config->font, output->scale, |
80 | config->pango_markup, "%s", text); | ||
64 | *x -= margin; | 81 | *x -= margin; |
65 | return ideal_height; | 82 | return ideal_height / output->scale; |
66 | } | 83 | } |
67 | 84 | ||
68 | static void render_sharp_line(cairo_t *cairo, uint32_t color, | 85 | static void render_sharp_line(cairo_t *cairo, uint32_t color, |
@@ -99,23 +116,29 @@ static void block_hotspot_callback(struct swaybar_output *output, | |||
99 | static uint32_t render_status_block(cairo_t *cairo, | 116 | static uint32_t render_status_block(cairo_t *cairo, |
100 | struct swaybar_config *config, struct swaybar_output *output, | 117 | struct swaybar_config *config, struct swaybar_output *output, |
101 | struct i3bar_block *block, double *x, | 118 | struct i3bar_block *block, double *x, |
102 | uint32_t height, bool focused, bool edge) { | 119 | uint32_t surface_height, bool focused, bool edge) { |
103 | static const int margin = 3; | ||
104 | if (!block->full_text || !*block->full_text) { | 120 | if (!block->full_text || !*block->full_text) { |
105 | return 0; | 121 | return 0; |
106 | } | 122 | } |
107 | 123 | ||
124 | uint32_t height = surface_height * output->scale; | ||
125 | |||
108 | int text_width, text_height; | 126 | int text_width, text_height; |
109 | get_text_size(cairo, config->font, &text_width, &text_height, | 127 | get_text_size(cairo, config->font, &text_width, &text_height, |
110 | 1, block->markup, "%s", block->full_text); | 128 | output->scale, block->markup, "%s", block->full_text); |
129 | |||
130 | int margin = 3 * output->scale; | ||
131 | int ws_vertical_padding = WS_VERTICAL_PADDING * 2; | ||
132 | |||
111 | int width = text_width; | 133 | int width = text_width; |
112 | if (width < block->min_width) { | 134 | if (width < block->min_width) { |
113 | width = block->min_width; | 135 | width = block->min_width; |
114 | } | 136 | } |
137 | |||
115 | double block_width = width; | 138 | double block_width = width; |
116 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; | 139 | uint32_t ideal_height = text_height + ws_vertical_padding * 2; |
117 | if (height < ideal_height) { | 140 | if (height < ideal_height) { |
118 | return ideal_height; | 141 | return ideal_height / output->scale; |
119 | } | 142 | } |
120 | 143 | ||
121 | *x -= width; | 144 | *x -= width; |
@@ -133,10 +156,10 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
133 | if (config->sep_symbol) { | 156 | if (config->sep_symbol) { |
134 | int _height; | 157 | int _height; |
135 | get_text_size(cairo, config->font, &sep_width, &_height, | 158 | get_text_size(cairo, config->font, &sep_width, &_height, |
136 | 1, false, "%s", config->sep_symbol); | 159 | output->scale, false, "%s", config->sep_symbol); |
137 | uint32_t _ideal_height = _height + ws_vertical_padding * 2; | 160 | uint32_t _ideal_height = _height + ws_vertical_padding * 2; |
138 | if (height < _ideal_height) { | 161 | if ((uint32_t)_height < _ideal_height / output->scale) { |
139 | return _height; | 162 | return _height / output->scale; |
140 | } | 163 | } |
141 | if (sep_width > block->separator_block_width) { | 164 | if (sep_width > block->separator_block_width) { |
142 | block->separator_block_width = sep_width + margin * 2; | 165 | block->separator_block_width = sep_width + margin * 2; |
@@ -160,22 +183,26 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
160 | double pos = *x; | 183 | double pos = *x; |
161 | if (block->background) { | 184 | if (block->background) { |
162 | cairo_set_source_u32(cairo, block->background); | 185 | cairo_set_source_u32(cairo, block->background); |
163 | cairo_rectangle(cairo, pos - 0.5, 1, block_width, height); | 186 | cairo_rectangle(cairo, pos - 0.5 * output->scale, |
187 | output->scale, block_width, height); | ||
164 | cairo_fill(cairo); | 188 | cairo_fill(cairo); |
165 | } | 189 | } |
166 | 190 | ||
167 | if (block->border && block->border_top > 0) { | 191 | if (block->border && block->border_top > 0) { |
168 | render_sharp_line(cairo, block->border, | 192 | render_sharp_line(cairo, block->border, |
169 | pos - 0.5, 1, block_width, block->border_top); | 193 | pos - 0.5 * output->scale, output->scale, |
194 | block_width, block->border_top); | ||
170 | } | 195 | } |
171 | if (block->border && block->border_bottom > 0) { | 196 | if (block->border && block->border_bottom > 0) { |
172 | render_sharp_line(cairo, block->border, | 197 | render_sharp_line(cairo, block->border, |
173 | pos - 0.5, height - 1 - block->border_bottom, | 198 | pos - 0.5 * output->scale, |
199 | height - output->scale - block->border_bottom, | ||
174 | block_width, block->border_bottom); | 200 | block_width, block->border_bottom); |
175 | } | 201 | } |
176 | if (block->border != 0 && block->border_left > 0) { | 202 | if (block->border != 0 && block->border_left > 0) { |
177 | render_sharp_line(cairo, block->border, | 203 | render_sharp_line(cairo, block->border, |
178 | pos - 0.5, 1, block->border_left, height); | 204 | pos - 0.5 * output->scale, output->scale, |
205 | block->border_left, height); | ||
179 | pos += block->border_left + margin; | 206 | pos += block->border_left + margin; |
180 | } | 207 | } |
181 | 208 | ||
@@ -190,13 +217,15 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
190 | cairo_move_to(cairo, offset, height / 2.0 - text_height / 2.0); | 217 | cairo_move_to(cairo, offset, height / 2.0 - text_height / 2.0); |
191 | uint32_t color = block->color ? *block->color : config->colors.statusline; | 218 | uint32_t color = block->color ? *block->color : config->colors.statusline; |
192 | cairo_set_source_u32(cairo, color); | 219 | cairo_set_source_u32(cairo, color); |
193 | pango_printf(cairo, config->font, 1, block->markup, "%s", block->full_text); | 220 | pango_printf(cairo, config->font, output->scale, |
221 | block->markup, "%s", block->full_text); | ||
194 | pos += width; | 222 | pos += width; |
195 | 223 | ||
196 | if (block->border && block->border_right > 0) { | 224 | if (block->border && block->border_right > 0) { |
197 | pos += margin; | 225 | pos += margin; |
198 | render_sharp_line(cairo, block->border, | 226 | render_sharp_line(cairo, block->border, |
199 | pos - 0.5, 1, block->border_right, height); | 227 | pos - 0.5 * output->scale, output->scale, |
228 | block->border_right, height); | ||
200 | pos += block->border_right; | 229 | pos += block->border_right; |
201 | } | 230 | } |
202 | 231 | ||
@@ -209,7 +238,7 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
209 | if (config->sep_symbol) { | 238 | if (config->sep_symbol) { |
210 | offset = pos + (block->separator_block_width - sep_width) / 2; | 239 | offset = pos + (block->separator_block_width - sep_width) / 2; |
211 | cairo_move_to(cairo, offset, margin); | 240 | cairo_move_to(cairo, offset, margin); |
212 | pango_printf(cairo, config->font, 1, false, | 241 | pango_printf(cairo, config->font, output->scale, false, |
213 | "%s", config->sep_symbol); | 242 | "%s", config->sep_symbol); |
214 | } else { | 243 | } else { |
215 | cairo_set_line_width(cairo, 1); | 244 | cairo_set_line_width(cairo, 1); |
@@ -220,19 +249,19 @@ static uint32_t render_status_block(cairo_t *cairo, | |||
220 | cairo_stroke(cairo); | 249 | cairo_stroke(cairo); |
221 | } | 250 | } |
222 | } | 251 | } |
223 | return ideal_height; | 252 | return ideal_height / output->scale; |
224 | } | 253 | } |
225 | 254 | ||
226 | static uint32_t render_status_line_i3bar(cairo_t *cairo, | 255 | static uint32_t render_status_line_i3bar(cairo_t *cairo, |
227 | struct swaybar_config *config, struct swaybar_output *output, | 256 | struct swaybar_config *config, struct swaybar_output *output, |
228 | struct status_line *status, bool focused, | 257 | struct status_line *status, bool focused, |
229 | double *x, uint32_t width, uint32_t height) { | 258 | double *x, uint32_t surface_height) { |
230 | uint32_t max_height = 0; | 259 | uint32_t max_height = 0; |
231 | bool edge = true; | 260 | bool edge = true; |
232 | struct i3bar_block *block; | 261 | struct i3bar_block *block; |
233 | wl_list_for_each(block, &status->blocks, link) { | 262 | wl_list_for_each(block, &status->blocks, link) { |
234 | uint32_t h = render_status_block(cairo, config, output, | 263 | uint32_t h = render_status_block(cairo, config, output, |
235 | block, x, height, focused, edge); | 264 | block, x, surface_height, focused, edge); |
236 | max_height = h > max_height ? h : max_height; | 265 | max_height = h > max_height ? h : max_height; |
237 | edge = false; | 266 | edge = false; |
238 | } | 267 | } |
@@ -242,17 +271,17 @@ static uint32_t render_status_line_i3bar(cairo_t *cairo, | |||
242 | static uint32_t render_status_line(cairo_t *cairo, | 271 | static uint32_t render_status_line(cairo_t *cairo, |
243 | struct swaybar_config *config, struct swaybar_output *output, | 272 | struct swaybar_config *config, struct swaybar_output *output, |
244 | struct status_line *status, bool focused, | 273 | struct status_line *status, bool focused, |
245 | double *x, uint32_t width, uint32_t height) { | 274 | double *x, uint32_t surface_height) { |
246 | switch (status->protocol) { | 275 | switch (status->protocol) { |
247 | case PROTOCOL_ERROR: | 276 | case PROTOCOL_ERROR: |
248 | return render_status_line_error(cairo, | 277 | return render_status_line_error(cairo, output, config, |
249 | config, status->text, x, width, height); | 278 | status->text, x, surface_height); |
250 | case PROTOCOL_TEXT: | 279 | case PROTOCOL_TEXT: |
251 | return render_status_line_text(cairo, | 280 | return render_status_line_text(cairo, output, config, |
252 | config, status->text, focused, x, width, height); | 281 | status->text, focused, x, surface_height); |
253 | case PROTOCOL_I3BAR: | 282 | case PROTOCOL_I3BAR: |
254 | return render_status_line_i3bar(cairo, config, output, status, | 283 | return render_status_line_i3bar(cairo, config, output, |
255 | focused, x, width, height); | 284 | status, focused, x, surface_height); |
256 | case PROTOCOL_UNDEF: | 285 | case PROTOCOL_UNDEF: |
257 | return 0; | 286 | return 0; |
258 | } | 287 | } |
@@ -260,15 +289,23 @@ static uint32_t render_status_line(cairo_t *cairo, | |||
260 | } | 289 | } |
261 | 290 | ||
262 | static uint32_t render_binding_mode_indicator(cairo_t *cairo, | 291 | static uint32_t render_binding_mode_indicator(cairo_t *cairo, |
263 | struct swaybar_config *config, const char *mode, double x, | 292 | struct swaybar_output *output, struct swaybar_config *config, |
264 | uint32_t height) { | 293 | const char *mode, double x, uint32_t surface_height) { |
294 | |||
295 | uint32_t height = surface_height * output->scale; | ||
296 | |||
265 | int text_width, text_height; | 297 | int text_width, text_height; |
266 | get_text_size(cairo, config->font, &text_width, &text_height, | 298 | get_text_size(cairo, config->font, &text_width, &text_height, |
267 | 1, true, "%s", mode); | 299 | output->scale, true, "%s", mode); |
300 | |||
301 | int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; | ||
302 | int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale; | ||
303 | int border_width = BORDER_WIDTH * output->scale; | ||
304 | |||
268 | uint32_t ideal_height = text_height + ws_vertical_padding * 2 | 305 | uint32_t ideal_height = text_height + ws_vertical_padding * 2 |
269 | + border_width * 2; | 306 | + border_width * 2; |
270 | if (height < ideal_height) { | 307 | if (height < ideal_height) { |
271 | return ideal_height; | 308 | return ideal_height / output->scale; |
272 | } | 309 | } |
273 | uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; | 310 | uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; |
274 | 311 | ||
@@ -289,8 +326,8 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo, | |||
289 | double text_y = height / 2.0 - text_height / 2.0; | 326 | double text_y = height / 2.0 - text_height / 2.0; |
290 | cairo_set_source_u32(cairo, config->colors.binding_mode.text); | 327 | cairo_set_source_u32(cairo, config->colors.binding_mode.text); |
291 | cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y)); | 328 | cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y)); |
292 | pango_printf(cairo, config->font, 1, true, "%s", mode); | 329 | pango_printf(cairo, config->font, output->scale, true, "%s", mode); |
293 | return ideal_height; | 330 | return ideal_height / output->scale; |
294 | } | 331 | } |
295 | 332 | ||
296 | static const char *strip_workspace_number(const char *ws_name) { | 333 | static const char *strip_workspace_number(const char *ws_name) { |
@@ -313,7 +350,7 @@ static void workspace_hotspot_callback(struct swaybar_output *output, | |||
313 | 350 | ||
314 | static uint32_t render_workspace_button(cairo_t *cairo, | 351 | static uint32_t render_workspace_button(cairo_t *cairo, |
315 | struct swaybar_output *output, struct swaybar_config *config, | 352 | struct swaybar_output *output, struct swaybar_config *config, |
316 | struct swaybar_workspace *ws, double *x, uint32_t height) { | 353 | struct swaybar_workspace *ws, double *x, uint32_t surface_height) { |
317 | const char *name = ws->name; | 354 | const char *name = ws->name; |
318 | if (config->strip_workspace_numbers) { | 355 | if (config->strip_workspace_numbers) { |
319 | name = strip_workspace_number(ws->name); | 356 | name = strip_workspace_number(ws->name); |
@@ -330,14 +367,22 @@ static uint32_t render_workspace_button(cairo_t *cairo, | |||
330 | box_colors = config->colors.inactive_workspace; | 367 | box_colors = config->colors.inactive_workspace; |
331 | } | 368 | } |
332 | 369 | ||
370 | uint32_t height = surface_height * output->scale; | ||
371 | |||
333 | int text_width, text_height; | 372 | int text_width, text_height; |
334 | get_text_size(cairo, config->font, &text_width, &text_height, | 373 | get_text_size(cairo, config->font, &text_width, &text_height, |
335 | 1, true, "%s", name); | 374 | output->scale, true, "%s", name); |
375 | |||
376 | int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; | ||
377 | int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale; | ||
378 | int border_width = BORDER_WIDTH * output->scale; | ||
379 | |||
336 | uint32_t ideal_height = ws_vertical_padding * 2 + text_height | 380 | uint32_t ideal_height = ws_vertical_padding * 2 + text_height |
337 | + border_width * 2; | 381 | + border_width * 2; |
338 | if (height < ideal_height) { | 382 | if (height < ideal_height) { |
339 | return ideal_height; | 383 | return ideal_height / output->scale; |
340 | } | 384 | } |
385 | |||
341 | uint32_t width = ws_horizontal_padding * 2 + text_width + border_width * 2; | 386 | uint32_t width = ws_horizontal_padding * 2 + text_width + border_width * 2; |
342 | 387 | ||
343 | cairo_set_source_u32(cairo, box_colors.background); | 388 | cairo_set_source_u32(cairo, box_colors.background); |
@@ -357,7 +402,7 @@ static uint32_t render_workspace_button(cairo_t *cairo, | |||
357 | double text_y = height / 2.0 - text_height / 2.0; | 402 | double text_y = height / 2.0 - text_height / 2.0; |
358 | cairo_set_source_u32(cairo, box_colors.text); | 403 | cairo_set_source_u32(cairo, box_colors.text); |
359 | cairo_move_to(cairo, *x + width / 2 - text_width / 2, (int)floor(text_y)); | 404 | cairo_move_to(cairo, *x + width / 2 - text_width / 2, (int)floor(text_y)); |
360 | pango_printf(cairo, config->font, 1, true, "%s", name); | 405 | pango_printf(cairo, config->font, output->scale, true, "%s", name); |
361 | 406 | ||
362 | struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot)); | 407 | struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot)); |
363 | hotspot->x = *x; | 408 | hotspot->x = *x; |
@@ -370,7 +415,7 @@ static uint32_t render_workspace_button(cairo_t *cairo, | |||
370 | wl_list_insert(&output->hotspots, &hotspot->link); | 415 | wl_list_insert(&output->hotspots, &hotspot->link); |
371 | 416 | ||
372 | *x += width; | 417 | *x += width; |
373 | return height; | 418 | return height / output->scale; |
374 | } | 419 | } |
375 | 420 | ||
376 | static uint32_t render_to_cairo(cairo_t *cairo, | 421 | static uint32_t render_to_cairo(cairo_t *cairo, |
@@ -394,7 +439,13 @@ static uint32_t render_to_cairo(cairo_t *cairo, | |||
394 | * height is too tall, the render function should adapt its drawing to | 439 | * height is too tall, the render function should adapt its drawing to |
395 | * utilize the available space. | 440 | * utilize the available space. |
396 | */ | 441 | */ |
397 | double x = 0; | 442 | double x = output->width * output->scale; |
443 | if (bar->status) { | ||
444 | uint32_t h = render_status_line(cairo, config, output, | ||
445 | bar->status, output->focused, &x, output->height); | ||
446 | max_height = h > max_height ? h : max_height; | ||
447 | } | ||
448 | x = 0; | ||
398 | if (config->workspace_buttons) { | 449 | if (config->workspace_buttons) { |
399 | struct swaybar_workspace *ws; | 450 | struct swaybar_workspace *ws; |
400 | wl_list_for_each_reverse(ws, &output->workspaces, link) { | 451 | wl_list_for_each_reverse(ws, &output->workspaces, link) { |
@@ -404,14 +455,8 @@ static uint32_t render_to_cairo(cairo_t *cairo, | |||
404 | } | 455 | } |
405 | } | 456 | } |
406 | if (config->binding_mode_indicator && config->mode) { | 457 | if (config->binding_mode_indicator && config->mode) { |
407 | uint32_t h = render_binding_mode_indicator( | 458 | uint32_t h = render_binding_mode_indicator(cairo, |
408 | cairo, config, config->mode, x, output->height); | 459 | output, config, config->mode, x, output->height); |
409 | max_height = h > max_height ? h : max_height; | ||
410 | } | ||
411 | x = output->width; | ||
412 | if (bar->status) { | ||
413 | uint32_t h = render_status_line(cairo, config, output, bar->status, | ||
414 | output->focused, &x, output->width, output->height); | ||
415 | max_height = h > max_height ? h : max_height; | 460 | max_height = h > max_height ? h : max_height; |
416 | } | 461 | } |
417 | 462 | ||
@@ -451,7 +496,9 @@ void render_frame(struct swaybar *bar, struct swaybar_output *output) { | |||
451 | } else { | 496 | } else { |
452 | // Replay recording into shm and send it off | 497 | // Replay recording into shm and send it off |
453 | output->current_buffer = get_next_buffer(bar->shm, | 498 | output->current_buffer = get_next_buffer(bar->shm, |
454 | output->buffers, output->width, output->height); | 499 | output->buffers, |
500 | output->width * output->scale, | ||
501 | output->height * output->scale); | ||
455 | cairo_t *shm = output->current_buffer->cairo; | 502 | cairo_t *shm = output->current_buffer->cairo; |
456 | 503 | ||
457 | cairo_save(shm); | 504 | cairo_save(shm); |
@@ -462,9 +509,11 @@ void render_frame(struct swaybar *bar, struct swaybar_output *output) { | |||
462 | cairo_set_source_surface(shm, recorder, 0.0, 0.0); | 509 | cairo_set_source_surface(shm, recorder, 0.0, 0.0); |
463 | cairo_paint(shm); | 510 | cairo_paint(shm); |
464 | 511 | ||
512 | wl_surface_set_buffer_scale(output->surface, output->scale); | ||
465 | wl_surface_attach(output->surface, | 513 | wl_surface_attach(output->surface, |
466 | output->current_buffer->buffer, 0, 0); | 514 | output->current_buffer->buffer, 0, 0); |
467 | wl_surface_damage(output->surface, 0, 0, output->width, output->height); | 515 | wl_surface_damage(output->surface, 0, 0, |
516 | output->width, output->height); | ||
468 | wl_surface_commit(output->surface); | 517 | wl_surface_commit(output->surface); |
469 | wl_display_roundtrip(bar->display); | 518 | wl_display_roundtrip(bar->display); |
470 | } | 519 | } |