From 739d8700916133e8eb30a48cbca71043d57081b2 Mon Sep 17 00:00:00 2001 From: MacDue Date: Sun, 8 May 2022 15:55:00 +0100 Subject: [PATCH] Fire: Ignore mouse events outside the window (to the left) This fixes a small issue where if you drag the cursor outside the window on the left-hand side, the fire demo will still respond to the mouse events, but wrapped around to the right of the window. --- Userland/Demos/Fire/Fire.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Demos/Fire/Fire.cpp b/Userland/Demos/Fire/Fire.cpp index ece640d618c676..1592cdba808ed4 100644 --- a/Userland/Demos/Fire/Fire.cpp +++ b/Userland/Demos/Fire/Fire.cpp @@ -174,9 +174,9 @@ void Fire::mousedown_event(GUI::MouseEvent& event) void Fire::mousemove_event(GUI::MouseEvent& event) { if (dragging) { - if (event.y() >= 2 && event.y() < 398 && event.x() <= 638) { - int ypos = event.y() / 2; - int xpos = event.x() / 2; + int ypos = event.y() / 2; + int xpos = event.x() / 2; + if (bitmap->rect().shrunken(1, 1, 0, 0).contains(xpos, ypos)) { bitmap->scanline_u8(ypos - 1)[xpos] = FIRE_MAX + 5; bitmap->scanline_u8(ypos - 1)[xpos + 1] = FIRE_MAX + 5; bitmap->scanline_u8(ypos)[xpos] = FIRE_MAX + 5;