Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
non-Steam Windows applications are not Mac apps, so they belong under the Windows library filter
NotProtonNot8c77cf447ee2
diff --git a/dylib/feats/webpatch.c b/dylib/feats/webpatch.cindex 020f14e..da883dd 100644--- a/dylib/feats/webpatch.c+++ b/dylib/feats/webpatch.c@@ -484,10 +484,18 @@ static const np_gate_t g_gates_selecttool[] = {#define NP_MAC_CHECK(OS, APP) \"(0," OS ".Pr)()&&" NP_PLATFORM_LISTS ".mac.has(" APP ".appid)?!" APP \".most_available_per_client_data?.is_invalid_os_type:(0," OS ".Pr)()&&" \- NP_PLATFORM_LISTS ".windows.has(" APP ".appid)?!1:(0," OS ".Pr)()?" \+ NP_WINDOWS(APP) "?!1:(0," OS ".Pr)()?" \APP ".is_available_on_current_platform&&!" APP ".most_available_per_client_data?.is_invalid_os_type:"+// .exe shortcuts = Windows+#define NP_RUNS_EXE "window.__NOTPROTON_RUNS_EXE__"+#define NP_RUNS_EXE_JS \+ NP_RUNS_EXE "=a=>{if(!a.BIsShortcut?.())return!1;const s=window.appDetailsStore,e=s?.m_mapAppData?.get(a.appid);" \+ "s&&!e?.cRegistered&&queueMicrotask(()=>s.m_mapAppData.get(a.appid)?.cRegistered||s.RegisterForAppData(a.appid));" \+ "return/\\.exe\"?$/i.test(e?.details?.strShortcutExe??\"\")};\n"+#define NP_WINDOWS(APP) \+ "(" NP_PLATFORM_LISTS ".windows.has(" APP ".appid)||" NP_RUNS_EXE "(" APP "))"#define NP_WINDOWS_ONLY_CASE(OS, APP) \- "case\"notprotonWindows\":return(0," OS ".Pr)()&&" NP_PLATFORM_LISTS ".windows.has(" APP ".appid)&&!" \+ "case\"notprotonWindows\":return(0," OS ".Pr)()&&" NP_WINDOWS(APP) "&&!" \NP_MAC_64(APP) ";"static const np_gate_t g_fixes[] = {@@ -731,7 +739,9 @@ char *np_webpatch_transform(const uint8_t *src, size_t src_len, size_t *out_len,np_out_t out = {0};np_cap_t caps[NP_CAP_MAX];- if (native_mac_js && !out_put(&out, native_mac_js, strlen(native_mac_js))) {+ if (native_mac_js && (!out_put(&out, native_mac_js, strlen(native_mac_js)) ||+ !out_put(&out, NP_RUNS_EXE_JS, sizeof(NP_RUNS_EXE_JS) - 1))) {+ free(out.buf);free(native_mac_js);return NULL;}diff --git a/dylib/tests/library-filter/behavior.js b/dylib/tests/library-filter/behavior.jsindex 16bc69e..fc16dc6 100644--- a/dylib/tests/library-filter/behavior.js+++ b/dylib/tests/library-filter/behavior.js@@ -21,7 +21,7 @@ function grab(src, re, what) {const english = () => { globalThis.document = { documentElement: { lang: 'en' } }; };function filter(src) {- const head = grab(src, /case"notprotonWindows":return\(0,([\w$]+)\.Pr\)\(\)&&window\.__NOTPROTON_NATIVE_PLATFORM__\.windows\.has\(([\w$]+)\.appid\)/,+ const head = grab(src, /case"notprotonWindows":return\(0,([\w$]+)\.Pr\)\(\)&&\(window\.__NOTPROTON_NATIVE_PLATFORM__\.windows\.has\(([\w$]+)\.appid\)/,'filter fix');const apple = grab(src.slice(head.index), /;case ([\w$]+)\.([\w$]+):return /, 'Apple case');const end = src.indexOf('.is_invalid_os_type;', head.index + apple.index + apple[0].length);@@ -36,7 +36,8 @@ function filter(src) {function lists(src) {const win = {};- new Function('window', src.slice(0, src.indexOf('\n') + 1))(win);+ const header = src.indexOf('\n', src.indexOf('\n') + 1) + 1;+ new Function('window', 'queueMicrotask', src.slice(0, header))(win, f => f());return win;}@@ -68,6 +69,35 @@ function check(file, name, t) {'the fallback on other platforms still uses the original invalid flag');t(apple(app(2), windows) && !wonly(app(2), windows), "on Windows the filter is Steam's");+ const registered = [];+ const entries = new Map();+ win.appDetailsStore = {+ m_mapAppData: entries,+ RegisterForAppData(id) {+ registered.push(id);+ const e = entries.get(id) || { cRegistered: 0 };+ e.cRegistered++;+ entries.set(id, e);+ },+ };+ const shortcut = appid => ({ ...app(appid), BIsShortcut: () => true });+ const target = (appid, exe) => { entries.get(appid).details = { strShortcutExe: exe }; };+ t(apple(app(3)) && !wonly(app(3)) && registered.length === 0,+ 'a Steam game never asks for shortcut details');+ t(apple(shortcut(10)) && !wonly(shortcut(10)) && apple(shortcut(10)),+ "a shortcut gets Steam's answer until its details arrive");+ t(registered.join() === '10', 'a shortcut asks for its details once');+ target(10, '"/Users/me/Downloads/Setup.EXE"');+ t(!apple(shortcut(10)) && wonly(shortcut(10)), 'an .exe shortcut is under Windows only');+ t(apple(shortcut(10), windows) && !wonly(shortcut(10), windows), "on Windows an .exe shortcut is Steam's");+ apple(shortcut(11));+ target(11, '"/Applications/Game.app"');+ t(apple(shortcut(11)) && !wonly(shortcut(11)), 'an .app shortcut stays under Apple');+ target(10, '"/Users/me/Downloads/game.exe.app"');+ t(apple(shortcut(10)) && !wonly(shortcut(10)), 'a shortcut retargeted to an app moves back to Apple');+ t(registered.join() === '10,11', 'each shortcut asked for its details once');+ delete win.appDetailsStore;+if (!src.includes('SelectCollectionsAppFilterOption("notprotonWindows"')) return;grab(src, /filterGroups:\[([\w$]+)\(!0,([\w$]+)&&\2\.filterGroups\[0\]\),\1\(!1,\2&&\2\.filterGroups\[1\]\)/,