From 8b967fc573b2a4d53c59a4cace75434c4b6c94db Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 28 Mar 2018 19:00:49 -0400 Subject: [PATCH] bug: dont slide over too far --- types/wlr_xdg_shell_v6.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index aaacbf29e..85ced7bdd 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -1761,7 +1761,7 @@ static bool wlr_xdg_popup_v6_unconstrain_flip(struct wlr_xdg_popup_v6 *popup, static bool wlr_xdg_popup_v6_unconstrain_slide(struct wlr_xdg_popup_v6 *popup, struct wlr_box *toplevel_box) { - int offset_x, offset_y; + int offset_x = 0, offset_y = 0; wlr_xdg_popup_v6_box_constraints(popup, toplevel_box, &offset_x, &offset_y); if (!offset_x && !offset_y) { @@ -1784,6 +1784,17 @@ static bool wlr_xdg_popup_v6_unconstrain_slide(struct wlr_xdg_popup_v6 *popup, popup->geometry.y += offset_y; } + int toplevel_x = 0, toplevel_y = 0; + wlr_xdg_popup_v6_get_toplevel_coords(popup, popup->geometry.x, + popup->geometry.y, &toplevel_x, &toplevel_y); + + if (slide_x && toplevel_x < toplevel_box->x) { + popup->geometry.x += toplevel_box->x - toplevel_x; + } + if (slide_y && toplevel_y < toplevel_box->y) { + popup->geometry.y += toplevel_box->y - toplevel_y; + } + wlr_xdg_popup_v6_box_constraints(popup, toplevel_box, &offset_x, &offset_y); return !offset_x && !offset_y;