From 2d64147f027c3a512f37da9bd92010f2edb00d3f Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Sat, 13 May 2023 04:57:55 -0400 Subject: [PATCH] LibGfx: Reverse coordinate subtraction in Rect::constrained_to() Fixes translating in the wrong direction or not at all in the case of a constraint at (0,0). This doesn't appear to be used anywhere yet but is needed in the upcoming patch. --- Userland/Libraries/LibGfx/Rect.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/Rect.h b/Userland/Libraries/LibGfx/Rect.h index 9d54efa4d3..7210ec17e1 100644 --- a/Userland/Libraries/LibGfx/Rect.h +++ b/Userland/Libraries/LibGfx/Rect.h @@ -610,9 +610,9 @@ public: if (bottom() > constrain_rect.bottom()) move_y = constrain_rect.bottom() - bottom(); if (x() < constrain_rect.x()) - move_x = x() - constrain_rect.x(); + move_x = constrain_rect.x() - x(); if (y() < constrain_rect.y()) - move_y = y() - constrain_rect.y(); + move_y = constrain_rect.y() - y(); auto rect = *this; if (move_x != 0 || move_y != 0) rect.translate_by(move_x, move_y);