Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 13 additions & 25 deletions core/global/launch_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var _persist_path: String = "/".join([_data_dir, "launcher.json"])
var _persist_data: Dictionary = {"version": 1}
var _ogui_window_id := 0
var should_manage_overlay := true
var logger := Log.get_logger("LaunchManager", Log.LEVEL.INFO)
var logger := Log.get_logger("LaunchManager", Log.LEVEL.DEBUG)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to fix before merge.

var _focused_app_id := 0


Expand Down Expand Up @@ -126,19 +126,6 @@ func _init() -> void:
return
logger.debug("Focusable apps changed from", from, "to", to)
self.check_running.call_deferred()
# If focusable apps has changed and the currently focused app no longer exists,
# remove the manual focus
const keep_app_ids := [GamescopeInstance.EXTRA_UNKNOWN_GAME_ID, GamescopeInstance.OVERLAY_GAME_ID]
var baselayer_apps := _xwayland_primary.baselayer_apps
var new_baselayer_apps := PackedInt64Array()
for app_id in baselayer_apps:
if app_id in keep_app_ids:
new_baselayer_apps.push_back(app_id)
continue
if app_id in to:
new_baselayer_apps.push_back(app_id)
if new_baselayer_apps != baselayer_apps:
_xwayland_primary.baselayer_apps = new_baselayer_apps
_xwayland_primary.focusable_apps_updated.connect(on_focusable_apps_changed)

# Listen for when focusable windows change
Expand Down Expand Up @@ -169,7 +156,7 @@ func _init() -> void:

if _xwayland_ogui:
logger.debug("Enabling STEAM_OVERLAY atom")
_xwayland_ogui.set_overlay(_ogui_window_id, 0)
_xwayland_ogui.set_overlay(_ogui_window_id, 1)

var on_game_state_exited := func(_to: State):
# Set the gamepad profile to the global profile
Expand Down Expand Up @@ -221,11 +208,10 @@ func launch(app: LibraryLaunchItem) -> RunningApp:
# Add the running app to our list and change to the IN_GAME state
_add_running(running_app)
state_machine.set_state([in_game_state])
_update_recent_apps(app)
update_recent_apps(app)

# Execute any pre-launch hooks and start the app
await _execute_hooks(app, AppLifecycleHook.TYPE.PRE_LAUNCH)
running_app.start()

# Call any hooks at different points in the app's lifecycle
var on_app_state_changed := func(_from: RunningApp.STATE, to: RunningApp.STATE):
Expand All @@ -251,13 +237,17 @@ func launch(app: LibraryLaunchItem) -> RunningApp:
var focused_window := _xwayland_primary.baselayer_window
if not focused_window in old_windows:
return
if new_windows.is_empty():
if not focused_window in new_windows:
_xwayland_primary.remove_baselayer_window()
return
# TODO: Use the most recently created window instead of just the first in the list
var new_window := new_windows[0]
running_app.switch_window(new_window)
running_app.window_ids_changed.connect(remove_focus)

# Run the application
running_app.start()

return running_app


Expand Down Expand Up @@ -400,7 +390,7 @@ func get_recent_apps() -> Array:


# Updates our list of recently launched apps
func _update_recent_apps(app: LibraryLaunchItem) -> void:
func update_recent_apps(app: LibraryLaunchItem) -> void:
if not "recent" in _persist_data:
_persist_data["recent"] = []
var recent: Array = _persist_data["recent"]
Expand Down Expand Up @@ -619,24 +609,22 @@ func check_running() -> void:
_update_pids(all_valid_windows)

# Update the state of all running apps
var windows_with_app := PackedInt64Array()
var orphan_windows := PackedInt64Array()
for app in _running:
var app_pids := PackedInt64Array()
if app.ogui_id in ogui_id_to_pids:
app_pids = ogui_id_to_pids[app.ogui_id]
app.update(all_valid_windows, app_pids)
windows_with_app.append_array(app.window_ids.duplicate())
for app in _running_background:
var app_pids := PackedInt64Array()
if app.ogui_id in ogui_id_to_pids:
app_pids = ogui_id_to_pids[app.ogui_id]
app.update(all_valid_windows, app_pids)
windows_with_app.append_array(app.window_ids.duplicate())

# Look for orphan windows
var windows_with_app := PackedInt64Array()
var orphan_windows := PackedInt64Array()
for app in _running:
windows_with_app.append_array(app.window_ids.duplicate())
for app in _running_background:
windows_with_app.append_array(app.window_ids.duplicate())
for window in all_valid_windows:
if window in windows_with_app:
continue
Expand Down
1 change: 1 addition & 0 deletions core/systems/effects/fade_effect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func fade_out() -> void:
tween.tween_property(target, "visible", false, 0)
var on_finished := func():
fade_out_finished.emit()
target.modulate = Color(1, 1, 1, 1)
tween.tween_callback(on_finished)


Expand Down
Loading