@@ -64,6 +64,8 @@ var logger := Log.get_logger("LaunchManager", Log.LEVEL.DEBUG)
6464
6565# Connect to Gamescope signals
6666func _init () -> void :
67+ _load_persist_data ()
68+
6769 # Get the window ID of OpenGamepadUI
6870 if _xwayland_ogui :
6971 var ogui_windows := _xwayland_ogui .get_windows_for_pid (PID )
@@ -77,6 +79,7 @@ func _init() -> void:
7779 if from == to :
7880 return
7981 logger .info ("Window focus changed from " + str (from ) + " to: " + str (to ))
82+ self .check_running .call_deferred ()
8083 _xwayland_primary .focused_window_updated .connect (on_focus_changed )
8184
8285 # When focused app changes, update the current app and gamepad profile
@@ -115,6 +118,7 @@ func _init() -> void:
115118 if from == to :
116119 return
117120 logger .debug ("Focusable apps changed from" , from , "to" , to )
121+ self .check_running .call_deferred ()
118122 # If focusable apps has changed and the currently focused app no longer exists,
119123 # remove the manual focus
120124 var baselayer_app := _xwayland_primary .baselayer_app
@@ -123,6 +127,14 @@ func _init() -> void:
123127 _xwayland_primary .remove_baselayer_app ()
124128 _xwayland_primary .focusable_apps_updated .connect (on_focusable_apps_changed )
125129
130+ # Listen for signals from the secondary Gamescope XWayland
131+ if _xwayland_game :
132+ # Listen for window created/destroyed events
133+ var on_window_created := func (window_id : int ):
134+ logger .debug ("Window created:" , window_id )
135+ self .check_running .call_deferred ()
136+ _xwayland_ogui .window_created .connect (on_window_created )
137+
126138 # Whenever the in-game state is entered, set the gamepad profile
127139 var on_game_state_entered := func (_from : State ):
128140 if _current_app :
@@ -152,6 +164,7 @@ func _init() -> void:
152164 in_game_state .state_exited .connect (on_game_state_exited )
153165 set_gamepad_profile ("" )
154166
167+
155168# Loads persistent data like recent games launched, etc.
156169func _load_persist_data ():
157170 # Create the data directory if it doesn't exist
@@ -189,20 +202,20 @@ func launch(app: LibraryLaunchItem) -> RunningApp:
189202 # Override any parameters that may be in the user's config for this game
190203 var section := "." .join (["game" , app .name .to_lower ()])
191204 var cmd_key := "." .join (["command" , app ._provider_id ])
192- var user_cmd = settings_manager .get_value (section , cmd_key )
193- if user_cmd and user_cmd is String :
205+ var user_cmd = settings_manager .get_value (section , cmd_key , "" )
206+ if user_cmd and user_cmd is String and not ( user_cmd as String ). is_empty () :
194207 cmd = user_cmd
195208 var args_key := "." .join (["args" , app ._provider_id ])
196- var user_args = settings_manager .get_value (section , args_key )
197- if user_args and user_args is PackedStringArray :
209+ var user_args = settings_manager .get_value (section , args_key , PackedStringArray () )
210+ if user_args and user_args is PackedStringArray and not ( user_args as PackedStringArray ). is_empty () :
198211 args = user_args
199212 var cwd_key := "." .join (["cwd" , app ._provider_id ])
200- var user_cwd = settings_manager .get_value (section , cwd_key )
201- if user_cwd and user_cwd is String :
213+ var user_cwd = settings_manager .get_value (section , cwd_key , "" )
214+ if user_cwd and user_cwd is String and not ( user_cwd as String ). is_empty () :
202215 cwd = user_cwd
203216 var env_key := "." .join (["env" , app ._provider_id ])
204- var user_env = settings_manager .get_value (section , env_key )
205- if user_env and user_env is Dictionary :
217+ var user_env = settings_manager .get_value (section , env_key , {} )
218+ if user_env and user_env is Dictionary and not ( user_env as Dictionary ). is_empty () :
206219 env = user_env
207220 var sandboxing_key := "." .join (["use_sandboxing" , app ._provider_id ])
208221 var use_sandboxing := settings_manager .get_value (section , sandboxing_key , true ) as bool
@@ -376,8 +389,8 @@ func set_gamepad_profile(path: String, target_gamepad: String = "") -> void:
376389 logger .info ("Setting target devices to: " , target_devices )
377390 gamepad .set_target_devices (target_devices )
378391
379- var notify := Notification .new ("Using gamepad profile: " + profile .name )
380- notification_manager .show (notify )
392+ # var notify := Notification.new("Using gamepad profile: " + profile.name)
393+ # notification_manager.show(notify)
381394
382395
383396## Sets the given running app as the current app
0 commit comments