iOS: Added support for SDL_DisableScreenSaver and SDL_EnableScreenSaver.
authorAlex Szpakowski <slime73@gmail.com>
Sat, 16 May 2015 16:55:56 -0300
changeset 96038e570fd79352
parent 9602 3c3800abc52f
child 9604 b8d8f9674717
iOS: Added support for SDL_DisableScreenSaver and SDL_EnableScreenSaver.
include/SDL_hints.h
src/video/uikit/SDL_uikitvideo.h
src/video/uikit/SDL_uikitvideo.m
     1.1 --- a/include/SDL_hints.h	Sat May 16 21:15:59 2015 +0200
     1.2 +++ b/include/SDL_hints.h	Sat May 16 16:55:56 2015 -0300
     1.3 @@ -243,6 +243,9 @@
     1.4   *  this is problematic. This functionality can be disabled by setting this
     1.5   *  hint.
     1.6   *
     1.7 + *  As of SDL 2.0.4, SDL_EnableScreenSaver and SDL_DisableScreenSaver accomplish
     1.8 + *  the same thing on iOS. They should be preferred over this hint.
     1.9 + *
    1.10   *  This variable can be set to the following values:
    1.11   *    "0"       - Enable idle timer
    1.12   *    "1"       - Disable idle timer
     2.1 --- a/src/video/uikit/SDL_uikitvideo.h	Sat May 16 21:15:59 2015 +0200
     2.2 +++ b/src/video/uikit/SDL_uikitvideo.h	Sat May 16 16:55:56 2015 -0300
     2.3 @@ -25,6 +25,8 @@
     2.4  
     2.5  #include "../SDL_sysvideo.h"
     2.6  
     2.7 +void UIKit_SuspendScreenSaver(_THIS);
     2.8 +
     2.9  BOOL UIKit_IsSystemVersionAtLeast(double version);
    2.10  CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen);
    2.11  
     3.1 --- a/src/video/uikit/SDL_uikitvideo.m	Sat May 16 21:15:59 2015 +0200
     3.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Sat May 16 16:55:56 2015 -0300
     3.3 @@ -26,6 +26,7 @@
     3.4  
     3.5  #include "SDL_video.h"
     3.6  #include "SDL_mouse.h"
     3.7 +#include "SDL_hints.h"
     3.8  #include "../SDL_sysvideo.h"
     3.9  #include "../SDL_pixels_c.h"
    3.10  #include "../../events/SDL_events_c.h"
    3.11 @@ -74,6 +75,7 @@
    3.12      device->GetDisplayModes = UIKit_GetDisplayModes;
    3.13      device->SetDisplayMode = UIKit_SetDisplayMode;
    3.14      device->PumpEvents = UIKit_PumpEvents;
    3.15 +    device->SuspendScreenSaver = UIKit_SuspendScreenSaver;
    3.16      device->CreateWindow = UIKit_CreateWindow;
    3.17      device->SetWindowTitle = UIKit_SetWindowTitle;
    3.18      device->ShowWindow = UIKit_ShowWindow;
    3.19 @@ -130,6 +132,21 @@
    3.20      UIKit_QuitModes(_this);
    3.21  }
    3.22  
    3.23 +void
    3.24 +UIKit_SuspendScreenSaver(_THIS)
    3.25 +{
    3.26 +    @autoreleasepool {
    3.27 +        /* Ignore ScreenSaver API calls if the idle timer hint has been set. */
    3.28 +        /* FIXME: The idle timer hint should be deprecated for SDL 2.1. */
    3.29 +        if (SDL_GetHint(SDL_HINT_IDLE_TIMER_DISABLED) == NULL) {
    3.30 +            UIApplication *app = [UIApplication sharedApplication];
    3.31 +
    3.32 +            /* Prevent the display from dimming and going to sleep. */
    3.33 +            app.idleTimerDisabled = (_this->suspend_screensaver != SDL_FALSE);
    3.34 +        }
    3.35 +    }
    3.36 +}
    3.37 +
    3.38  BOOL
    3.39  UIKit_IsSystemVersionAtLeast(double version)
    3.40  {