aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-03-23 12:18:21 +0100
committerFederico Angelilli <code@fedang.net>2024-03-23 12:18:21 +0100
commitcccfc17f790e84a9e574af97726cc5ef63a22447 (patch)
tree22f4c4fbe1ebf6bb2ada31fa636a238fb81b0990
parent46de28e9789618b2ea7af66c461f3f7db5ef0bd5 (diff)
Move surface scaling
-rw-r--r--src/draw.c14
-rw-r--r--src/window.c3
2 files changed, 9 insertions, 8 deletions
diff --git a/src/draw.c b/src/draw.c
index d989e70..c47aa00 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -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));
diff --git a/src/window.c b/src/window.c
index b35eb07..c179b0e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -181,6 +181,9 @@ cairo_t *window_get_context(Window *win)
double window_get_scale(Window *win)
{
+ // FIXME
+ return 1;
+
return MAX(1, win->con->screen_dpi / 96.0);
}