X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fevents.c;h=f6442956645825d6ac8e1e1cdcd970e01fe64397;hp=9966905b6286a496ee0a97868b2990105d6dc98a;hb=aaa6bf53eceb4c7801966a017dcc8a57c2fdface;hpb=c38790fcee093efb156366bb4a02dbde55085ca4 diff --git a/src/events.c b/src/events.c index 9966905b..f6442956 100644 --- a/src/events.c +++ b/src/events.c @@ -47,6 +47,24 @@ static void HandleNoEvent(void); static void HandleEventActions(void); +// event filter to set mouse x/y position (for pointer class global animations) +// (this is especially required to ensure smooth global animation mouse pointer +// movement when the screen is updated without handling events; this can happen +// when drawing door/envelope request animations, for example) + +int FilterMouseMotionEvents(void *userdata, Event *event) +{ + if (event->type == EVENT_MOTIONNOTIFY) + { + int mouse_x = ((MotionEvent *)event)->x; + int mouse_y = ((MotionEvent *)event)->y; + + UpdateRawMousePosition(mouse_x, mouse_y); + } + + return 1; +} + // event filter especially needed for SDL event filtering due to // delay problems with lots of mouse motion events when mouse button // not pressed (X11 can handle this with 'PointerMotionHintMask') @@ -74,9 +92,6 @@ static int FilterEvents(const Event *event) { ((MotionEvent *)event)->x -= video.screen_xoffset; ((MotionEvent *)event)->y -= video.screen_yoffset; - - gfx.mouse_x = ((MotionEvent *)event)->x; - gfx.mouse_y = ((MotionEvent *)event)->y; } // non-motion events are directly passed to event handler functions @@ -571,6 +586,8 @@ void HandleWindowEvent(WindowEvent *event) if (game_status == GAME_MODE_SETUP) RedrawSetupScreenAfterFullscreenToggle(); + UpdateMousePosition(); + SetWindowTitle(); } } @@ -1607,6 +1624,15 @@ void HandleUserEvent(UserEvent *event) { switch (event->code) { + case USEREVENT_ANIM_DELAY_ACTION: + case USEREVENT_ANIM_EVENT_ACTION: + // execute action functions until matching action was found + if (DoKeysymAction(event->value1) || + DoGadgetAction(event->value1) || + DoScreenAction(event->value1)) + return; + break; + default: break; } @@ -2111,6 +2137,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; @@ -2142,12 +2170,17 @@ void HandleKey(Key key, int key_status) if (game_status == GAME_MODE_SETUP) RedrawSetupScreenAfterFullscreenToggle(); + UpdateMousePosition(); + return; } - if (HandleGlobalAnimClicks(-1, -1, (key == KSYM_space || - key == KSYM_Return || - key == KSYM_Escape), TRUE)) + // some key events are handled like clicks for global animations + boolean click = (key == KSYM_space || + key == KSYM_Return || + key == KSYM_Escape); + + if (click && HandleGlobalAnimClicks(-1, -1, MB_LEFTBUTTON, TRUE)) { // do not handle this key event anymore if (key != KSYM_Escape) // always allow ESC key to be handled