From 65062710710fe6b7e4edc9665d989e7c570f3e87 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Mon, 6 May 2024 23:53:00 +0200 Subject: [PATCH] xdg-popup: slide as little as possible when re-positioning popups --- src/ifs/wl_surface/xdg_surface/xdg_popup.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs index f7999bb7..a1880cc7 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs @@ -142,17 +142,21 @@ impl XdgPopup { } let (mut dx, mut dy) = (0, 0); if positioner.ca.contains(CA_SLIDE_X) && overflow.x_overflow() { - dx = if overflow.left > 0 || overflow.left + overflow.right > 0 { + dx = if overflow.left + overflow.right > 0 { parent_abs.x1() - abs_pos.x1() + } else if overflow.left > 0 { + overflow.left } else { - parent_abs.x2() - abs_pos.x2() + -overflow.right }; } if positioner.ca.contains(CA_SLIDE_Y) && overflow.y_overflow() { - dy = if overflow.top > 0 || overflow.top + overflow.bottom > 0 { + dy = if overflow.top + overflow.bottom > 0 { parent_abs.y1() - abs_pos.y1() + } else if overflow.top > 0 { + overflow.top } else { - parent_abs.y2() - abs_pos.y2() + -overflow.bottom }; } if dx != 0 || dy != 0 {