diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-30 01:02:50 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-08-01 22:47:54 -0400 |
commit | 0ef3988438c251c84251ef7a2723791856505065 (patch) | |
tree | 9b9273ad89656e1244b24ceb2a337387cdf939d6 /swaynag/render.c | |
parent | swaynag: allow more config options (diff) | |
download | sway-0ef3988438c251c84251ef7a2723791856505065.tar.gz sway-0ef3988438c251c84251ef7a2723791856505065.tar.zst sway-0ef3988438c251c84251ef7a2723791856505065.zip |
swaynag: fix hidpi
Diffstat (limited to 'swaynag/render.c')
-rw-r--r-- | swaynag/render.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/swaynag/render.c b/swaynag/render.c index bc3e520e..766409e4 100644 --- a/swaynag/render.c +++ b/swaynag/render.c | |||
@@ -25,10 +25,10 @@ static uint32_t render_message(cairo_t *cairo, struct swaynag *swaynag) { | |||
25 | 25 | ||
26 | cairo_set_source_u32(cairo, swaynag->type->text); | 26 | cairo_set_source_u32(cairo, swaynag->type->text); |
27 | cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); | 27 | cairo_move_to(cairo, padding, (int)(ideal_height - text_height) / 2); |
28 | pango_printf(cairo, swaynag->type->font, swaynag->scale, false, "%s", | 28 | pango_printf(cairo, swaynag->type->font, swaynag->scale, false, |
29 | swaynag->message); | 29 | "%s", swaynag->message); |
30 | 30 | ||
31 | return ideal_height; | 31 | return ideal_surface_height; |
32 | } | 32 | } |
33 | 33 | ||
34 | static void render_details_scroll_button(cairo_t *cairo, | 34 | static void render_details_scroll_button(cairo_t *cairo, |
@@ -61,9 +61,11 @@ static int get_detailed_scroll_button_width(cairo_t *cairo, | |||
61 | struct swaynag *swaynag) { | 61 | struct swaynag *swaynag) { |
62 | int up_width, down_width, temp_height; | 62 | int up_width, down_width, temp_height; |
63 | get_text_size(cairo, swaynag->type->font, &up_width, &temp_height, | 63 | get_text_size(cairo, swaynag->type->font, &up_width, &temp_height, |
64 | swaynag->scale, true, "%s", swaynag->details.button_up.text); | 64 | swaynag->scale, true, |
65 | "%s", swaynag->details.button_up.text); | ||
65 | get_text_size(cairo, swaynag->type->font, &down_width, &temp_height, | 66 | get_text_size(cairo, swaynag->type->font, &down_width, &temp_height, |
66 | swaynag->scale, true, "%s", swaynag->details.button_down.text); | 67 | swaynag->scale, true, |
68 | "%s", swaynag->details.button_down.text); | ||
67 | 69 | ||
68 | int text_width = up_width > down_width ? up_width : down_width; | 70 | int text_width = up_width > down_width ? up_width : down_width; |
69 | int border = swaynag->type->button_border_thickness * swaynag->scale; | 71 | int border = swaynag->type->button_border_thickness * swaynag->scale; |
@@ -83,7 +85,7 @@ static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag, | |||
83 | int decor = padding + border; | 85 | int decor = padding + border; |
84 | 86 | ||
85 | swaynag->details.x = decor; | 87 | swaynag->details.x = decor; |
86 | swaynag->details.y = y + decor; | 88 | swaynag->details.y = y * swaynag->scale + decor; |
87 | swaynag->details.width = width - decor * 2; | 89 | swaynag->details.width = width - decor * 2; |
88 | 90 | ||
89 | PangoLayout *layout = get_pango_layout(cairo, swaynag->type->font, | 91 | PangoLayout *layout = get_pango_layout(cairo, swaynag->type->font, |
@@ -167,7 +169,7 @@ static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag, | |||
167 | pango_cairo_show_layout(cairo, layout); | 169 | pango_cairo_show_layout(cairo, layout); |
168 | g_object_unref(layout); | 170 | g_object_unref(layout); |
169 | 171 | ||
170 | return ideal_height; | 172 | return ideal_height / swaynag->scale; |
171 | } | 173 | } |
172 | 174 | ||
173 | static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag, | 175 | static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag, |
@@ -211,7 +213,7 @@ static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag, | |||
211 | 213 | ||
212 | *x = button->x - border; | 214 | *x = button->x - border; |
213 | 215 | ||
214 | return ideal_height; | 216 | return ideal_surface_height; |
215 | } | 217 | } |
216 | 218 | ||
217 | static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) { | 219 | static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) { |
@@ -245,8 +247,10 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) { | |||
245 | max_height += border; | 247 | max_height += border; |
246 | } | 248 | } |
247 | cairo_set_source_u32(cairo, swaynag->type->border_bottom); | 249 | cairo_set_source_u32(cairo, swaynag->type->border_bottom); |
248 | cairo_rectangle(cairo, 0, swaynag->height * swaynag->scale - border, | 250 | cairo_rectangle(cairo, 0, |
249 | swaynag->width * swaynag->scale, border); | 251 | swaynag->height * swaynag->scale - border, |
252 | swaynag->width * swaynag->scale, | ||
253 | border); | ||
250 | cairo_fill(cairo); | 254 | cairo_fill(cairo); |
251 | 255 | ||
252 | return max_height; | 256 | return max_height; |