Simplify render_menu - wmenu - 🔧 fork of wmenu
(HTM) git clone git@git.drkhsh.at/wmenu.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 3ad4b5ca3f9f66c71ec521d0d7261228ec7b4631
(DIR) parent 48ec172b4bd51da0736c24d84c72b574e4107b31
(HTM) Author: M Stoeckl <code@mstoeckl.com>
Date: Wed, 6 Nov 2024 14:31:46 -0500
Simplify render_menu
Diffstat:
M render.c | 31 ++++++-------------------------
1 file changed, 6 insertions(+), 25 deletions(-)
---
(DIR) diff --git a/render.c b/render.c
@@ -189,41 +189,22 @@ static void render_to_cairo(struct menu *menu, cairo_t *cairo) {
void render_menu(struct menu *menu) {
struct wl_context *context = menu->context;
- cairo_surface_t *recorder = cairo_recording_surface_create(
- CAIRO_CONTENT_COLOR_ALPHA, NULL);
- cairo_t *cairo = cairo_create(recorder);
- cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST);
- cairo_font_options_t *fo = cairo_font_options_create();
- cairo_set_font_options(cairo, fo);
- cairo_font_options_destroy(fo);
- cairo_save(cairo);
- cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR);
- cairo_paint(cairo);
- cairo_restore(cairo);
-
- render_to_cairo(menu, cairo);
-
int scale = context_get_scale(context);
struct pool_buffer *buffer = context_get_next_buffer(context, scale);
if (!buffer) {
- goto cleanup;
+ return;
}
cairo_t *shm = buffer->cairo;
- cairo_save(shm);
- cairo_set_operator(shm, CAIRO_OPERATOR_CLEAR);
- cairo_paint(shm);
- cairo_restore(shm);
- cairo_set_source_surface(shm, recorder, 0, 0);
- cairo_paint(shm);
+ cairo_set_antialias(shm, CAIRO_ANTIALIAS_BEST);
+ cairo_font_options_t *fo = cairo_font_options_create();
+ cairo_set_font_options(shm, fo);
+ cairo_font_options_destroy(fo);
+ render_to_cairo(menu, shm);
struct wl_surface *surface = context_get_surface(context);
wl_surface_set_buffer_scale(surface, scale);
wl_surface_attach(surface, buffer->buffer, 0, 0);
wl_surface_damage(surface, 0, 0, menu->width, menu->height);
wl_surface_commit(surface);
-
-cleanup:
- cairo_destroy(cairo);
- cairo_surface_destroy(recorder);
}