fixed repeatedly toggling fullscreen mode by repeated 'key press' events
authorHolger Schemel <info@artsoft.org>
Fri, 15 Apr 2016 18:08:24 +0000 (20:08 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 15 Apr 2016 18:08:24 +0000 (20:08 +0200)
src/events.c

index d9104aa1be04172a8d64bc8be39b3afd8c57fb46..e371b63455b1384f0762765c6269bdf1850b1650 100644 (file)
@@ -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;
   }