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()); }