diff --git a/Translations/Translations.pot b/Translations/Translations.pot index 7b3ed61c1..2a0259fb5 100644 --- a/Translations/Translations.pot +++ b/Translations/Translations.pot @@ -1058,13 +1058,13 @@ msgstr "" msgid "Set application FPS limit:" msgstr "" -msgid "Limit FPS to the idle FPS when app loses focus" +msgid "Pause application when it loses focus" msgstr "" msgid "Sets the limit of the application's frames per second. The lower the number, the lower the CPU usage, but the application gets slower, choppier and unresponsive. 0 means that there is no limit." msgstr "" -msgid "If this is toggled on, when the application's window loses focus, the FPS limit of the application is set to the idle FPS. This helps lower CPU usage when idle. The FPS limit is being reset when the mouse enters the application's window." +msgid "If this is toggled on, when the application's window loses focus, it gets paused. This helps lower CPU usage when idle. The application gets unpaused when the mouse enters the application's window." msgstr "" msgid "Brush:" @@ -1790,9 +1790,3 @@ msgstr "" msgid "Position:" msgstr "" - -msgid "Set idle FPS:" -msgstr "" - -msgid "Sets how many FPS Pixelorama uses when out of focus. The less the better the performance." -msgstr "" diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index e3a101d20..09688ff37 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -70,9 +70,8 @@ var selection_animated_borders := true var selection_border_color_1 := Color.white var selection_border_color_2 := Color.black -var fps_limit_focus := true +var pause_when_unfocused := true var fps_limit := 0 -var idle_fps := 1 var autosave_interval := 1.0 var enable_autosave := true diff --git a/src/Main.gd b/src/Main.gd index a1f4803af..b465f31d3 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -328,22 +328,22 @@ func _handle_backup() -> void: func _notification(what: int) -> void: match what: - MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit + MainLoop.NOTIFICATION_WM_QUIT_REQUEST: show_quit_dialog() - MainLoop.NOTIFICATION_WM_FOCUS_OUT: # Called when another program is currently focused - Global.has_focus = false - if Global.fps_limit_focus: - # then set the fps to the idle fps (by default 1) to facilitate the CPU - Engine.set_target_fps(Global.idle_fps) - MainLoop.NOTIFICATION_WM_MOUSE_ENTER: # Opposite of the above - if Global.fps_limit_focus: - Engine.set_target_fps(Global.fps_limit) # 0 stands for maximum fps # If the mouse exits the window and another application has the focus, - # set the fps to the idle fps + # pause the application + MainLoop.NOTIFICATION_WM_FOCUS_OUT: + Global.has_focus = false + if Global.pause_when_unfocused: + get_tree().paused = true MainLoop.NOTIFICATION_WM_MOUSE_EXIT: - if !OS.is_window_focused() and Global.fps_limit_focus: - Engine.set_target_fps(Global.idle_fps) + if !OS.is_window_focused() and Global.pause_when_unfocused: + get_tree().paused = true + # Unpause it when the mouse enters the window or when it gains focus + MainLoop.NOTIFICATION_WM_MOUSE_ENTER: + get_tree().paused = false MainLoop.NOTIFICATION_WM_FOCUS_IN: + get_tree().paused = false var mouse_pos := get_global_mouse_position() var viewport_rect := Rect2( Global.main_viewport.rect_global_position, Global.main_viewport.rect_size diff --git a/src/Preferences/PreferencesDialog.gd b/src/Preferences/PreferencesDialog.gd index 28ff8ceb3..261b3af7d 100644 --- a/src/Preferences/PreferencesDialog.gd +++ b/src/Preferences/PreferencesDialog.gd @@ -147,12 +147,11 @@ var preferences = [ ], ["fps_limit", "Performance/PerformanceContainer/SetFPSLimit", "value", Global.fps_limit], [ - "fps_limit_focus", - "Performance/PerformanceContainer/EnableLimitFPSFocus", + "pause_when_unfocused", + "Performance/PerformanceContainer/PauseAppFocus", "pressed", - Global.fps_limit_focus + Global.pause_when_unfocused ], - ["idle_fps", "Performance/PerformanceContainer/IdleFPS", "value", Global.idle_fps] ] var selected_item := 0 @@ -165,9 +164,6 @@ onready var autosave_interval: SpinBox = right_side.get_node( ) onready var shrink_label: Label = right_side.get_node("Interface/ShrinkContainer/ShrinkLabel") onready var themes: BoxContainer = right_side.get_node("Interface/Themes") -onready var idle_fps_spinbox: SpinBox = right_side.get_node( - "Performance/PerformanceContainer/IdleFPS" -) func _ready() -> void: @@ -331,9 +327,6 @@ func preference_update(prop: String) -> void: if prop in ["fps_limit"]: Engine.set_target_fps(Global.fps_limit) - if prop in ["fps_limit_focus"]: - idle_fps_spinbox.editable = !idle_fps_spinbox.editable - if ( prop in ["selection_animated_borders", "selection_border_color_1", "selection_border_color_2"] diff --git a/src/Preferences/PreferencesDialog.tscn b/src/Preferences/PreferencesDialog.tscn index 19db5bbd2..bd680e0b5 100644 --- a/src/Preferences/PreferencesDialog.tscn +++ b/src/Preferences/PreferencesDialog.tscn @@ -10,8 +10,8 @@ [node name="PreferencesDialog" type="AcceptDialog"] margin_left = -3.0 margin_top = 9.0 -margin_right = 419.0 -margin_bottom = 1163.0 +margin_right = 617.0 +margin_bottom = 459.0 rect_min_size = Vector2( 620, 450 ) window_title = "Preferences" resizable = true @@ -39,13 +39,13 @@ __meta__ = { [node name="List" type="ItemList" parent="HSplitContainer"] margin_right = 86.0 -margin_bottom = 1110.0 +margin_bottom = 406.0 rect_min_size = Vector2( 85, 0 ) [node name="ScrollContainer" type="ScrollContainer" parent="HSplitContainer"] margin_left = 106.0 margin_right = 604.0 -margin_bottom = 1110.0 +margin_bottom = 406.0 rect_min_size = Vector2( 100, 0 ) size_flags_horizontal = 3 @@ -1376,11 +1376,11 @@ __meta__ = { [node name="Performance" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"] visible = false margin_top = 28.0 -margin_right = 553.0 +margin_right = 500.0 margin_bottom = 80.0 [node name="PerformanceContainer" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance"] -margin_right = 553.0 +margin_right = 500.0 margin_bottom = 52.0 columns = 3 @@ -1407,20 +1407,20 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="EnableLimitFPSFocusLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"] -margin_left = 324.0 +[node name="PauseAppFocusLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"] +margin_left = 261.0 margin_top = 5.0 -margin_right = 553.0 +margin_right = 500.0 margin_bottom = 19.0 -hint_tooltip = "If this is toggled on, when the application's window loses focus, the FPS limit of the application is set to the idle FPS. This helps lower CPU usage when idle. The FPS limit is being reset when the mouse enters the application's window." +hint_tooltip = "If this is toggled on, when the application's window loses focus, it gets paused. This helps lower CPU usage when idle. The application gets unpaused when the mouse enters the application's window." mouse_filter = 0 -text = "Limit FPS to the idle FPS when app loses focus" +text = "Pause application when it loses focus" -[node name="EnableLimitFPSFocus" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"] +[node name="PauseAppFocus" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"] margin_top = 28.0 margin_right = 158.0 margin_bottom = 52.0 -hint_tooltip = "If this is toggled on, when the application's window loses focus, the FPS limit of the application is set to the idle FPS. This helps lower CPU usage when idle. The FPS limit is being reset when the mouse enters the application's window." +hint_tooltip = "If this is toggled on, when the application's window loses focus, it gets paused. This helps lower CPU usage when idle. The application gets unpaused when the mouse enters the application's window." mouse_default_cursor_shape = 2 pressed = true text = "On" @@ -1428,33 +1428,6 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="IdleFPSLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"] -margin_left = 162.0 -margin_top = 33.0 -margin_right = 320.0 -margin_bottom = 47.0 -hint_tooltip = "Sets how many FPS Pixelorama uses when out of focus." -mouse_filter = 0 -size_flags_horizontal = 0 -text = "Set idle FPS:" - -[node name="IdleFPS" type="SpinBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Performance/PerformanceContainer"] -margin_left = 324.0 -margin_top = 28.0 -margin_right = 419.0 -margin_bottom = 52.0 -rect_min_size = Vector2( 95, 0 ) -hint_tooltip = "Sets how many FPS Pixelorama uses when out of focus." -mouse_default_cursor_shape = 2 -size_flags_horizontal = 0 -min_value = 1.0 -max_value = 60.0 -value = 1.0 -align = 2 -__meta__ = { -"_edit_use_anchors_": false -} - [node name="Indicators" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"] visible = false margin_top = 54.0