fix eating to the left

This commit is contained in:
vaxerski 2021-11-19 20:39:43 +01:00
parent 13745c7636
commit 8c62013ed1

View file

@ -286,14 +286,14 @@ bool canEatWindow(CWindow* a, CWindow* toEat) {
} }
void eatWindow(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 // Size is pos + size max - pos
const auto OPPCORNERA = a->getPosition() + a->getSize(); const auto OPPCORNERA = a->getPosition() + a->getSize();
const auto OPPCORNERB = toEat->getPosition() + toEat->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()); a->setSize(Vector2D(std::max(OPPCORNERA.x, OPPCORNERB.x), std::max(OPPCORNERA.y, OPPCORNERB.y)) - a->getPosition());
} }