From 8c62013ed1d7a7c9ef11966e398ad0f8647d7f2e Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 19 Nov 2021 20:39:43 +0100 Subject: [PATCH] fix eating to the left --- src/windowManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/windowManager.cpp b/src/windowManager.cpp index b5bab65..0568292 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -286,14 +286,14 @@ bool canEatWindow(CWindow* a, CWindow* toEat) { } void eatWindow(CWindow* a, CWindow* toEat) { - - // Pos is min of both. - a->setPosition(Vector2D(std::min(a->getPosition().x, toEat->getPosition().x), std::min(a->getPosition().y, toEat->getPosition().y))); - + // Size is pos + size max - pos const auto OPPCORNERA = a->getPosition() + a->getSize(); const auto OPPCORNERB = toEat->getPosition() + toEat->getSize(); + // Pos is min of both. + a->setPosition(Vector2D(std::min(a->getPosition().x, toEat->getPosition().x), std::min(a->getPosition().y, toEat->getPosition().y))); + a->setSize(Vector2D(std::max(OPPCORNERA.x, OPPCORNERB.x), std::max(OPPCORNERA.y, OPPCORNERB.y)) - a->getPosition()); }