diff --git a/lime/system/System.hx b/lime/system/System.hx index a29d8db81..c6b0712ba 100644 --- a/lime/system/System.hx +++ b/lime/system/System.hx @@ -33,6 +33,7 @@ import sys.io.Process; class System { + public static var allowScreenTimeout (get, set):Bool; public static var applicationDirectory (get, null):String; public static var applicationStorageDirectory (get, null):String; public static var desktopDirectory (get, null):String; @@ -227,6 +228,28 @@ class System { + private static function get_allowScreenTimeout ():Bool { + + #if ((cpp || neko || nodejs) && !macro) + return lime_system_get_allow_screen_timeout (); + #else + return true; + #end + + } + + + private static function set_allowScreenTimeout (value:Bool):Bool { + + #if ((cpp || neko || nodejs) && !macro) + return lime_system_set_allow_screen_timeout (value); + #else + return true; + #end + + } + + private static function get_applicationDirectory ():String { #if ((cpp || neko || nodejs) && !macro) @@ -394,6 +417,8 @@ class System { #if ((cpp || neko || nodejs) && !macro) + @:cffi private static function lime_system_get_allow_screen_timeout ():Bool; + @:cffi private static function lime_system_set_allow_screen_timeout (value:Bool):Bool; @:cffi private static function lime_system_get_directory (type:Int, company:String, title:String):Dynamic; @:cffi private static function lime_system_get_display (index:Int):Dynamic; @:cffi private static function lime_system_get_num_displays ():Int; diff --git a/project/include/system/System.h b/project/include/system/System.h index 5e9516cce..971e4109a 100644 --- a/project/include/system/System.h +++ b/project/include/system/System.h @@ -25,10 +25,12 @@ namespace lime { public: + static bool GetAllowScreenTimeout (); static const char* GetDirectory (SystemDirectory type, const char* company, const char* title); static value GetDisplay (int id); static int GetNumDisplays (); static double GetTimer (); + static bool SetAllowScreenTimeout (bool allow); }; diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index df4d2362f..6b496bee8 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -1029,6 +1029,13 @@ namespace lime { } + bool lime_system_get_allow_screen_timeout () { + + return System::GetAllowScreenTimeout (); + + } + + value lime_system_get_directory (int type, HxString company, HxString title) { const char* path = System::GetDirectory ((SystemDirectory)type, company.__s, title.__s); @@ -1058,6 +1065,13 @@ namespace lime { } + bool lime_system_set_allow_screen_timeout (bool allow) { + + return System::SetAllowScreenTimeout (allow); + + } + + void lime_text_event_manager_register (value callback, value eventObject) { TextEvent::callback = new AutoGCRoot (callback); @@ -1359,10 +1373,12 @@ namespace lime { DEFINE_PRIME1v (lime_renderer_unlock); DEFINE_PRIME2v (lime_render_event_manager_register); DEFINE_PRIME2v (lime_sensor_event_manager_register); + DEFINE_PRIME0 (lime_system_get_allow_screen_timeout); DEFINE_PRIME3 (lime_system_get_directory); DEFINE_PRIME1 (lime_system_get_display); DEFINE_PRIME0 (lime_system_get_num_displays); DEFINE_PRIME0 (lime_system_get_timer); + DEFINE_PRIME1 (lime_system_set_allow_screen_timeout); DEFINE_PRIME2v (lime_text_event_manager_register); DEFINE_PRIME3 (lime_text_layout_create); DEFINE_PRIME5 (lime_text_layout_position); diff --git a/project/src/backend/sdl/SDLSystem.cpp b/project/src/backend/sdl/SDLSystem.cpp index ffbedafd1..d49732c57 100644 --- a/project/src/backend/sdl/SDLSystem.cpp +++ b/project/src/backend/sdl/SDLSystem.cpp @@ -80,6 +80,13 @@ namespace lime { } + bool System::GetAllowScreenTimeout () { + + return SDL_IsScreenSaverEnabled (); + + } + + const char* System::GetDirectory (SystemDirectory type, const char* company, const char* title) { switch (type) { @@ -312,6 +319,23 @@ namespace lime { } + bool System::SetAllowScreenTimeout (bool allow) { + + if (allow) { + + SDL_EnableScreenSaver (); + + } else { + + SDL_DisableScreenSaver (); + + } + + return allow; + + } + + FILE* FILE_HANDLE::getFile () { #ifndef HX_WINDOWS