From 329f4edc5c564b754ea7d1cf497757ec6b4f08a7 Mon Sep 17 00:00:00 2001 From: Laurenz Reinthaler <47503977+Schweini07@users.noreply.github.com> Date: Tue, 15 Dec 2020 16:30:47 +0100 Subject: [PATCH] Improve Cpu Usage while in Idle (#394) Use focus insted of mouse --- src/Main.gd | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Main.gd b/src/Main.gd index 8e474e33a..eed1b4f5e 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -121,8 +121,13 @@ func handle_backup() -> void: func _notification(what : int) -> void: - if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit - show_quit_dialog() + match what: + MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit + show_quit_dialog() + MainLoop.NOTIFICATION_WM_FOCUS_OUT: # Called when the mouse isn't in the window anymore + Engine.set_target_fps(1) # then set the fps to 1 to relieve the cpu + MainLoop.NOTIFICATION_WM_MOUSE_ENTER: # Opposite of the above + Engine.set_target_fps(0) # 0 stands for maximum fps func _on_files_dropped(_files : PoolStringArray, _screen : int) -> void: