1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 11:37:44 +00:00

Constrain the mouse cursor to keep it inside the screen rect.

This commit is contained in:
Andreas Kling 2019-01-12 01:00:24 +01:00
parent b95aa18315
commit 9bc7b128b2
3 changed files with 23 additions and 6 deletions

View file

@ -40,6 +40,7 @@ void AbstractScreen::did_receive_mouse_data(int dx, int dy, bool left_button, bo
{
auto prev_location = m_cursor_location;
m_cursor_location.moveBy(dx, dy);
m_cursor_location.constrain(rect());
if (m_cursor_location.x() >= width())
m_cursor_location.setX(width() - 1);
if (m_cursor_location.y() >= height())