From 6942efee2d41a768501e23bd06f38dbb4fde197b Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Thu, 11 Jul 2024 15:10:24 +0200 Subject: Copy blocks --- src/comet.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/comet.c') diff --git a/src/comet.c b/src/comet.c index 66a90c9..c30a4e7 100644 --- a/src/comet.c +++ b/src/comet.c @@ -23,12 +23,15 @@ #define ANY_LOG_IMPLEMENT #include "any_log.h" -cairo_surface_t *render(layout_t *layout, layout_info_t info) +static cairo_surface_t *render_all(layout_t *layout, config_t *config, layout_info_t info) { - cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, info.width, info.height); + cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + config->width, + config->height); + log_value_trace("Created cairo surface", - "i:width", info.width, - "i:height", info.height); + "i:width", config->width, + "i:height", config->height); cairo_t *cr = cairo_create(surface); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); @@ -68,6 +71,8 @@ int main(int argc, char **argv) window_t window; window_init(&window, &display); + config.block.min_width = config.block.max_width = config.width; + int x_padding = 10; int y_padding = 8; @@ -79,7 +84,6 @@ int main(int argc, char **argv) .context = pango_cairo_create_context(window.cr), .x_offset = 0, .height = config.height, - .width = config.width, }; window_resize(&window, config.width, config.height); @@ -134,8 +138,8 @@ int main(int argc, char **argv) event_dispatch(&display, &layout); - cairo_surface_t *surface = render(&layout, info); - window_present(&window, surface, config.width, config.height); + cairo_surface_t *surface = render_all(&layout, &config, info); + window_present(&window, surface); cairo_surface_destroy(surface); layout_free(&layout); @@ -144,6 +148,10 @@ int main(int argc, char **argv) nanosleep(&diff, NULL); } + + g_object_unref(info.context); + pango_font_description_free(fontdesc); + window_close(&window); display_close(&display); config_free(&config); -- cgit v1.2.3