From: Holger Schemel Date: Thu, 21 Mar 2019 22:36:36 +0000 (+0100) Subject: fixed handling global animation key event actions multiple times X-Git-Tag: 4.1.3.0~24 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=da0b032a906bd0fdadf798802c04c9084bee074c fixed handling global animation key event actions multiple times When checking key events for triggering global animations, all keys that are not handled as "click" events for the "any" animation event were effectively treated like a "released button" event, which did not have an effect if no mouse button was pressed at the same time. However, when clicking on "clickable" global animations (those that have a "click" animation event defined) with key event actions (that will cause a simulated key press and release event), any key press event that is not recognized as a "click" event will again be treated like a "released button" event, causing the "button is pressed" state in "HandleGlobalAnimClicks()" to be changed to "not pressed anymore", so the still pressed mouse button will cause another "press event" in "HandleGlobalAnimClicks()" right away, which will result in multiple key events instead of one single key event. This may cause unexpected and unwanted behaviour when handling global animation events. This problem is fixed by only handling those key events for global animations that will be handled as "click" events. --- diff --git a/src/events.c b/src/events.c index 9966905b..11fd28f4 100644 --- a/src/events.c +++ b/src/events.c @@ -2145,9 +2145,12 @@ void HandleKey(Key key, int key_status) 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