improved function to toggle fullscreen or change window scaling
authorHolger Schemel <info@artsoft.org>
Sat, 5 Sep 2020 19:38:50 +0000 (21:38 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 5 Sep 2020 19:38:50 +0000 (21:38 +0200)
src/tools.c

index 8ac74ac7178eb4d7f10247e9c6302ac594df460e..4affe1366d5aa2f75718bcf80a83423b3585b7df 100644 (file)
@@ -9245,32 +9245,21 @@ void PlaySoundSelecting(void)
 
 void ToggleFullscreenOrChangeWindowScalingIfNeeded(void)
 {
-  boolean change_fullscreen = (setup.fullscreen !=
-                              video.fullscreen_enabled);
-  boolean change_window_scaling_percent = (!video.fullscreen_enabled &&
-                                          setup.window_scaling_percent !=
-                                          video.window_scaling_percent);
-
-  if (change_window_scaling_percent && video.fullscreen_enabled)
-    return;
-
-  if (!change_window_scaling_percent && !video.fullscreen_available)
-    return;
-
-  if (change_window_scaling_percent)
-  {
-    SDLSetWindowScaling(setup.window_scaling_percent);
-
-    return;
-  }
-  else if (change_fullscreen)
+  if (setup.fullscreen != video.fullscreen_enabled &&
+      video.fullscreen_available)
   {
     SDLSetWindowFullscreen(setup.fullscreen);
 
     // set setup value according to successfully changed fullscreen mode
     setup.fullscreen = video.fullscreen_enabled;
+  }
+  else if (setup.window_scaling_percent != video.window_scaling_percent &&
+          !video.fullscreen_enabled)
+  {
+    SDLSetWindowScaling(setup.window_scaling_percent);
 
-    return;
+    // set setup value according to successfully changed window scaling
+    setup.window_scaling_percent = video.window_scaling_percent;
   }
 }