From ab4c23583a15b148893f16a5e81b0fba8a946ae5 Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 2 Aug 2024 03:44:29 +0200 Subject: [PATCH] Add keep_screen_on editor setting --- core/config/project_settings.cpp | 4 ---- doc/classes/EditorSettings.xml | 3 +++ doc/classes/ProjectSettings.xml | 3 --- editor/editor_node.cpp | 2 ++ editor/editor_settings.cpp | 1 + editor/project_manager.cpp | 1 + 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 37a2608c102..3c1f77a51f5 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1472,10 +1472,6 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF(PropertyInfo(Variant::INT, "display/window/size/window_height_override", PROPERTY_HINT_RANGE, "0,4320,1,or_greater"), 0); // 8K resolution GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true); -#ifdef TOOLS_ENABLED - GLOBAL_DEF("display/window/energy_saving/keep_screen_on.editor_hint", false); -#endif - GLOBAL_DEF("animation/warnings/check_invalid_track_paths", true); GLOBAL_DEF("animation/warnings/check_angle_interpolation_type_conflicting", true); diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index d63c71a351a..dcb842737e1 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -675,6 +675,9 @@ If [code]true[/code], (re)imports resources even if the editor window is unfocused or minimized. If [code]false[/code], resources are only (re)imported when the editor window is focused. This can be set to [code]true[/code] to speed up iteration by starting the import process earlier when saving files in the project folder. This also allows getting visual feedback on changes without having to click the editor window, which is useful with multi-monitor setups. The downside of setting this to [code]true[/code] is that it increases idle CPU usage and may steal CPU time from other applications when importing resources. + + If [code]true[/code], keeps the screen on (even in case of inactivity), so the screensaver does not take over. Works on desktop and mobile platforms. + If [code]true[/code], setting names in the editor are localized when possible. [b]Note:[/b] This setting affects most [EditorInspector]s in the editor UI, primarily Project Settings and Editor Settings. To control names displayed in the Inspector dock, use [member interface/inspector/default_property_name_style] instead. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 22c25dd5e57..5fa8bef62ab 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -814,9 +814,6 @@ If [code]true[/code], keeps the screen on (even in case of inactivity), so the screensaver does not take over. Works on desktop and mobile platforms. - - Editor-only override for [member display/window/energy_saving/keep_screen_on]. Does not affect running project. - The default screen orientation to use on mobile devices. See [enum DisplayServer.ScreenOrientation] for possible values. [b]Note:[/b] When set to a portrait orientation, this project setting does not flip the project resolution's width and height automatically. Instead, you have to set [member display/window/size/viewport_width] and [member display/window/size/viewport_height] accordingly. diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 8b6d316dd16..57ce7641d08 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -707,6 +707,7 @@ void EditorNode::_notification(int p_what) { RenderingServer::get_singleton()->viewport_set_disable_2d(get_scene_root()->get_viewport_rid(), true); RenderingServer::get_singleton()->viewport_set_environment_mode(get_viewport()->get_viewport_rid(), RenderingServer::VIEWPORT_ENVIRONMENT_DISABLED); + DisplayServer::get_singleton()->screen_set_keep_on(EDITOR_GET("interface/editor/keep_screen_on")); feature_profile_manager->notify_changed(); @@ -805,6 +806,7 @@ void EditorNode::_notification(int p_what) { if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor")) { _update_update_spinner(); _update_vsync_mode(); + DisplayServer::get_singleton()->screen_set_keep_on(EDITOR_GET("interface/editor/keep_screen_on")); } #if defined(MODULE_GDSCRIPT_ENABLED) || defined(MODULE_MONO_ENABLED) diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 0956d122369..d0420ba3739 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -461,6 +461,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/show_update_spinner", 0, "Auto (Disabled),Enabled,Disabled") #endif + _initial_set("interface/editor/keep_screen_on", false); EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_RANGE, "interface/editor/low_processor_mode_sleep_usec", 6900, "1,100000,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) // Default unfocused usec sleep is for 10 FPS. Allow an unfocused FPS limit // as low as 1 FPS for those who really need low power usage (but don't need diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 59f45ef5dbd..ff9ab962dc4 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -93,6 +93,7 @@ void ProjectManager::_notification(int p_what) { } break; case NOTIFICATION_READY: { + DisplayServer::get_singleton()->screen_set_keep_on(EDITOR_GET("interface/editor/keep_screen_on")); const int default_sorting = (int)EDITOR_GET("project_manager/sorting_order"); filter_option->select(default_sorting); project_list->set_order_option(default_sorting);