split function to toggle fullscreen and change window scaling
authorHolger Schemel <info@artsoft.org>
Sat, 5 Sep 2020 23:23:32 +0000 (01:23 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 5 Sep 2020 23:23:32 +0000 (01:23 +0200)
src/events.c
src/screens.c
src/tools.c
src/tools.h

index 4140ab5f0ef38e0694d4b42f53c5ea1708dd58d5..0643e1642c3a77ff7c33ded51282c0c9b1167af1 100644 (file)
@@ -2177,7 +2177,7 @@ void HandleKey(Key key, int key_status)
   {
     setup.fullscreen = !setup.fullscreen;
 
-    ToggleFullscreenOrChangeWindowScalingIfNeeded();
+    ToggleFullscreenIfNeeded();
 
     if (game_status == GAME_MODE_SETUP)
       RedrawSetupScreenAfterFullscreenToggle();
@@ -2210,7 +2210,7 @@ void HandleKey(Key key, int key_status)
     else if (setup.window_scaling_percent > MAX_WINDOW_SCALING_PERCENT)
       setup.window_scaling_percent = MAX_WINDOW_SCALING_PERCENT;
 
-    ToggleFullscreenOrChangeWindowScalingIfNeeded();
+    ChangeWindowScalingIfNeeded();
 
     if (game_status == GAME_MODE_SETUP)
       RedrawSetupScreenAfterFullscreenToggle();
index a5d9d45fd62053da4df73f4d68912e6add29bdff..1808e9bcd4a6dbfe71083b9117e52ec82762ab3f 100644 (file)
@@ -1580,10 +1580,6 @@ void DrawMainMenu(void)
     return;
   }
 
-  // needed if last screen was the setup screen and fullscreen state changed
-  // (moved to "execSetupGraphics()" to change fullscreen state directly)
-  // ToggleFullscreenOrChangeWindowScalingIfNeeded();
-
   // leveldir_current may be invalid (level group, parent link)
   if (!validLevelSeries(leveldir_current))
     leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid);
@@ -5327,7 +5323,7 @@ static void execSetupGraphics(void)
     ModifyGameSpeedIfNeeded();
 
   // window scaling may have changed at this point
-  ToggleFullscreenOrChangeWindowScalingIfNeeded();
+  ChangeWindowScalingIfNeeded();
 
   // window scaling quality may have changed at this point
   if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
@@ -6861,7 +6857,7 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
 
   // fullscreen state may have changed at this point
   if (si->value == &setup.fullscreen)
-    ToggleFullscreenOrChangeWindowScalingIfNeeded();
+    ToggleFullscreenIfNeeded();
 
   // network mode may have changed at this point
   if (si->value == &setup.network_mode)
index 4affe1366d5aa2f75718bcf80a83423b3585b7df..d44e2cb48c6f83174133da7f2bc99cf40b704434 100644 (file)
@@ -9243,7 +9243,7 @@ void PlaySoundSelecting(void)
 #endif
 }
 
-void ToggleFullscreenOrChangeWindowScalingIfNeeded(void)
+void ToggleFullscreenIfNeeded(void)
 {
   if (setup.fullscreen != video.fullscreen_enabled &&
       video.fullscreen_available)
@@ -9253,8 +9253,12 @@ void ToggleFullscreenOrChangeWindowScalingIfNeeded(void)
     // 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)
+}
+
+void ChangeWindowScalingIfNeeded(void)
+{
+  if (setup.window_scaling_percent != video.window_scaling_percent &&
+      !video.fullscreen_enabled)
   {
     SDLSetWindowScaling(setup.window_scaling_percent);
 
index 2743d41d460281f54ea71b86878983f10a2a1561..a58888bec0fd47176b950854225a56bcb433b868 100644 (file)
@@ -283,7 +283,8 @@ void ResetFontStatus(void);
 
 void SetLevelSetInfo(char *, int);
 
-void ToggleFullscreenOrChangeWindowScalingIfNeeded(void);
+void ToggleFullscreenIfNeeded(void);
+void ChangeWindowScalingIfNeeded(void);
 void ChangeVsyncModeIfNeeded(void);
 void ChangeViewportPropertiesIfNeeded(void);