From 3d022f08c0f48d7e20c42a1ffe208be8d3abcccf Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Sun, 22 Sep 2024 12:32:51 +0900 Subject: [PATCH] action: place menu at topleft of window when opened by leftmost button It will be more natural to place the menu at the topleft of the window when opened by the leftmost button just like before 8b1831c7. Suggested by @johanmalm. --- src/action.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/action.c b/src/action.c index 07b2fb3f..deac624a 100644 --- a/src/action.c +++ b/src/action.c @@ -617,6 +617,16 @@ action_list_free(struct wl_list *action_list) } } +static enum ssd_part_type +get_leftmost_button_type(void) +{ + struct title_button *b; + wl_list_for_each(b, &rc.title_buttons_left, link) { + return b->type; + } + return LAB_SSD_NONE; +} + static void show_menu(struct server *server, struct view *view, struct cursor_context *ctx, const char *menu_name, bool at_cursor, @@ -659,8 +669,8 @@ show_menu(struct server *server, struct view *view, struct cursor_context *ctx, x = view->current.x; y = view->current.y; /* Push the client menu underneath the button */ - if (is_client_menu && ssd_part_contains( - LAB_SSD_BUTTON, ctx->type)) { + if (is_client_menu && ssd_part_contains(LAB_SSD_BUTTON, ctx->type) + && ctx->type != get_leftmost_button_type()) { assert(ctx->node); int ly; wlr_scene_node_coords(ctx->node, &x, &ly);