diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-12-12 07:48:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 07:48:21 -0500 |
commit | ef9506b0bc009a19ee871333bd40f1ba0c0a2aa9 (patch) | |
tree | e3bf2347f3b5419267e10f7d29eb4808d44593ee | |
parent | 6161a153c841953468960d4ebe65f6472ab11310 (diff) | |
parent | 07865104e1ca1f8e3263bba0ac4c99aa953e4e28 (diff) |
Merge pull request #1433 from ammen99/fix-layer-shell-unconstrain
xdg-popup: fix wlr_xdg_popup_get_toplevel_coords()
-rw-r--r-- | types/xdg_shell/wlr_xdg_popup.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c index 874329f9..02dbec73 100644 --- a/types/xdg_shell/wlr_xdg_popup.c +++ b/types/xdg_shell/wlr_xdg_popup.c @@ -325,17 +325,25 @@ void wlr_xdg_popup_get_anchor_point(struct wlr_xdg_popup *popup, void wlr_xdg_popup_get_toplevel_coords(struct wlr_xdg_popup *popup, int popup_sx, int popup_sy, int *toplevel_sx, int *toplevel_sy) { - struct wlr_xdg_surface *parent = - wlr_xdg_surface_from_wlr_surface(popup->parent); - while (parent != NULL && parent->role == WLR_XDG_SURFACE_ROLE_POPUP) { - popup_sx += parent->popup->geometry.x; - popup_sy += parent->popup->geometry.y; - parent = wlr_xdg_surface_from_wlr_surface(parent->popup->parent); + struct wlr_surface *parent = popup->parent; + while (wlr_surface_is_xdg_surface(parent)) { + struct wlr_xdg_surface *xdg_surface = + wlr_xdg_surface_from_wlr_surface(parent); + + if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) { + popup_sx += xdg_surface->popup->geometry.x; + popup_sy += xdg_surface->popup->geometry.y; + parent = xdg_surface->popup->parent; + } else { + popup_sx += xdg_surface->geometry.x; + popup_sy += xdg_surface->geometry.y; + break; + } } assert(parent); - *toplevel_sx = popup_sx + parent->geometry.x; - *toplevel_sy = popup_sy + parent->geometry.y; + *toplevel_sx = popup_sx; + *toplevel_sy = popup_sy; } static void xdg_popup_box_constraints(struct wlr_xdg_popup *popup, |