Skip to content

Commit

Permalink
Fire: Ignore mouse events outside the window (to the left)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MacDue authored and linusg committed May 8, 2022
1 parent 934ea4f commit 739d870
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Userland/Demos/Fire/Fire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 739d870

Please sign in to comment.