Skip to content

Commit

Permalink
fix(LaunchManager): fix incorrectly thinking steam game has closed
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Apr 5, 2023
1 parent 0cc0eed commit 201c07d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 3 additions & 5 deletions core/global/launch_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ var _pid_to_windows := {}
var _running: Array[RunningApp] = []
var _apps_by_pid: Dictionary = {}
var _apps_by_name: Dictionary = {}
var _all_apps_by_name: Dictionary = {}
var _data_dir: String = ProjectSettings.get_setting("OpenGamepadUI/data/directory")
var _persist_path: String = "/".join([_data_dir, "launcher.json"])
var _persist_data: Dictionary = {"version": 1}
Expand Down Expand Up @@ -139,9 +138,7 @@ func launch(app: LibraryLaunchItem) -> RunningApp:
logger.info("Launched with PID: {0}".format([pid]))

# Create a running app instance
if not app.name in _all_apps_by_name:
_all_apps_by_name[app.name] = RunningApp.new(app, pid, display)
var running_app := _all_apps_by_name[app.name] as RunningApp
var running_app := RunningApp.new(app, pid, display)
running_app.launch_item = app
running_app.pid = pid
running_app.display = display
Expand Down Expand Up @@ -332,7 +329,8 @@ func _check_running():

# If this was launched by Steam, try and detect if the game closed
# so we can kill Steam graefully
if app.is_steam_app() and app.created_window:
if app.is_steam_app() and app.num_created_windows > 0:
logger.debug("Running app is a Steam game and has no valid window ID, but has been detected " + str(app.num_created_windows) + " times.")
var steam_pid := app.find_steam()
if steam_pid > 0:
logger.debug("Trying to stop steam with pid: " + str(steam_pid))
Expand Down
3 changes: 3 additions & 0 deletions core/systems/launcher/running_app.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ var app_id: int:
app_id_changed.emit()
## Whether or not the running app has created at least one valid window
var created_window := false
## The number of windows that have been disovered from this app
var num_created_windows := 0
var logger := Log.get_logger("RunningApp", Log.LEVEL.DEBUG)


Expand Down Expand Up @@ -175,6 +177,7 @@ func needs_window_id() -> bool:
# Track that a window has been successfully detected at least once.
if not created_window:
created_window = true
num_created_windows += 1

return false

Expand Down

0 comments on commit 201c07d

Please sign in to comment.