You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-13 13:31:48 +00:00
Decrease the editor FPS cap when the window is unfocused
This decreases CPU/GPU usage when the window is unfocused, which can be beneficial to laptop users. This also makes the low-processor mode sleep project setting no longer affect the editor. Instead, two new editor settings now define the duration of sleeping when the editor is focused and unfocused. This closes #24209 and partially addresses #29257.
This commit is contained in:
@@ -288,6 +288,7 @@ void EditorNode::_notification(int p_what) {
|
||||
|
||||
Engine::get_singleton()->set_editor_hint(true);
|
||||
|
||||
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
|
||||
get_tree()->get_root()->set_usage(Viewport::USAGE_2D_NO_SAMPLING); //reduce memory usage
|
||||
get_tree()->get_root()->set_disable_3d(true);
|
||||
get_tree()->get_root()->set_as_audio_listener(false);
|
||||
@@ -323,9 +324,18 @@ void EditorNode::_notification(int p_what) {
|
||||
|
||||
if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_OUT) {
|
||||
|
||||
// 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")));
|
||||
}
|
||||
|
||||
if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) {
|
||||
|
||||
_menu_option_confirm(FILE_QUIT, false);
|
||||
|
||||
Reference in New Issue
Block a user