1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:37:45 +00:00

LibGfx: Fix error & crash in Rect::closest_to

Assertion fails if the point is outside of the rect. This was introduced
in introduced in #18970 and causes serenity to crash when changing to 2x
resolution for a monitor, if the cursor after resizing is outside of
the new screen.

Added test to reproduce.
This commit is contained in:
Sebastian Zaha 2023-06-28 23:42:56 +02:00 committed by Jelle Raaijmakers
parent 0cb9c9e81e
commit d52a2ff10e
2 changed files with 13 additions and 2 deletions

View file

@ -656,8 +656,8 @@ public:
}
};
check_distance({ top_left(), top_right() });
check_distance({ bottom_left(), bottom_right() });
check_distance({ top_left(), top_right().moved_left(1) });
check_distance({ bottom_left().moved_up(1), bottom_right().translated(-1) });
if (height() > 2) {
check_distance({ { x(), y() + 1 }, { x(), bottom() - 2 } });
check_distance({ { right() - 1, y() + 1 }, { right() - 1, bottom() - 2 } });