X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=1e39b67bc57a7489beb9c78376d3a11486e65564;hb=8b77194545721f4b8e3f80b59da8423ab2d90dae;hp=bd82a609734afb1c06ebf95f52862a82594ab54c;hpb=8e4eb47925648cd84d134dfe05ca7fb30727dc24;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index bd82a609..1e39b67b 100644 --- a/src/events.c +++ b/src/events.c @@ -40,6 +40,7 @@ static unsigned int special_cursor_delay = 0; static unsigned int special_cursor_delay_value = 1000; static boolean virtual_button_pressed = FALSE; +static boolean stop_processing_events = FALSE; // forward declarations for internal use @@ -54,20 +55,13 @@ static void HandleEventActions(void); int FilterMouseMotionEvents(void *userdata, Event *event) { - if (event->type != EVENT_MOTIONNOTIFY) - return 1; - - int mouse_x = ((MotionEvent *)event)->x; - int mouse_y = ((MotionEvent *)event)->y; - - // mouse events do not contain logical screen size corrections at this stage - SDLCorrectMouseEventXY(&mouse_x, &mouse_y); - - mouse_x -= video.screen_xoffset; - mouse_y -= video.screen_yoffset; + if (event->type == EVENT_MOTIONNOTIFY) + { + int mouse_x = ((MotionEvent *)event)->x; + int mouse_y = ((MotionEvent *)event)->y; - gfx.mouse_x = mouse_x; - gfx.mouse_y = mouse_y; + UpdateRawMousePosition(mouse_x, mouse_y); + } return 1; } @@ -189,6 +183,11 @@ boolean NextValidEvent(Event *event) return FALSE; } +void StopProcessingEvents(void) +{ + stop_processing_events = TRUE; +} + static void HandleEvents(void) { Event event; @@ -197,6 +196,8 @@ static void HandleEvents(void) ResetDelayCounter(&event_frame_delay); + stop_processing_events = FALSE; + while (NextValidEvent(&event)) { switch (event.type) @@ -252,6 +253,10 @@ static void HandleEvents(void) // do not handle events for longer than standard frame delay period if (DelayReached(&event_frame_delay, event_frame_delay_value)) break; + + // do not handle any further events if triggered by a special flag + if (stop_processing_events) + break; } } @@ -593,6 +598,8 @@ void HandleWindowEvent(WindowEvent *event) if (game_status == GAME_MODE_SETUP) RedrawSetupScreenAfterFullscreenToggle(); + UpdateMousePosition(); + SetWindowTitle(); } } @@ -2142,6 +2149,8 @@ void HandleKey(Key key, int key_status) if (game_status == GAME_MODE_SETUP) RedrawSetupScreenAfterFullscreenToggle(); + UpdateMousePosition(); + // set flag to ignore repeated "key pressed" events ignore_repeated_key = TRUE; @@ -2173,6 +2182,8 @@ void HandleKey(Key key, int key_status) if (game_status == GAME_MODE_SETUP) RedrawSetupScreenAfterFullscreenToggle(); + UpdateMousePosition(); + return; }