X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fevents.c;h=ffe1d4f0b09b306762c9560bab9a8ccf66a264c7;hp=c88a27b8dfb80324151e36d6112e1226cb9e90ef;hb=e57078603232563176d90bb543ce2bc3a15b889e;hpb=514321a85f7dda02848a3ce78667329f9c891156 diff --git a/src/events.c b/src/events.c index c88a27b8..ffe1d4f0 100644 --- a/src/events.c +++ b/src/events.c @@ -40,24 +40,21 @@ static unsigned long playfield_cursor_delay = 0; int FilterMouseMotionEvents(const Event *event) { + MotionEvent *motion; + /* non-motion events are directly passed to event handler functions */ if (event->type != EVENT_MOTIONNOTIFY) return 1; - if (game_status == PLAYING) - { - MotionEvent *motion = (MotionEvent *)event; - - cursor_inside_playfield = - (motion->x >= SX && motion->x < SX + SXSIZE && - motion->y >= SY && motion->y < SY + SYSIZE); + motion = (MotionEvent *)event; + cursor_inside_playfield = (motion->x >= SX && motion->x < SX + SXSIZE && + motion->y >= SY && motion->y < SY + SYSIZE); - if (playfield_cursor_set) - { - SetMouseCursor(CURSOR_DEFAULT); - DelayReached(&playfield_cursor_delay, 0); - playfield_cursor_set = FALSE; - } + if (game_status == PLAYING && playfield_cursor_set) + { + SetMouseCursor(CURSOR_DEFAULT); + playfield_cursor_set = FALSE; + DelayReached(&playfield_cursor_delay, 0); } /* skip mouse motion events without pressed button outside level editor */ @@ -119,11 +116,19 @@ void EventLoop(void) else { /* when playing, display a special mouse pointer inside the playfield */ - if (game_status == PLAYING && cursor_inside_playfield && - DelayReached(&playfield_cursor_delay, 1000)) + if (game_status == PLAYING) + { + if (!playfield_cursor_set && cursor_inside_playfield && + DelayReached(&playfield_cursor_delay, 1000)) + { + SetMouseCursor(CURSOR_PLAYFIELD); + playfield_cursor_set = TRUE; + } + } + else if (playfield_cursor_set) { - SetMouseCursor(CURSOR_PLAYFIELD); - playfield_cursor_set = TRUE; + SetMouseCursor(CURSOR_DEFAULT); + playfield_cursor_set = FALSE; } HandleNoEvent();