Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

Add the Windows library button on the Steam beta

NotProtonNot99a823356bad
diff --git a/dylib/feats/webpatch.c b/dylib/feats/webpatch.c
index 8f09a54..4f40bed 100644
--- a/dylib/feats/webpatch.c
+++ b/dylib/feats/webpatch.c
@@ -535,6 +535,23 @@ static const np_gate_t g_fixes[] = {
#define NP_NATIVE_MAC_FILTER_FIX (NP_FIX_COUNT - 2)
#define NP_UPDATED_NATIVE_MAC_FILTER_FIX (NP_FIX_COUNT - 1)
+#define NP_PLATFORM_TIP "\"#GameList_View_Platform_Linux\":\"#GameList_View_Platform_Apple\""
+#define NP_LOCALIZED_PLATFORM_TIP "(0," NP_C12 ".we)(\"#GameList_View_Platform_Linux\"):(0," NP_C12 \
+ ".we)(\"#GameList_View_Platform_Apple\")"
+#define NP_PLATFORM_BUTTON(tip) \
+ NP_C1 "&&(0," NP_C2 ".jsxs)(" NP_C3 ".he,{direction:\"top\",nDelayShowMS:240,toolTipContent:" NP_C4 \
+ "?" tip ",className:(0," NP_C5 ".A)(" NP_C6 "().CheckboxWithImage," NP_C7 "&&" NP_C6 "().Disabled," \
+ NP_C8 "&&" NP_C6 "().Active),onClick:()=>" NP_C7 "||" NP_C9 "(" NP_C10 ".W6," NP_C10 ".Pu,!" NP_C8 \
+ "),children:[" NP_C4 "&&(0," NP_C2 ".jsx)(" NP_C11 ".Wy0,{}),!" NP_C4 "&&(0," NP_C2 ".jsx)(" NP_C11 ".kPc,{})]})"
+#define NP_WINDOWS_BUTTON \
+ NP_C1 "&&!" NP_C4 "&&" NP_C11 ".Xz0&&(0," NP_C2 ".jsxs)(" NP_C3 ".he,{direction:\"top\",nDelayShowMS:240," \
+ "toolTipContent:" NP_LIBRARY_WINDOWS_HINT ",className:(0," NP_C5 ".A)(" NP_C6 "().CheckboxWithImage," \
+ NP_C7 "&&" NP_C6 "().Disabled,npWindows&&" NP_C6 "().Active),onClick:()=>" NP_C7 \
+ "||npStore.SelectCollectionsAppFilterOption(\"notprotonWindows\",null,!npWindows)," \
+ "children:[(0," NP_C2 ".jsx)(\"style\",{children:\".\"+" NP_C6 "().CheckboxWithImage+" \
+ "\" .SVGIcon_WindowsLogo{width:13px;height:13px}.\"+" NP_C6 "().CheckboxWithImage+" \
+ "\" .SVGIcon_WindowsLogo rect{fill:inherit}\"}),(0," NP_C2 ".jsx)(" NP_C11 ".Xz0,{})]})"
+
static const np_gate_t g_library_filters[] = {
// Library list and search
{ "if(!" NP_C1 "(" NP_C2 "[" NP_C3 ".W6]," NP_C4 "(" NP_C5 "))||!" NP_C1 "(" NP_C2 "[" NP_C3 ".sc],",
@@ -566,27 +583,17 @@ static const np_gate_t g_library_filters[] = {
"," NP_C1 "=" NP_C2 ".n6.currentAppFilter.BIsSelected(" NP_C3 ".W6," NP_C3 ".Pu),npStore=" NP_C2 ".n6,"
"npWindows=!!" NP_C2 ".n6.currentAppFilter.m_filterSpec.notprotonWindows;return(0,"
NP_C4 ".jsxs)(\"div\",{className:" NP_C5 "().Bar,", 1, 0 },
- { "children:[" NP_C1 "&&(0," NP_C2 ".jsxs)(" NP_C3 ".he,{direction:\"top\",nDelayShowMS:240,toolTipContent:" NP_C4
- "?\"#GameList_View_Platform_Linux\":\"#GameList_View_Platform_Apple\",className:(0," NP_C5 ".A)("
- NP_C6 "().CheckboxWithImage," NP_C7 "&&" NP_C6 "().Disabled," NP_C8 "&&" NP_C6 "().Active),onClick:()=>"
- NP_C7 "||" NP_C9 "(" NP_C10 ".W6," NP_C10 ".Pu,!" NP_C8 "),children:[" NP_C4 "&&(0," NP_C2 ".jsx)("
- NP_C11 ".Wy0,{}),!" NP_C4 "&&(0," NP_C2 ".jsx)(" NP_C11 ".kPc,{})]})",
- "children:["
- NP_C1 "&&!" NP_C4 "&&" NP_C11 ".Xz0&&(0," NP_C2 ".jsxs)(" NP_C3 ".he,{direction:\"top\",nDelayShowMS:240,"
- "toolTipContent:" NP_LIBRARY_WINDOWS_HINT ",className:(0," NP_C5 ".A)(" NP_C6 "().CheckboxWithImage,"
- NP_C7 "&&" NP_C6 "().Disabled,npWindows&&" NP_C6 "().Active),onClick:()=>" NP_C7
- "||npStore.SelectCollectionsAppFilterOption(\"notprotonWindows\",null,!npWindows),"
- "children:[(0," NP_C2 ".jsx)(\"style\",{children:\".\"+" NP_C6 "().CheckboxWithImage+"
- "\" .SVGIcon_WindowsLogo{width:13px;height:13px}.\"+" NP_C6 "().CheckboxWithImage+"
- "\" .SVGIcon_WindowsLogo rect{fill:inherit}\"}),(0," NP_C2 ".jsx)(" NP_C11 ".Xz0,{})]}),"
- NP_C1 "&&(0," NP_C2 ".jsxs)(" NP_C3 ".he,{direction:\"top\",nDelayShowMS:240,toolTipContent:" NP_C4
- "?\"#GameList_View_Platform_Linux\":\"#GameList_View_Platform_Apple\",className:(0," NP_C5 ".A)("
- NP_C6 "().CheckboxWithImage," NP_C7 "&&" NP_C6 "().Disabled," NP_C8 "&&" NP_C6 "().Active),onClick:()=>"
- NP_C7 "||" NP_C9 "(" NP_C10 ".W6," NP_C10 ".Pu,!" NP_C8 "),children:[" NP_C4 "&&(0," NP_C2 ".jsx)("
- NP_C11 ".Wy0,{}),!" NP_C4 "&&(0," NP_C2 ".jsx)(" NP_C11 ".kPc,{})]})", 1, 0 },
+ { "children:[" NP_PLATFORM_BUTTON(NP_PLATFORM_TIP), "children:[" NP_WINDOWS_BUTTON "," NP_PLATFORM_BUTTON(NP_PLATFORM_TIP), 1, 0 },
+ // 1792192922 passes the tooltip through Steam's localize call.
+ { "children:[" NP_PLATFORM_BUTTON(NP_LOCALIZED_PLATFORM_TIP),
+ "children:[" NP_WINDOWS_BUTTON "," NP_PLATFORM_BUTTON(NP_LOCALIZED_PLATFORM_TIP), 1, 0 },
};
#define NP_LIBRARY_FILTER_COUNT (sizeof(g_library_filters) / sizeof(g_library_filters[0]))
+// Exactly one of the two toolbar anchors has to match.
+#define NP_LIBRARY_TOOLBAR (NP_LIBRARY_FILTER_COUNT - 2)
+#define NP_LOCALIZED_LIBRARY_TOOLBAR (NP_LIBRARY_FILTER_COUNT - 1)
+
typedef struct {
const char *name;
const char *probe;
@@ -671,9 +678,21 @@ char *np_webpatch_transform(const uint8_t *src, size_t src_len, size_t *out_len,
fix_on[NP_NATIVE_MAC_FILTER_FIX] = fix_on[NP_UPDATED_NATIVE_MAC_FILTER_FIX] = 0;
}
int library_filter = fix_on[NP_NATIVE_MAC_FILTER_FIX] || fix_on[NP_UPDATED_NATIVE_MAC_FILTER_FIX];
- for (size_t g = 0; library_filter && g < NP_LIBRARY_FILTER_COUNT; g++)
- library_filter = count_matches(s, src_len, g_library_filters[g].find) ==
- (size_t)g_library_filters[g].expect;
+ int library_on[NP_LIBRARY_FILTER_COUNT] = {0};
+ for (size_t g = 0; library_filter && g < NP_LIBRARY_FILTER_COUNT; g++) {
+ size_t n = count_matches(s, src_len, g_library_filters[g].find);
+ library_on[g] = n == (size_t)g_library_filters[g].expect;
+ if (library_on[g] || g == NP_LIBRARY_TOOLBAR || g == NP_LOCALIZED_LIBRARY_TOOLBAR) continue;
+ NP_WARN("webpatch: library anchor %zu expected %d occurrence(s), found %zu; "
+ "no Windows filter button", g, g_library_filters[g].expect, n);
+ library_filter = 0;
+ }
+ if (library_filter && library_on[NP_LIBRARY_TOOLBAR] == library_on[NP_LOCALIZED_LIBRARY_TOOLBAR]) {
+ NP_WARN("webpatch: %s; no Windows filter button",
+ library_on[NP_LIBRARY_TOOLBAR] ? "both library toolbar anchors matched"
+ : "no library toolbar anchor matched");
+ library_filter = 0;
+ }
if (!shape && !fix_live) {
free(native_mac_js);
@@ -721,7 +740,7 @@ char *np_webpatch_transform(const uint8_t *src, size_t src_len, size_t *out_len,
for (size_t f = 0; f < NP_FIX_COUNT; f++)
if (fix_on[f]) mark_start(can_start, g_fixes[f].find);
for (size_t g = 0; library_filter && g < NP_LIBRARY_FILTER_COUNT; g++)
- mark_start(can_start, g_library_filters[g].find);
+ if (library_on[g]) mark_start(can_start, g_library_filters[g].find);
for (size_t i = 0; i < src_len; ) {
size_t plain = i;
while (plain < src_len && !can_start[(unsigned char)s[plain]]) plain++;
@@ -743,6 +762,7 @@ char *np_webpatch_transform(const uint8_t *src, size_t src_len, size_t *out_len,
if (used) { hit = &g_fixes[f]; break; }
}
for (size_t g = 0; !hit && library_filter && g < NP_LIBRARY_FILTER_COUNT; g++) {
+ if (!library_on[g]) continue;
used = match_at(s, src_len, i, g_library_filters[g].find, caps);
if (used) { hit = &g_library_filters[g]; break; }
}
diff --git a/dylib/tests/gatecheck.c b/dylib/tests/gatecheck.c
index 2dc53c1..27dacdc 100644
--- a/dylib/tests/gatecheck.c
+++ b/dylib/tests/gatecheck.c
@@ -345,7 +345,7 @@ static int extract_library(const char *chunk, const char *out_path) {
const size_t pad = 160;
np_cap_t caps[NP_CAP_MAX];
- size_t fixes = 0;
+ size_t fixes = 0, toolbars = 0;
for (size_t a = 0; a < NP_LIBRARY_ANCHORS; a++) {
size_t hits = 0;
for (size_t i = 0; i < len; ) {
@@ -359,6 +359,7 @@ static int extract_library(const char *chunk, const char *out_path) {
i += used;
}
if (a >= NP_LIBRARY_FILTER_COUNT) { fixes += hits; continue; }
+ if (a == NP_LIBRARY_TOOLBAR || a == NP_LOCALIZED_LIBRARY_TOOLBAR) { toolbars += hits; continue; }
if (hits != (size_t)library_anchor(a)->expect) {
fprintf(stderr, "library anchor %zu found %zu times in %s\n", a, hits, chunk);
fclose(o); free(buf);
@@ -368,6 +369,7 @@ static int extract_library(const char *chunk, const char *out_path) {
fclose(o);
free(buf);
if (fixes != 1) { fprintf(stderr, "%zu filter fixes in %s\n", fixes, chunk); return 1; }
+ if (toolbars != 1) { fprintf(stderr, "%zu library toolbars in %s\n", toolbars, chunk); return 1; }
printf("extracted fixture to %s\n", out_path);
return 0;
}
@@ -437,6 +439,12 @@ static void check_library(const char *path, const char *out_path, int literal_ve
len = (size_t)(version - (char *)buf) + 1 + tail;
}
+ int present[NP_LIBRARY_FILTER_COUNT];
+ for (size_t g = 0; g < NP_LIBRARY_FILTER_COUNT; g++)
+ present[g] = count_matches((const char *)buf, len, g_library_filters[g].find) != 0;
+ if (present[NP_LIBRARY_TOOLBAR] == present[NP_LOCALIZED_LIBRARY_TOOLBAR])
+ wrong("%s needs exactly one library toolbar", path);
+
g_platform_js = g_test_lists;
size_t out_len = 0;
char *out = library_transform((const char *)buf, len, &out_len);
@@ -452,6 +460,7 @@ static void check_library(const char *path, const char *out_path, int literal_ve
wrong("library anchor %zu survived in %s", a, path);
}
for (size_t g = 0; g < NP_LIBRARY_FILTER_COUNT; g++) {
+ if (!present[g]) continue;
if (count_matches(out, out_len, g_library_filters[g].replace) != (size_t)g_library_filters[g].expect)
wrong("library replacement %zu is missing from %s", g, path);
}
@@ -471,6 +480,7 @@ static void check_library(const char *path, const char *out_path, int literal_ve
g_platform_js = g_test_lists;
np_cap_t caps[NP_CAP_MAX];
for (size_t g = 0; g < NP_LIBRARY_FILTER_COUNT; g++) {
+ if (!present[g]) continue;
char *copy = malloc(len + 1);
if (!copy) { wrong("out of memory"); break; }
memcpy(copy, buf, len + 1);
diff --git a/dylib/tests/library-filter/behavior.js b/dylib/tests/library-filter/behavior.js
index 894b906..16bc69e 100644
--- a/dylib/tests/library-filter/behavior.js
+++ b/dylib/tests/library-filter/behavior.js
@@ -124,7 +124,7 @@ function check(file, name, t) {
t(new Function(`return ${summary[2]}`)() === 'Runs on Windows, no Mac OS version',
'the filter summary names the Windows filter');
- const button = grab(src, /children:\[(([\w$]+)&&!([\w$]+)&&([\w$]+)\.Xz0&&\(0,([\w$]+)\.jsxs\)\(([\w$]+)\.he,\{.*?\(0,\5\.jsx\)\(\4\.Xz0,\{\}\)\]\}\)),\2&&\(0,\5\.jsxs\)\(\6\.he,\{direction:"top",nDelayShowMS:240,toolTipContent:\3\?"#GameList_View_Platform_Linux"/,
+ const button = grab(src, /children:\[(([\w$]+)&&!([\w$]+)&&([\w$]+)\.Xz0&&\(0,([\w$]+)\.jsxs\)\(([\w$]+)\.he,\{.*?\(0,\5\.jsx\)\(\4\.Xz0,\{\}\)\]\}\)),\2&&\(0,\5\.jsxs\)\(\6\.he,\{direction:"top",nDelayShowMS:240,toolTipContent:\3\?(?:\(0,[\w$]+\.we\)\()?"#GameList_View_Platform_Linux"/,
'Windows button before Apple');
const [, expr, shown, linux, icons, rt, tip] = button;
const cls = /className:\(0,([\w$]+)\.A\)\(([\w$]+)\(\)\.CheckboxWithImage,([\w$]+)&&/.exec(expr);
diff --git a/dylib/tests/webpatch-fixtures/library.1792192922.js b/dylib/tests/webpatch-fixtures/library.1792192922.js
new file mode 100644
index 0000000..c71cc46
--- /dev/null
+++ b/dylib/tests/webpatch-fixtures/library.1792192922.js
@@ -0,0 +1,10 @@
+on(Re){this.m_filterSpec.filterGroups[Re].bAcceptUnion=!this.m_filterSpec.filterGroups[Re].bAcceptUnion}MatchesImpl(Re){const ce=this.m_filterSpec.filterGroups;if(!K(ce[C.W6],Te(Re))||!K(ce[C.sc],de(Re))||!K(ce[C.Kr],Ne(Re))||!K(ce[C.bp],xe(Re))||!K(ce[C.Tx],ot(Re))||!K(ce[C.vA],pe(Re))||!K(ce[C.RB],Oe(Re)))return!1;if(this.m_filterSpec.strSearchText){if
+cludes($)||Re.sort_as.includes($)||A(we,$)!==-1)}return!0}Matches(Re){return this.MatchesImpl(Re)}MatchesScoredImpl(Re){const ce=this.m_filterSpec.filterGroups;if(!K(ce[C.W6],Te(Re))||!K(ce[C.sc],de(Re))||!K(ce[C.Kr],Ne(Re))||!K(ce[C.bp],xe(Re))||!K(ce[C.Tx],ot(Re))||!K(ce[C.vA],pe(Re))||!K(ce[C.RB],Oe(Re))||Re.BIsAppBlocked())return 0;if(this.m_filterSp
+ 0;constructor(Re){(0,s.Gn)(this),Re&&(Re.filterGroups[2].rgOptions=Re.filterGroups[2].rgOptions?.filter(ce=>ce!=C.eb)||[]),this.m_filterSpec={nFormatVersion:lt,strSearchText:Re&&Re.strSearchText||"",filterGroups:[P(!0,Re&&Re.filterGroups[0]),P(!1,Re&&Re.filterGroups[1]),P(!1,Re&&Re.filterGroups[2]),P(!1,Re&&Re.filterGroups[3]),P(!1,Re&&Re.filterGroups[4]),P(!1,Re&&Re.fi
+(ce=>ce==Re)}CheckForExclusiveOption(Re,ce){be.forEach($=>{$.group==Re&&$.filters.includes(ce)&&$.filters.forEach(Ye=>{Ye!==ce&&this.SelectOption(Re,Ye,!1)})})}SelectOption(Re,ce,$){let we=this.m_filterSpec.filterGroups[Re].rgOptions;if(Re==C.sc){const He=ce;if(z(He)&&$&&(this.ClearSteamHWCompatOptions(we),He==C.eb))return}Re==C.Tx&&$&&(S.O$.RefreshOwnedGames(ce),(0,x.L)("Library/AddFriendTo
+e.filterGroups[4]),P(!1,Re&&Re.filterGroups[5]),P(!1,Re&&Re.filterGroups[6]),P(!1,Re&&Re.filterGroups[7]),P(!1,Re&&Re.filterGroups[8])],setSuggestions:new Set}}Reset(){this.m_filterSpec.strSearchText="",this.m_filterSpec.filterGroups.forEach(Re=>Re.rgOptions=[])}BIncludesTools(){const Re=this.GetSelectedOptions(C.Wc);return!!Re.find(ce=>ce==n.B7)||Re.length==0}
+)}`)).join(", "));let Qe=this.GetSelectedOptions(C.RB);return Qe.length>0&&Re.push(Qe.map(At=>(0,c.we)(`#Accessibility_Feature_${re(C.RB,At)}`)).join(", ")),Re}get bIsEmpty(){return this.searchText.length==0&&this.m_filterSpec.filterGroups.every(Re=>Re.rgOptions.length==0)}get searchText(){return this.m_filterSpec.strSearchText}SetSearchText(Re){this.m_filterSpec.str
+=this.GetSelectedOptions(C.Wc);$.length>0&&$.length!=ce.length&&Re.push(ce.filter(At=>$.indexOf(At)!==-1).map(At=>(0,c.we)(Jd.LocalizeAppType(At))).join(", "));let we=this.GetSelectedOptions(C.W6);we.length>0&&Re.push(we.map(At=>{if(At==C.Pu){if((0,f.CI)())return(0,c.we)("#FilterElement_ValidPlatform_Linux");if((0,f.Pr)())return(0,c.we)("#FilterElement_ValidPlatform_MacOS")}return(0,c.we)("#FilterEle
+.VQ,Ys=i.n6.bIsGameListSortedByRecent,ra=i.n6.selectedGameListView!=i.GA,Js=i.n6.currentAppFilter.BIsSelected(Qn.W6,Qn.Sr),ca=!ei,ua=!(0,ft.td)(),aa=(0,ft.CI)(),Rs=i.n6.currentAppFilter.BIsSelected(Qn.W6,Qn.Pu);return(0,e.jsxs)("div",{className:Ma().Bar,children:[(0,e.jsx)(an.EN,{active:ss,children:(0,e.jsx)(Nl,{closeModal:ps})}),(0,e.jsxs)("div",{className:Ma().SearchBar,ref:hi,tabIndex:-1,children:[(0,e.jsxs)
+ren:(0,e.jsx)(h.i3G,{angle:0})})]}),(0,e.jsx)("div",{className:Ma().ViewFiltersBar,children:(0,e.jsxs)("div",{className:(0,g.A)(Ma().Filters,fs&&Ma().Disabled),children:[ua&&(0,e.jsxs)(Qe.he,{direction:"top",nDelayShowMS:240,toolTipContent:aa?(0,A.we)("#GameList_View_Platform_Linux"):(0,A.we)("#GameList_View_Platform_Apple"),className:(0,g.A)(Ma().CheckboxWithImage,ra&&Ma().Disabled,Rs&&Ma().Active),onClick:()=>ra||Gl(Qn.W6,Qn.Pu,!Rs),children:[aa&&(0,e.jsx)(h.Wy0,{}),!aa&&(0,e.jsx)(h.kPc,{})]}),(0,e.jsx)(Qe.he,{direction:"top",nDelayShowMS:240,toolTipContent:(0,A.we)("#GameList_View_SortByRecent"),className:(0,g.A)(Ma().CheckboxWithImage,fs&&Ma().Disa
+AppType!=n.em&&We.local_per_client_data&&!!We.local_per_client_data.installed;case C.zW:return We.rt_last_time_played>0;case C.jn:return!We.rt_last_time_played;case C.Pu:return(0,f.CI)()&&!(0,f.mP)()?Se(We):(0,f.td)()?!0:We.is_available_on_current_platform&&!We.is_invalid_os_type;case C.fd:return e.tw.BIsAppPrivate(We.appid);default:return!1}}}function Ne(We){return We.BHasStoreTag}function ot(We){return Re=>S.O$.GetOwnedGames(Re).has(We