]> git.mdlowis.com Git - proto/labwc.git/commitdiff
menu: slightly slide menus opened with atCursor="no"
authortokyo4j <hrak1529@gmail.com>
Wed, 18 Dec 2024 16:06:48 +0000 (01:06 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 18 Dec 2024 18:43:03 +0000 (18:43 +0000)
This is reland of 2ade6a1e which was reverted with 21bd5b00, but this
prevents the x-position of the menu from being negative and slides menus
opened with Alt-Space too.

src/action.c

index fdce2b4f08790cc75487d0578d3643ca1362fbeb..ce4f077f041e86b7b0336a4fd1267201e14f7a41 100644 (file)
@@ -670,14 +670,17 @@ show_menu(struct server *server, struct view *view, struct cursor_context *ctx,
        }
        /* Place menu in the view corner if desired (and menu is not root-menu) */
        if (!at_cursor && view) {
-               x = view->current.x;
+               struct wlr_box extent = ssd_max_extents(view);
+               x = extent.x;
                y = view->current.y;
                /* Push the client menu underneath the button */
                if (is_client_menu && ssd_part_contains(
                                LAB_SSD_BUTTON, ctx->type)) {
                        assert(ctx->node);
-                       int ly;
-                       wlr_scene_node_coords(ctx->node, &x, &ly);
+                       int lx, ly;
+                       wlr_scene_node_coords(ctx->node, &lx, &ly);
+                       /* MAX() prevents negative x when the window is maximized */
+                       x = MAX(x, lx - server->theme->menu_border_width);
                }
        }