fix(proton): an installed DroidDeck-Proton replaces a Proton Experimental default nobody picked, and added shortcuts follow it (#2266)

* fix(proton): an installed DroidDeck-Proton replaces a Proton Experimental default nobody picked, and added shortcuts follow the default

* test: an owned shortcut left on the previous default follows a default change
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-08 06:07:53 -05:00
1 parent 15baa296bb
commit 39469e6e8f
5 files changed
+136 -22

No files matched your search

@@ -1078,7 +1078,8 @@ class Helper:
wanted = COMPAT["requested_tool"](request, catalog)
newer = isinstance(request.get("seq"), int) and request["seq"] > int(state.get("applied", 0) or 0)
waiting = newer and wanted is not None and wanted not in self.known
default, state = COMPAT["choose_default"](top["selected"], state, request, live, apply_request=not waiting)
default, state = COMPAT["choose_default"](top["selected"], state, request, catalog, apply_request=not waiting,
listed=[t["name"] for t in live])
installed = COMPAT["installed_apps"](self.steam_root)
self.installed = installed
picks = COMPAT["valve_picks"](self.steam_root)
@@ -1137,7 +1138,7 @@ class Helper:
state.update(
auto={app: tool for app, tool in auto.items() if tool is not COMPAT["NATIVE_CHOICE"]},
native_choices=sorted(refused_native | {app for app, tool in auto.items() if tool is COMPAT["NATIVE_CHOICE"]}),
picked=COMPAT["picked_after"](current, changes), tools=catalog, live=True,
picked=COMPAT["picked_after"](current, changes), tools=catalog, live=True, written=default,
games_applied=COMPAT["applied_game_requests"](requests, overrides, state))
state.pop("native", None)
if waiting:
@@ -355,8 +355,9 @@ def main():
"linux_tool": "droiddeck-direct"}
else:
protect = compat.adopt_extras(tools)
used = compat.register_default(cfg, apps=[str(int(g["appid"]) & 0xFFFFFFFF) for g in games if g.get("exe") and not g.get("native")] + [str(appid) for appid in set(routes.values())],
protect=protect, **own)
owned = [str(int(g["appid"]) & 0xFFFFFFFF) for g in games if g.get("exe") and not g.get("native")]
used = compat.register_default(cfg, apps=owned + [str(appid) for appid in set(routes.values())],
protect=protect, owned=owned, **own)
print("droiddeck-steam-shortcuts: mapped them to %s" % used)
except Exception as e:
print("droiddeck-steam-shortcuts: compat mapping skipped (%s)" % e)
@@ -1307,9 +1307,13 @@ def now_ms():
return int(time.time() * 1000)
def choose_default(steam_default, state, request, catalog, adopt_steam=True, apply_request=True, now=None):
def choose_default(steam_default, state, request, catalog, adopt_steam=True, apply_request=True, now=None, listed=None):
state = dict(state)
names = [t["name"] for t in catalog]
listed = names if listed is None else listed
if "written" not in state and state.get("source") == "steam":
state["source"] = "fallback"
hidden = state.get("default") in names and state.get("default") not in listed
seq = request.get("seq")
seq = seq if isinstance(seq, int) else 0
if apply_request and seq > int(state.get("applied", 0) or 0):
@@ -1321,11 +1325,12 @@ def choose_default(steam_default, state, request, catalog, adopt_steam=True, app
else:
print("steam-compatibility: the app asked for %s, which is not installed; kept %s" % (
request.get("name") or request.get("dir"), state.get("default") or TOOL))
elif adopt_steam and steam_default in names and steam_default != state.get("default"):
elif adopt_steam and steam_default in names and not hidden and steam_default not in (
state.get("default"), state.get("written", state.get("default") or TOOL)):
state.update(default=steam_default, seq=now or now_ms(), source="steam")
if state.get("default") not in names:
state["default"] = TOOL
return state["default"], state
if state.get("default") not in names and state.get("default") != TOOL:
state.update(default=TOOL, source="fallback")
return state["default"] if state["default"] in listed else TOOL, state
def mapping_block(tokens):
@@ -1482,7 +1487,7 @@ def live_helper_running(directory=None):
def register_default(config_path, apps=(), protect=(), default=None, catalog=None, directory=None, settle=False, picks=(),
linux_tool=FEX_TOOL):
linux_tool=FEX_TOOL, owned=None):
with locked(directory):
state = read_json(state_path("state.json", directory))
with open(config_path, encoding="utf-8", errors="replace") as f:
@@ -1497,18 +1502,24 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non
dict(protect) if isinstance(protect, dict) else {name: name for name in protect})
names = [t["name"] for t in catalog]
newest, gone = own_proton_moves(state, catalog)
previous, applied, chosen = state.get("default"), state.get("applied"), state.get("seq")
previous = state.get("default")
if owned is not None:
auto = followers(state, current)
known = {app for app in state.get("owned", ()) if isinstance(app, str)} if isinstance(state.get("owned"), list) else set()
pinned = {app: current[app] for app in set(owned) - known
if current.get(app) in {TOOL, previous} | gone and app not in auto}
if pinned and isinstance(auto, dict):
state["auto"] = dict(auto, **pinned)
state["owned"] = sorted(set(owned), key=app_order)
if default is None:
if settle:
default, state = choose_default(current.get("0", ""), state, read_json(state_path("request.json", directory)), catalog)
else:
default = state.get("default") if state.get("default") in names else TOOL
if settle and newest and default == TOOL and state.get("applied") == applied and state.get("seq") == chosen and (
previous in gone or not state.get("own_proton")):
if settle and newest and default == TOOL and state.get("source") not in ("app", "steam"):
default = newest
state.update(default=newest, seq=now_ms(), source="update")
if settle and newest:
state["own_proton"] = True
state.pop("own_proton", None)
if newest:
replacements = {app: newest for app, name in current.items() if app != "0" and name in gone}
set_mappings(tokens, mapping, replacements)
@@ -1539,6 +1550,8 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non
state.pop("native", None)
state["tools"] = catalog
state.setdefault("default", default)
if settle:
state["written"] = default
write_json(state_path("state.json", directory), state)
return default