diff options
author | M Stoeckl <code@mstoeckl.com> | 2024-10-31 10:27:47 -0400 |
---|---|---|
committer | adnano <adnano@noreply.codeberg.org> | 2024-11-01 23:33:53 +0000 |
commit | 0947765fc9a4f6fc4287acfcd2efcaf4fef1ffb8 (patch) | |
tree | e123c7fe7ded1913957731c5a91d3d6eba4fd431 /menu.c | |
parent | 260eaba88ec8f54fe2bdbe391b18fcd2db70836f (diff) | |
download | wmenu-0947765fc9a4f6fc4287acfcd2efcaf4fef1ffb8.tar.gz |
Only call render_menu once per frame
An actual surface is not needed to estimate font sizes; a 1x1 image
will do, as long as the cairo context has the same options.
Diffstat (limited to 'menu.c')
-rw-r--r-- | menu.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -34,6 +34,8 @@ struct menu *menu_create(menu_callback callback) { menu->selectionbg = 0x005577ff; menu->selectionfg = 0xeeeeeeff; menu->callback = callback; + menu->test_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); + menu->test_cairo = cairo_create(menu->test_surface); return menu; } @@ -58,6 +60,8 @@ static void free_items(struct menu *menu) { void menu_destroy(struct menu *menu) { free_pages(menu); free_items(menu); + cairo_destroy(menu->test_cairo); + cairo_surface_destroy(menu->test_surface); free(menu); } @@ -374,7 +378,6 @@ static void match_items(struct menu *menu) { // Render menu items. void menu_render_items(struct menu *menu) { - render_menu(menu); calc_widths(menu); match_items(menu); render_menu(menu); |