menu: lazily generate menu scenes

This removes the need to call update_client_list_combined_menu()
and update_client_send_to_menu() every time a root menu is opened.

This commit also fixed the incorrect menu position with following
configuration:
  <menu id="foo" label="foo">
    <item label="aaaaaa"/>
    <item label="bbbbbb"/>
  </menu>
  <menu id="root-menu">
    <menu id="foo" />
    <menu id="foo" />
  </menu>
This commit is contained in:
tokyo4j 2025-03-10 00:00:39 +09:00 committed by Hiroaki Yamamoto
parent 514f1d4fc4
commit 12f95543f0
3 changed files with 50 additions and 85 deletions

View file

@ -664,16 +664,6 @@ show_menu(struct server *server, struct view *view, struct cursor_context *ctx,
return;
}
/*
* We always refresh client-list-combined-menu and client-send-to-menu
* so that they are up-to-date whether they are directly opened as a
* top-level menu or opened as a submenu which we don't know at this
* point. It is also needed to calculate the proper width for placement
* as it fluctuates depending on application/workspace titles.
*/
update_client_list_combined_menu(menu->server);
update_client_send_to_menu(menu->server);
int x = server->seat.cursor->x;
int y = server->seat.cursor->y;