From: Holger Schemel Date: Fri, 15 Apr 2016 18:08:24 +0000 (+0200) Subject: fixed repeatedly toggling fullscreen mode by repeated 'key press' events X-Git-Tag: 4.0.0.0-rc2~25 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=1e99bc0a89b3d120e8fbc193e307af741ad4efbc;p=rocksndiamonds.git fixed repeatedly toggling fullscreen mode by repeated 'key press' events --- diff --git a/src/events.c b/src/events.c index d9104aa1..e371b634 100644 --- a/src/events.c +++ b/src/events.c @@ -1159,6 +1159,7 @@ static void HandleKeysSpecial(Key key) void HandleKey(Key key, int key_status) { boolean anyTextGadgetActiveOrJustFinished = anyTextGadgetActive(); + static boolean ignore_repeated_key = FALSE; static struct SetupKeyboardInfo ski; static struct SetupShortcutInfo ssi; static struct @@ -1326,12 +1327,18 @@ void HandleKey(Key key, int key_status) key_joystick_mapping = 0; if (key_status == KEY_RELEASED) + { + // reset flag to ignore repeated "key pressed" events after key release + ignore_repeated_key = FALSE; + return; + } if ((key == KSYM_F11 || ((key == KSYM_Return || key == KSYM_KP_Enter) && (GetKeyModState() & KMOD_Alt))) && - video.fullscreen_available) + video.fullscreen_available && + !ignore_repeated_key) { setup.fullscreen = !setup.fullscreen; @@ -1340,6 +1347,9 @@ void HandleKey(Key key, int key_status) if (game_status == GAME_MODE_SETUP) RedrawSetupScreenAfterFullscreenToggle(); + // set flag to ignore repeated "key pressed" events + ignore_repeated_key = TRUE; + return; }