bug: dont slide over too far

This commit is contained in:
Tony Crisci 2018-03-28 19:00:49 -04:00
parent bf5ae85683
commit 8b967fc573
1 changed files with 12 additions and 1 deletions

View File

@ -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, static bool wlr_xdg_popup_v6_unconstrain_slide(struct wlr_xdg_popup_v6 *popup,
struct wlr_box *toplevel_box) { 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); wlr_xdg_popup_v6_box_constraints(popup, toplevel_box, &offset_x, &offset_y);
if (!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; 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); wlr_xdg_popup_v6_box_constraints(popup, toplevel_box, &offset_x, &offset_y);
return !offset_x && !offset_y; return !offset_x && !offset_y;