From 80a9397459cdbb15b7b0e403aec002ff68db5be9 Mon Sep 17 00:00:00 2001
From: Sasha Szpakowski <[EMAIL REDACTED]>
Date: Sat, 26 Nov 2022 23:03:06 -0400
Subject: [PATCH] Remove SDL_HINT_IDLE_TIMER_DISABLED.
SDL_DisableScreenSaver can be used instead. Fixes #6660.
---
docs/README-migration.md | 1 +
include/SDL3/SDL_hints.h | 17 -----------------
src/video/uikit/SDL_uikitappdelegate.m | 11 -----------
src/video/uikit/SDL_uikitvideo.m | 10 +++-------
test/testautomation_hints.c | 2 --
5 files changed, 4 insertions(+), 37 deletions(-)
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 3432b5475797..7fd9d930735d 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -169,6 +169,7 @@ Programs which have access to shaders can implement more robust versions of thos
## SDL_hints.h
The following hints have been removed:
+* SDL_HINT_IDLE_TIMER_DISABLED (use SDL_DisableScreenSaver instead)
* SDL_HINT_VIDEO_X11_FORCE_EGL (use SDL_HINT_VIDEO_FORCE_EGL instead)
* SDL_HINT_VIDEO_X11_XINERAMA (Xinerama no longer supported by the X11 backend)
* SDL_HINT_VIDEO_X11_XVIDMODE (Xvidmode no longer supported by the X11 backend)
diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h
index 7662597af124..39351bbd053a 100644
--- a/include/SDL3/SDL_hints.h
+++ b/include/SDL3/SDL_hints.h
@@ -556,23 +556,6 @@ extern "C" {
*/
#define SDL_HINT_HIDAPI_IGNORE_DEVICES "SDL_HIDAPI_IGNORE_DEVICES"
-/**
- * \brief A variable controlling whether the idle timer is disabled on iOS.
- *
- * When an iOS app does not receive touches for some time, the screen is
- * dimmed automatically. For games where the accelerometer is the only input
- * this is problematic. This functionality can be disabled by setting this
- * hint.
- *
- * As of SDL 2.0.4, SDL_EnableScreenSaver() and SDL_DisableScreenSaver()
- * accomplish the same thing on iOS. They should be preferred over this hint.
- *
- * This variable can be set to the following values:
- * "0" - Enable idle timer
- * "1" - Disable idle timer
- */
-#define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED"
-
/**
* \brief A variable to control whether certain IMEs should handle text editing internally instead of sending SDL_TEXTEDITING events.
*
diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m
index f41ac6954cf8..9c4e8b534286 100644
--- a/src/video/uikit/SDL_uikitappdelegate.m
+++ b/src/video/uikit/SDL_uikitappdelegate.m
@@ -75,13 +75,6 @@ int SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction)
return exit_status;
}
-static void SDLCALL
-SDL_IdleTimerDisabledChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
-{
- BOOL disable = (hint && *hint != '0');
- [UIApplication sharedApplication].idleTimerDisabled = disable;
-}
-
#if !TARGET_OS_TV
/* Load a launch image using the old UILaunchImageFile-era naming rules. */
static UIImage *
@@ -457,10 +450,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
/* Set working directory to resource path */
[[NSFileManager defaultManager] changeCurrentDirectoryPath:[bundle resourcePath]];
- /* register a callback for the idletimer hint */
- SDL_AddHintCallback(SDL_HINT_IDLE_TIMER_DISABLED,
- SDL_IdleTimerDisabledChanged, NULL);
-
SDL_SetMainReady();
[self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0];
diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m
index 0df6bcd8d23f..0ff7efe94d77 100644
--- a/src/video/uikit/SDL_uikitvideo.m
+++ b/src/video/uikit/SDL_uikitvideo.m
@@ -177,14 +177,10 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device)
UIKit_SuspendScreenSaver(_THIS)
{
@autoreleasepool {
- /* Ignore ScreenSaver API calls if the idle timer hint has been set. */
- /* FIXME: The idle timer hint should be deprecated for SDL 2.1. */
- if (!SDL_GetHintBoolean(SDL_HINT_IDLE_TIMER_DISABLED, SDL_FALSE)) {
- UIApplication *app = [UIApplication sharedApplication];
+ UIApplication *app = [UIApplication sharedApplication];
- /* Prevent the display from dimming and going to sleep. */
- app.idleTimerDisabled = (_this->suspend_screensaver != SDL_FALSE);
- }
+ /* Prevent the display from dimming and going to sleep. */
+ app.idleTimerDisabled = (_this->suspend_screensaver != SDL_FALSE);
}
}
diff --git a/test/testautomation_hints.c b/test/testautomation_hints.c
index 1b7e8de2980c..a3dee44af282 100644
--- a/test/testautomation_hints.c
+++ b/test/testautomation_hints.c
@@ -12,7 +12,6 @@ const char* _HintsEnum[] =
SDL_HINT_FRAMEBUFFER_ACCELERATION,
SDL_HINT_GAMECONTROLLERCONFIG,
SDL_HINT_GRAB_KEYBOARD,
- SDL_HINT_IDLE_TIMER_DISABLED,
SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK,
SDL_HINT_MOUSE_RELATIVE_MODE_WARP,
@@ -38,7 +37,6 @@ const char* _HintsVerbose[] =
"SDL_FRAMEBUFFER_ACCELERATION",
"SDL_GAMECONTROLLERCONFIG",
"SDL_GRAB_KEYBOARD",
- "SDL_IDLE_TIMER_DISABLED",
"SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS",
"SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK",
"SDL_MOUSE_RELATIVE_MODE_WARP",