]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xdg-popup: uncontrain popups
authorJohan Malm <jgm323@gmail.com>
Tue, 2 Mar 2021 20:51:32 +0000 (20:51 +0000)
committerJohan Malm <jgm323@gmail.com>
Tue, 2 Mar 2021 20:51:32 +0000 (20:51 +0000)
src/xdg-popup.c

index f4b9b1812ef6f51bae5c25977e53239936718475..c1a50efd2eadbea24129f07048ab2b47ef567d71 100644 (file)
@@ -50,6 +50,28 @@ popup_handle_new_xdg_popup(struct wl_listener *listener, void *data)
        xdg_popup_create(popup->view_child.parent, wlr_popup);
 }
 
+static void
+popup_unconstrain(struct xdg_popup *popup)
+{
+       struct view *view = popup->view_child.parent;
+       struct server *server = view->server;
+       struct wlr_box *popup_box = &popup->wlr_popup->geometry;
+       struct wlr_output_layout *output_layout = server->output_layout;
+       struct wlr_output *wlr_output = wlr_output_layout_output_at(
+               output_layout, view->x + popup_box->x, view->y + popup_box->y);
+       struct wlr_box *output_box = wlr_output_layout_get_box(
+               output_layout, wlr_output);
+
+       struct wlr_box output_toplevel_box = {
+               .x = output_box->x - view->x,
+               .y = output_box->y - view->y,
+               .width = output_box->width,
+               .height = output_box->height,
+       };
+       wlr_xdg_popup_unconstrain_from_box(
+               popup->wlr_popup, &output_toplevel_box);
+}
+
 void
 xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup)
 {
@@ -70,5 +92,5 @@ xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup)
        popup->new_popup.notify = popup_handle_new_xdg_popup;
        wl_signal_add(&wlr_popup->base->events.new_popup, &popup->new_popup);
 
-       /* TODO: popup_unconstrain() */
+       popup_unconstrain(popup);
 }