From: Holger Schemel Date: Wed, 20 Mar 2019 18:18:54 +0000 (+0100) Subject: fixed handling global animation key actions when mouse button is pressed X-Git-Tag: 4.1.3.0~28 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c271d9388070fd4ae23f7b75abab9045bd81bb73;p=rocksndiamonds.git fixed handling global animation key actions when mouse button is pressed When handling key actions for global animations (like pressing "Enter" or "Escape") which are translated into global animation click events, they were ignored if a "real" mouse button is already held pressed at the same time. This can especially happen with animation event actions that simulate key press events when clicking on global animations, so the key actions were ignored if the mouse button was held down for too long. This change forces key actions of global animations to be handled even if a mouse button was pressed at the same time. --- diff --git a/src/anim.c b/src/anim.c index 2ebf520f..71f99588 100644 --- a/src/anim.c +++ b/src/anim.c @@ -1795,7 +1795,7 @@ static void ResetGlobalAnim_Clicked(void) InitGlobalAnim_Clicked(-1, -1, ANIM_CLICKED_RESET); } -boolean HandleGlobalAnimClicks(int mx, int my, int button) +boolean HandleGlobalAnimClicks(int mx, int my, int button, boolean force_click) { static boolean click_consumed = FALSE; static int last_button = 0; @@ -1803,6 +1803,9 @@ boolean HandleGlobalAnimClicks(int mx, int my, int button) boolean release_event; boolean click_consumed_current = click_consumed; + if (button != 0 && force_click) + last_button = 0; + // check if button state has changed since last invocation press_event = (button != 0 && last_button == 0); release_event = (button == 0 && last_button != 0); diff --git a/src/anim.h b/src/anim.h index 6b87a041..cbaeda2b 100644 --- a/src/anim.h +++ b/src/anim.h @@ -18,6 +18,6 @@ int getAnimationFrame(int, int, int, int, int); void InitGlobalAnimations(void); void DrawGlobalAnimations(int, int); -boolean HandleGlobalAnimClicks(int, int, int); +boolean HandleGlobalAnimClicks(int, int, int, boolean); #endif diff --git a/src/events.c b/src/events.c index 52595e25..9348533a 100644 --- a/src/events.c +++ b/src/events.c @@ -1745,7 +1745,7 @@ void HandleButton(int mx, int my, int button, int button_nr) !virtual_button_pressed)); #endif - if (HandleGlobalAnimClicks(mx, my, button)) + if (HandleGlobalAnimClicks(mx, my, button, FALSE)) { // do not handle this button event anymore return; // force mouse event not to be handled at all @@ -2249,7 +2249,7 @@ void HandleKey(Key key, int key_status) if (HandleGlobalAnimClicks(-1, -1, (key == KSYM_space || key == KSYM_Return || - key == KSYM_Escape))) + key == KSYM_Escape), TRUE)) { // do not handle this key event anymore if (key != KSYM_Escape) // always allow ESC key to be handled @@ -2560,7 +2560,7 @@ void HandleJoystick(void) int dy = (up ? -1 : down ? 1 : 0); boolean use_delay_value_first = (joytest != joytest_last); - if (HandleGlobalAnimClicks(-1, -1, newbutton)) + if (HandleGlobalAnimClicks(-1, -1, newbutton, FALSE)) { // do not handle this button event anymore return;