mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
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:
parent
d29464bac7
commit
25f5cdd3a6
12 changed files with 67 additions and 109 deletions
24
src/seat.c
24
src/seat.c
|
|
@ -722,22 +722,17 @@ pressed_surface_destroy(struct wl_listener *listener, void *data)
|
|||
}
|
||||
|
||||
void
|
||||
seat_set_pressed(struct seat *seat, struct view *view,
|
||||
struct wlr_scene_node *node, struct wlr_surface *surface,
|
||||
struct wlr_surface *toplevel, uint32_t resize_edges)
|
||||
seat_set_pressed(struct seat *seat, struct cursor_context *ctx)
|
||||
{
|
||||
assert(view || surface);
|
||||
assert(ctx);
|
||||
assert(ctx->view || ctx->surface);
|
||||
seat_reset_pressed(seat);
|
||||
|
||||
seat->pressed.view = view;
|
||||
seat->pressed.node = node;
|
||||
seat->pressed.surface = surface;
|
||||
seat->pressed.toplevel = toplevel;
|
||||
seat->pressed.resize_edges = resize_edges;
|
||||
seat->pressed = *ctx;
|
||||
|
||||
if (surface) {
|
||||
if (ctx->surface) {
|
||||
seat->pressed_surface_destroy.notify = pressed_surface_destroy;
|
||||
wl_signal_add(&surface->events.destroy,
|
||||
wl_signal_add(&ctx->surface->events.destroy,
|
||||
&seat->pressed_surface_destroy);
|
||||
}
|
||||
}
|
||||
|
|
@ -748,12 +743,7 @@ seat_reset_pressed(struct seat *seat)
|
|||
if (seat->pressed.surface) {
|
||||
wl_list_remove(&seat->pressed_surface_destroy.link);
|
||||
}
|
||||
|
||||
seat->pressed.view = NULL;
|
||||
seat->pressed.node = NULL;
|
||||
seat->pressed.surface = NULL;
|
||||
seat->pressed.toplevel = NULL;
|
||||
seat->pressed.resize_edges = 0;
|
||||
seat->pressed = (struct cursor_context){0};
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue