summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2021-06-17 12:50:36 +0200
committerGitHub <noreply@github.com>2021-06-17 12:50:36 +0200
commitdd39855c0a19f2d9a9c76b2f8b204e96d94d31e3 (patch)
tree4d835c9aa9d956dbe2e879526d580004fbd876ae
parentba9ffbe5d766b0eeb2cb26729f53017b547eecc3 (diff)
parentf10c30a9ed6690ed98c3953a923689589f244f3b (diff)
Merge pull request #47796 from Calinou/editor-add-save-on-focus-loss-option
Add a "save on focus loss" editor setting (disabled by default)
-rw-r--r--editor/editor_node.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index b6264af9eb..73bb1f3856 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -609,7 +609,7 @@ void EditorNode::_notification(int p_what) {
} break;
case NOTIFICATION_APPLICATION_FOCUS_IN: {
- // Restore the original FPS cap after focusing back on the editor
+ // Restore the original FPS cap after focusing back on the editor.
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
EditorFileSystem::get_singleton()->scan_changes();
@@ -617,7 +617,12 @@ void EditorNode::_notification(int p_what) {
} break;
case NOTIFICATION_APPLICATION_FOCUS_OUT: {
- // Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused
+ // Save on focus loss before applying the FPS limit to avoid slowing down the saving process.
+ if (EDITOR_GET("interface/editor/save_on_focus_loss")) {
+ _menu_option_confirm(FILE_SAVE_SCENE, false);
+ }
+
+ // Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused.
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec")));
} break;
@@ -5845,6 +5850,7 @@ EditorNode::EditorNode() {
EDITOR_DEF("run/output/always_open_output_on_play", true);
EDITOR_DEF("run/output/always_close_output_on_stop", true);
EDITOR_DEF("run/auto_save/save_before_running", true);
+ EDITOR_DEF("interface/editor/save_on_focus_loss", false);
EDITOR_DEF_RST("interface/editor/save_each_scene_on_quit", true);
EDITOR_DEF("interface/editor/show_update_spinner", false);
EDITOR_DEF("interface/editor/update_continuously", false);