diff --git a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility index f3181b608e..e37cddfbf6 100755 --- a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility +++ b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility @@ -1084,7 +1084,7 @@ def plan_mapping(current, installed, runnable, default, auto, native=None, picks continue mine = auto.get(app) target = native.get(app, default) - if not name and app in native_choices: + if not name and (app in native_choices or (app in current and app in FEX_DEFAULT_APPS)): target = NATIVE_CHOICE stale = unrunnable(name, runnable) if name and not stale and (mine is None or name != mine): diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 36178ab610..c48e5ab1b2 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -1682,6 +1682,46 @@ class ProtonDefaultTest(unittest.TestCase): self.assertEqual(changes, {}) self.assertEqual(auto, {}) + def test_a_cleared_fex_default_for_a_listed_title_is_kept_as_a_native_choice(self): + app = "4385780" + fex = COMPAT["FEX_TOOL"] + with tempfile.TemporaryDirectory() as tmp: + steam = Path(tmp) / "Steam" + config = steam / "config/config.vdf" + config.parent.mkdir(parents=True) + config.write_text(config_text([("0", self.TOOL)])) + (Path(tmp) / "state.json").write_text(json.dumps({"default": self.TOOL, "auto": {}})) + + globals_ = COMPAT["native_targets"].__globals__ + original_platforms = globals_["appinfo_platforms"] + globals_["appinfo_platforms"] = lambda _path, wanted: { + app: ({"linux", "windows"}, "64", "game") + } if app in wanted else {} + try: + def run(): + COMPAT["register_default"](str(config), [app], catalog=self.CATALOG, directory=tmp) + return json.loads((Path(tmp) / "state.json").read_text()) + + state = run() + self.assertEqual(mapping_of(config.read_text()), {"0": self.TOOL, app: fex}) + self.assertEqual(state["auto"], {app: fex}) + + config.write_text(config_text([("0", self.TOOL), (app, "")])) + state = run() + cleared = config.read_bytes() + self.assertEqual(mapping_of(cleared.decode()), {"0": self.TOOL, app: ""}) + self.assertEqual(state["auto"], {}) + self.assertEqual(state["native_choices"], [app]) + run() + self.assertEqual(config.read_bytes(), cleared) + + config.write_text(config_text([("0", self.TOOL), (app, fex)])) + state = run() + self.assertEqual(mapping_of(config.read_text()), {"0": self.TOOL, app: fex}) + self.assertEqual(state["native_choices"], []) + finally: + globals_["appinfo_platforms"] = original_platforms + def test_factorio_preserves_an_observed_native_choice_despite_ambiguous_metadata(self): with tempfile.TemporaryDirectory() as tmp: steam = Path(tmp) / "Steam"