From: tokyo4j Date: Mon, 22 Jul 2024 07:20:17 +0000 (+0900) Subject: src/xdg-popup.c: take into account CSD borders for unconstraining X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=a7024dd22481baaa8945a0700d1a3e603c864c4f;p=proto%2Flabwc.git src/xdg-popup.c: take into account CSD borders for unconstraining wlr_xdg_popup_unconstrain_from_box() takes a constraint box relative to toplevel surface, not window. --- diff --git a/src/xdg-popup.c b/src/xdg-popup.c index a4b2295b..dd17b990 100644 --- a/src/xdg-popup.c +++ b/src/xdg-popup.c @@ -28,19 +28,33 @@ popup_unconstrain(struct xdg_popup *popup) struct view *view = popup->parent_view; struct server *server = view->server; + /* Get position of parent toplevel/popup */ 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); + /* Get usable area to constrain by */ struct wlr_box *popup_box = &popup->wlr_popup->scheduled.geometry; struct output *output = output_nearest_to(server, parent_lx + popup_box->x, parent_ly + popup_box->y); struct wlr_box usable = output_usable_area_in_layout_coords(output); + /* Get offset of toplevel window from its surface */ + int toplevel_dx = 0; + int toplevel_dy = 0; + struct wlr_xdg_surface *toplevel_surface = xdg_surface_from_view(view); + if (toplevel_surface) { + toplevel_dx = toplevel_surface->current.geometry.x; + toplevel_dy = toplevel_surface->current.geometry.y; + } else { + wlr_log(WLR_ERROR, "toplevel is not valid XDG surface"); + } + + /* Geometry of usable area relative to toplevel surface */ struct wlr_box output_toplevel_box = { - .x = usable.x - view->current.x, - .y = usable.y - view->current.y, + .x = usable.x - (view->current.x - toplevel_dx), + .y = usable.y - (view->current.y - toplevel_dy), .width = usable.width, .height = usable.height, };