diff options
| author | Federico Angelilli <code@fedang.net> | 2024-03-23 12:18:21 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-03-23 12:18:21 +0100 |
| commit | cccfc17f790e84a9e574af97726cc5ef63a22447 (patch) | |
| tree | 22f4c4fbe1ebf6bb2ada31fa636a238fb81b0990 /src/draw.c | |
| parent | 46de28e9789618b2ea7af66c461f3f7db5ef0bd5 (diff) | |
Move surface scaling
Diffstat (limited to 'src/draw.c')
| -rw-r--r-- | src/draw.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -83,9 +83,6 @@ static void paint_text(cairo_t *cr, const Layout *layout) cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); cairo_move_to(cr, text_x, text_y); - // Update for scale - pango_cairo_update_layout(cr, layout->pl); - // NOTE: This works only if the text didn't change in size after the layouting pango_layout_set_text(layout->pl, CAST(layout->btn, ButtonSimple)->text, -1); pango_cairo_update_layout(cr, layout->pl); @@ -126,11 +123,6 @@ void draw_paint(Drawer *draw, Window *win) // Back buffering cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, draw->width, draw->height); - // Set scale - double scale = window_get_scale(win); - cairo_surface_set_device_scale(win->surface, scale, scale); - pango_cairo_update_context(win->cr, draw->context); - cairo_t *cr = cairo_create(surface); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); @@ -144,6 +136,7 @@ void draw_paint(Drawer *draw, Window *win) cairo_destroy(cr); // Use device pixels + double scale = window_get_scale(win); window_move(win, draw->left_pad * scale, draw->top_pad * scale); window_resize(win, draw->width * scale, draw->height * scale); @@ -292,6 +285,11 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns) // Move this somewhere else compute_width(draw, win); + double scale = window_get_scale(win); + cairo_surface_set_device_scale(win->surface, scale, scale); + pango_cairo_context_set_resolution(draw->context, scale * 96); + pango_cairo_update_context(win->cr, draw->context); + memset(draw->layout_end, 0, sizeof(draw->layout_end)); memset(draw->layout_bx, 0, sizeof(draw->layout_bx)); |
