Refactor the logic of placing client-menu with ShowMenu action

Before this commit, we assumed `ShowMenu` action is not bound to any
buttons other than window menu button and always place the client-menu
under the window-menu button when atCursor="no". Also, it was going to be
difficult to distinguish whether the action is executed from the window
menu button or the window icon, which will be added soon.

This commit fixes it to open the menu under the actually-clicked button by
passing `cursor_context` to `actions_run()`, with some refactoring:
- `seat->pressed.resize_edges` is removed and it's calculated from the
  cursor position and `seat->pressed.type` just before running Resize
  action. This slightly changes the existing logic to determine the
  resizing edges with Alt-Right + Drag mousebinding, but
  `seat->pressed.type` is still stored on button press so it doesn't bring
  back the issue #543.
- `seat->pressed.toplevel` is removed and `get_toplevel()` in
  `update_pressed_surface()` may be called more often, but its overhead
  will be negligible.
This commit is contained in:
tokyo4j 2024-09-21 01:11:27 +09:00 committed by Johan Malm
parent d29464bac7
commit 25f5cdd3a6
12 changed files with 67 additions and 109 deletions

View file

@ -7,6 +7,7 @@
struct view;
struct server;
struct cursor_context;
struct action {
struct wl_list link; /*
@ -34,8 +35,16 @@ void action_arg_from_xml_node(struct action *action, const char *nodename, const
bool actions_contain_toggle_keybinds(struct wl_list *action_list);
/**
* actions_run() - Run actions.
* @activator: Target view to apply actions (e.g. Maximize, Focus etc.).
* NULL is allowed, in which case the focused/hovered view is used.
* @ctx: Set for action invocations via mousebindings. Used to get the
* direction of resize or the position of the window menu button for ShowMenu
* action.
*/
void actions_run(struct view *activator, struct server *server,
struct wl_list *actions, uint32_t resize_edges);
struct wl_list *actions, struct cursor_context *ctx);
void action_free(struct action *action);
void action_list_free(struct wl_list *action_list);