]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/xdg-popup.c: choose output depending on xdg-positioner
authortokyo4j <hrak1529@gmail.com>
Sat, 20 Jul 2024 17:33:51 +0000 (02:33 +0900)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 23 Jul 2024 12:53:33 +0000 (14:53 +0200)
wlr_popup->current.geometry.{x,y} are usually zero on initial commit, so
xdg-popups were always unconstrained against the output which contains
the top-left of the parent toplevel.

This commit changes xdg-popups to be unconstrained against the output
which contains the top-left of preliminary popup geometry designated by
xdg-positioner given as an argument of "get_popup" or "reposition"
requests.

src/xdg-popup.c

index c17d195a9a13986061b81c4d563f157af4ff7bde..a4b2295bb7132de3659115be630b0ae96b65a146 100644 (file)
@@ -27,10 +27,15 @@ popup_unconstrain(struct xdg_popup *popup)
 {
        struct view *view = popup->parent_view;
        struct server *server = view->server;
-       struct wlr_box *popup_box = &popup->wlr_popup->current.geometry;
+
+       int parent_lx, parent_ly;
+       struct wlr_scene_tree *parent_tree = popup->wlr_popup->parent->data;
+       wlr_scene_node_coords(&parent_tree->node, &parent_lx, &parent_ly);
+
+       struct wlr_box *popup_box = &popup->wlr_popup->scheduled.geometry;
        struct output *output = output_nearest_to(server,
-               view->current.x + popup_box->x,
-               view->current.y + popup_box->y);
+               parent_lx + popup_box->x,
+               parent_ly + popup_box->y);
        struct wlr_box usable = output_usable_area_in_layout_coords(output);
 
        struct wlr_box output_toplevel_box = {
@@ -116,7 +121,7 @@ xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup)
         * We must add xdg popups to the scene graph so they get rendered. The
         * wlroots scene graph provides a helper for this, but to use it we must
         * provide the proper parent scene node of the xdg popup. To enable
-        * this, we always set the user data field of xdg_surfaces to the
+        * this, we always set the user data field of wlr_surfaces to the
         * corresponding scene node.
         *
         * xdg-popups live in server->xdg_popup_tree so that they can be