summaryrefslogtreecommitdiffstats
path: root/swaybar/render.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/render.c')
-rw-r--r--swaybar/render.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/swaybar/render.c b/swaybar/render.c
index 58325050..7bc060d5 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -51,7 +51,8 @@ static void render_sharp_line(cairo_t *cairo, uint32_t color, double x, double y
51 51
52static void render_block(struct window *window, struct config *config, struct status_block *block, double *x, bool edge) { 52static void render_block(struct window *window, struct config *config, struct status_block *block, double *x, bool edge) {
53 int width, height, sep_width; 53 int width, height, sep_width;
54 get_text_size(window->cairo, window->font, &width, &height, block->markup, "%s", block->full_text); 54 get_text_size(window->cairo, window->font, &width, &height,
55 window->scale, block->markup, "%s", block->full_text);
55 56
56 int textwidth = width; 57 int textwidth = width;
57 double block_width = width; 58 double block_width = width;
@@ -75,7 +76,8 @@ static void render_block(struct window *window, struct config *config, struct st
75 // Add separator 76 // Add separator
76 if (!edge) { 77 if (!edge) {
77 if (config->sep_symbol) { 78 if (config->sep_symbol) {
78 get_text_size(window->cairo, window->font, &sep_width, &height, false, "%s", config->sep_symbol); 79 get_text_size(window->cairo, window->font, &sep_width, &height,
80 window->scale, false, "%s", config->sep_symbol);
79 if (sep_width > block->separator_block_width) { 81 if (sep_width > block->separator_block_width) {
80 block->separator_block_width = sep_width + margin * 2; 82 block->separator_block_width = sep_width + margin * 2;
81 } 83 }
@@ -137,7 +139,8 @@ static void render_block(struct window *window, struct config *config, struct st
137 139
138 cairo_move_to(window->cairo, offset, margin); 140 cairo_move_to(window->cairo, offset, margin);
139 cairo_set_source_u32(window->cairo, block->color); 141 cairo_set_source_u32(window->cairo, block->color);
140 pango_printf(window->cairo, window->font, block->markup, "%s", block->full_text); 142 pango_printf(window->cairo, window->font, window->scale,
143 block->markup, "%s", block->full_text);
141 144
142 pos += width; 145 pos += width;
143 146
@@ -160,7 +163,8 @@ static void render_block(struct window *window, struct config *config, struct st
160 if (config->sep_symbol) { 163 if (config->sep_symbol) {
161 offset = pos + (block->separator_block_width - sep_width) / 2; 164 offset = pos + (block->separator_block_width - sep_width) / 2;
162 cairo_move_to(window->cairo, offset, margin); 165 cairo_move_to(window->cairo, offset, margin);
163 pango_printf(window->cairo, window->font, false, "%s", config->sep_symbol); 166 pango_printf(window->cairo, window->font, window->scale,
167 false, "%s", config->sep_symbol);
164 } else { 168 } else {
165 cairo_set_line_width(window->cairo, 1); 169 cairo_set_line_width(window->cairo, 1);
166 cairo_move_to(window->cairo, pos + block->separator_block_width/2, 170 cairo_move_to(window->cairo, pos + block->separator_block_width/2,
@@ -200,7 +204,8 @@ static const char *strip_workspace_name(bool strip_num, const char *ws_name) {
200void workspace_button_size(struct window *window, const char *workspace_name, int *width, int *height) { 204void workspace_button_size(struct window *window, const char *workspace_name, int *width, int *height) {
201 const char *stripped_name = strip_workspace_name(swaybar.config->strip_workspace_numbers, workspace_name); 205 const char *stripped_name = strip_workspace_name(swaybar.config->strip_workspace_numbers, workspace_name);
202 206
203 get_text_size(window->cairo, window->font, width, height, false, "%s", stripped_name); 207 get_text_size(window->cairo, window->font, width, height,
208 window->scale, false, "%s", stripped_name);
204 *width += 2 * ws_horizontal_padding; 209 *width += 2 * ws_horizontal_padding;
205 *height += 2 * ws_vertical_padding; 210 *height += 2 * ws_vertical_padding;
206} 211}
@@ -235,14 +240,16 @@ static void render_workspace_button(struct window *window, struct config *config
235 // text 240 // text
236 cairo_set_source_u32(window->cairo, box_colors.text); 241 cairo_set_source_u32(window->cairo, box_colors.text);
237 cairo_move_to(window->cairo, (int)*x + ws_horizontal_padding, margin); 242 cairo_move_to(window->cairo, (int)*x + ws_horizontal_padding, margin);
238 pango_printf(window->cairo, window->font, false, "%s", stripped_name); 243 pango_printf(window->cairo, window->font, window->scale,
244 false, "%s", stripped_name);
239 245
240 *x += width + ws_spacing; 246 *x += width + ws_spacing;
241} 247}
242 248
243static void render_binding_mode_indicator(struct window *window, struct config *config, double pos) { 249static void render_binding_mode_indicator(struct window *window, struct config *config, double pos) {
244 int width, height; 250 int width, height;
245 get_text_size(window->cairo, window->font, &width, &height, false, "%s", config->mode); 251 get_text_size(window->cairo, window->font, &width, &height,
252 window->scale, false, "%s", config->mode);
246 253
247 // background 254 // background
248 cairo_set_source_u32(window->cairo, config->colors.binding_mode.background); 255 cairo_set_source_u32(window->cairo, config->colors.binding_mode.background);
@@ -259,7 +266,8 @@ static void render_binding_mode_indicator(struct window *window, struct config *
259 // text 266 // text
260 cairo_set_source_u32(window->cairo, config->colors.binding_mode.text); 267 cairo_set_source_u32(window->cairo, config->colors.binding_mode.text);
261 cairo_move_to(window->cairo, (int)pos + ws_horizontal_padding, margin); 268 cairo_move_to(window->cairo, (int)pos + ws_horizontal_padding, margin);
262 pango_printf(window->cairo, window->font, false, "%s", config->mode); 269 pango_printf(window->cairo, window->font, window->scale,
270 false, "%s", config->mode);
263} 271}
264 272
265void render(struct output *output, struct config *config, struct status_line *line) { 273void render(struct output *output, struct config *config, struct status_line *line) {
@@ -283,10 +291,12 @@ void render(struct output *output, struct config *config, struct status_line *li
283 int width, height; 291 int width, height;
284 292
285 if (line->protocol == TEXT) { 293 if (line->protocol == TEXT) {
286 get_text_size(window->cairo, window->font, &width, &height, config->pango_markup, "%s", line->text_line); 294 get_text_size(window->cairo, window->font, &width, &height,
295 window->scale, config->pango_markup, "%s", line->text_line);
287 cairo_move_to(cairo, (window->width * window->scale) 296 cairo_move_to(cairo, (window->width * window->scale)
288 - margin - width, margin); 297 - margin - width, margin);
289 pango_printf(window->cairo, window->font, config->pango_markup, "%s", line->text_line); 298 pango_printf(window->cairo, window->font, window->scale,
299 config->pango_markup, "%s", line->text_line);
290 } else if (line->protocol == I3BAR && line->block_line) { 300 } else if (line->protocol == I3BAR && line->block_line) {
291 double pos = window->width - 0.5; 301 double pos = window->width - 0.5;
292 bool edge = true; 302 bool edge = true;
@@ -319,7 +329,7 @@ void render(struct output *output, struct config *config, struct status_line *li
319void set_window_height(struct window *window, int height) { 329void set_window_height(struct window *window, int height) {
320 int text_width, text_height; 330 int text_width, text_height;
321 get_text_size(window->cairo, window->font, 331 get_text_size(window->cairo, window->font,
322 &text_width, &text_height, false, 332 &text_width, &text_height, window->scale, false,
323 "Test string for measuring purposes"); 333 "Test string for measuring purposes");
324 if (height > 0) { 334 if (height > 0) {
325 margin = (height - text_height) / 2; 335 margin = (height - text_height) / 2;