Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid double-firing of keyPressed events #2757

Merged
merged 1 commit into from
Apr 23, 2018

Commits on Nov 24, 2017

  1. Avoid double-firing of keyPressed events

    The `IngameKeyListener` seems to double fire `keyPressed` events.
    The net effect is that it is impossible to use hotkeys such as 'B'
    because the dropdown construction menu just flashes for an instant
    and then closes back down immediately.
    
    I suspect this is a deeper issue inside `fifengine`, but I am not
    familiar with that so here I offer a quick fix to avoid the problem.
    
    Simply put, the `IngameKeyListener` keeps track of the last event
    and, if the current one is identical (same key, same press/release
    status), it directly discards it without further processing.
    
    Furthermore, I also cache an instance of `KeyConfig` inside
    `IngameKeyListener` instead of instantiating one every time
    `keyPressed` or `keyReleased` are called. This just popped to my eyes
    as an obvious optimization to implement, but feel free to discard if
    it gives raise to some problems.
    FedericoStra committed Nov 24, 2017
    Configuration menu
    Copy the full SHA
    549a3ae View commit details
    Browse the repository at this point in the history