From 9fd0fc9334d9df43a4f2c5365dbb0d0422fd8c17 Mon Sep 17 00:00:00 2001 From: "Derek J. Clark" Date: Sat, 21 Dec 2024 14:47:10 -0800 Subject: [PATCH] fix(Overlay Mode): Focus and Profile Fixes - Fix bug where an app type couldn't be detected if it was started by Steam. - Only change Steam overlay status if it was the overlay. - Also ignore window ID 1, Chimera App sets Steam to this for some reason. --- core/global/launch_manager.gd | 11 ++++++----- core/ui/card_ui_overlay_mode/card_ui_overlay_mode.gd | 8 ++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/core/global/launch_manager.gd b/core/global/launch_manager.gd index 69099dba..d753d43c 100644 --- a/core/global/launch_manager.gd +++ b/core/global/launch_manager.gd @@ -61,7 +61,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.DEBUG) +var logger := Log.get_logger("LaunchManager", Log.LEVEL.INFO) var _focused_app_id := 0 @@ -93,7 +93,7 @@ func _init() -> void: _focused_app_id = to # If OGUI was focused, set the global gamepad profile - if to in [gamescope.OVERLAY_GAME_ID, 0]: + if to in [gamescope.OVERLAY_GAME_ID, 0, 1]: set_gamepad_profile("") return @@ -577,7 +577,7 @@ func _is_app_id_running(app_id) -> bool: # Identifies the running app from the given window_id. If none is found, # creates a new RunningApp instance. -func _detect_running_app(_app_id: int) -> RunningApp: +func _detect_running_app(app_id: int) -> RunningApp: logger.debug("No known running app in focused window. Attempting to detect the running app.") # Get the currently focused window id @@ -620,12 +620,12 @@ func _detect_running_app(_app_id: int) -> RunningApp: return null logger.debug("Found app name : " + app_name) - return _make_running_app_from_process(app_name, pid, window_id) + return _make_running_app_from_process(app_name, pid, window_id, app_id) # Creates a new RunningApp instance from a given name, PID, and window_id. Used # when an app launch is detcted that wasn't launched by an OGUI library. -func _make_running_app_from_process(name: String, pid: int, window_id: int) -> RunningApp: +func _make_running_app_from_process(name: String, pid: int, window_id: int, app_id: int) -> RunningApp: logger.debug("Creating running app from process") # Create a dummy LibraryLaunchItem to make our RunningApp. @@ -646,6 +646,7 @@ func _make_running_app_from_process(name: String, pid: int, window_id: int) -> R if _xwayland_game: display = _xwayland_game.name var running_app: RunningApp = _make_running_app(launch_item, pid, display) + running_app.app_id = app_id running_app.window_id = window_id running_app.state = RunningApp.STATE.RUNNING running_app.is_ogui_managed = false diff --git a/core/ui/card_ui_overlay_mode/card_ui_overlay_mode.gd b/core/ui/card_ui_overlay_mode/card_ui_overlay_mode.gd index c283d7fc..8b913388 100644 --- a/core/ui/card_ui_overlay_mode/card_ui_overlay_mode.gd +++ b/core/ui/card_ui_overlay_mode/card_ui_overlay_mode.gd @@ -25,6 +25,7 @@ var managed_states: Array[State] = [quick_bar_state, settings_state, gamepad_sta var xwayland_primary := gamescope.get_xwayland(gamescope.XWAYLAND_TYPE_PRIMARY) var xwayland_ogui := gamescope.get_xwayland(gamescope.XWAYLAND_TYPE_OGUI) var overlay_window_id := 0 +var set_steam_overlay_focus := false # Process var PID: int = OS.get_process_id() @@ -300,7 +301,8 @@ func _on_base_state_entered(_from: State) -> void: # Manage overlay xwayland_ogui.set_overlay(overlay_window_id, 0) - xwayland_ogui.set_overlay(underlay_window_id, 1) + if self.set_steam_overlay_focus: + xwayland_ogui.set_overlay(underlay_window_id, 1) ## Called when a the base state is exited. @@ -315,8 +317,10 @@ func _on_base_state_exited(_to: State) -> void: logger.error("Unable to set STEAM_INPUT_FOCUS atom!") # Manage overlay + self.set_steam_overlay_focus = xwayland_ogui.get_overlay(underlay_window_id) == 1 xwayland_ogui.set_overlay(overlay_window_id, 1) - xwayland_ogui.set_overlay(underlay_window_id, 0) + if self.set_steam_overlay_focus: + xwayland_ogui.set_overlay(underlay_window_id, 0) ## Verifies steam is still running by checking for the steam overlay, closes otherwise.