From 5dc06ce1f99e8ea25386bf3823b995be5f1cac53 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Mon, 26 Dec 2022 17:12:31 +0000 Subject: Convert to using Cairo scale. Instead of scaling various theme parameters ourselves, just set the scale in Cairo. This shouldn't result in any visible changes, but lays the ground work for fractional scaling support. --- src/entry.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/entry.c') diff --git a/src/entry.c b/src/entry.c index 6a55741..4ad825a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -64,6 +64,7 @@ void entry_init(struct entry *entry, uint8_t *restrict buffer, uint32_t width, u height, width * sizeof(uint32_t) ); + cairo_surface_set_device_scale(surface, scale, scale); cairo_t *cr = cairo_create(surface); entry->cairo[0].surface = surface; @@ -76,8 +77,12 @@ void entry_init(struct entry *entry, uint8_t *restrict buffer, uint32_t width, u height, width * sizeof(uint32_t) ); + cairo_surface_set_device_scale(entry->cairo[1].surface, scale, scale); entry->cairo[1].cr = cairo_create(entry->cairo[1].surface); + /* If we're scaling with Cairo, remember to account for that here. */ + width /= scale; + height /= scale; log_debug("Drawing window.\n"); /* Draw the background */ @@ -196,17 +201,6 @@ void entry_init(struct entry *entry, uint8_t *restrict buffer, uint32_t width, u entry->cursor_theme.text_color = entry->background_color; } - /* - * TODO: - * This is a dirty hack. The proper thing to do is probably just to - * stop scaling everything manually, set cairo_scale and have done - * with. The reason that isn't how things are currently done is due to - * historic scaling behaviour of tofi. - */ - if (!entry->cursor_theme.thickness_specified) { - entry->cursor_theme.thickness *= scale; - } - /* * Perform an initial render of the text. * This is done here rather than by calling entry_update to avoid the -- cgit v1.2.3