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
Fix DPI issues with High Resolution mode
NotProtonNot279167917dc6
diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex 0da1052..30fe947 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -615,12 +615,48 @@ winebus_lines() {printf '%s\r\n' '[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\WineBus]' "$hidraw_value" ''}+# High Resolution doubles LogPixels and turning it off halves it+plan_logpixels() {+ dpi_value=""+ new_dpi=""+ read -r retina_was dpi <<EOF+$({ [ ! -f "$WINEPREFIX/user.reg" ] || tr '[:upper:]' '[:lower:]' < "$WINEPREFIX/user.reg"; } | awk '+ /^\[/ { s = 0+ if (index($0, "[software\\\\wine\\\\mac driver]") == 1) s = 1+ else if (index($0, "[control panel\\\\desktop]") == 1) s = 2+ next }+ s == 1 && $0 ~ /^"retinamode"="[yt1]/ { r = 1 }+ s == 2 && $0 ~ /^"logpixels"=dword:[0-9a-f]+$/ && length($0) <= 26 { d = substr($0, 19) }+ END { print r + 0, d }')+EOF+ [ -n "$dpi" ] || [ ! -f "$WINEPREFIX/system.reg" ] || dpi=$(tr '[:upper:]' '[:lower:]' < "$WINEPREFIX/system.reg" \+ | awk '/^\[/ { s = index($0, "[system\\\\controlset001\\\\hardware profiles\\\\current\\\\software\\\\fonts]") == 1; next }+ s && $0 ~ /^"logpixels"=dword:[0-9a-f]+$/ && length($0) <= 26 { print substr($0, 19); exit }')+ dpi=$((0x${dpi:-0}))+ [ "$dpi" -gt 0 ] || dpi=96+ if [ "$NOTPROTON_RETINA" = "1" ]; then+ [ "$retina_was" = 1 ] && [ "$dpi" -ge 110 ] || [ "$dpi" -gt 2147483647 ] || new_dpi=$((dpi * 2))+ elif [ "$retina_was" = 1 ]; then+ new_dpi=$((dpi / 2))+ [ "$new_dpi" -ge 96 ] || new_dpi=96+ fi+ [ -z "$new_dpi" ] || [ "$new_dpi" -eq "$dpi" ] || dpi_value=$(printf '"LogPixels"=dword:%08x' "$new_dpi")+}++video_lines() {+ [ "$verb" = waitforexitandrun ] || return 0+ printf '%s\r\n' '[HKEY_CURRENT_USER\Software\Wine\Mac Driver]' "$retina_line" ''+ [ -n "$dpi_value" ] || return 0+ printf '%s\r\n' '[HKEY_CURRENT_USER\Control Panel\Desktop]' "$dpi_value" ''+}+import_prefix_settings() {if [ "$NOTPROTON_RETINA" = "1" ]; thenretina_line='"RetinaMode"="y"'elseretina_line='"RetinaMode"=-'fi+ dpi_value=""controllers_planned=0if plan_hidden_controllers 2>/dev/null; thencontrollers_planned=1@@ -639,6 +675,10 @@ import_prefix_settings() {hidraw_value=""echo "=== could not track DisableHidraw, leaving it as it is ===" >> "$log" 2>&1 || truefi+ # Steam sends install scripts no launch options, so they keep the game's video settings.+ if [ "$verb" = waitforexitandrun ]; then+ plan_logpixels 2>/dev/null || dpi_value=""+ fisettings_file=$(mktemp "$WINEPREFIX/drive_c/notproton-settings.XXXXXX" 2>/dev/null) \|| settings_file=""if [ -z "$settings_file" ] || ! { printf '%s\r\n' \@@ -646,7 +686,7 @@ import_prefix_settings() {'[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug]' '"Auto"="0"' '' \'[HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug]' '"Auto"="0"' '' \'[HKEY_CURRENT_USER\Software\Wine\WineDbg]' '"ShowCrashDialog"=dword:00000000' '' \- '[HKEY_CURRENT_USER\Software\Wine\Mac Driver]' "$retina_line" '' \+ && video_lines && printf '%s\r\n' \'[HKEY_LOCAL_MACHINE\Software\Classes\steam]' '"URL Protocol"=""' '' \'[HKEY_LOCAL_MACHINE\Software\Classes\steam\shell\open\command]' \'@="\"C:\\Program Files (x86)\\Steam\\steam.exe\" \"%1\""' '' \@@ -665,7 +705,7 @@ import_prefix_settings() {if [ "$import_status" -eq 0 ] && [ "$hidraw_planned" -eq 1 ] && [ "$NOTPROTON_DISABLE_HIDRAW" != "1" ]; thenrm -f "$hidraw_file"fi- if [ "$import_status" -eq 0 ] && [ -n "$controllers_add$controllers_remove$hidraw_value" ]; then+ if [ "$import_status" -eq 0 ] && [ -n "$controllers_add$controllers_remove$hidraw_value$dpi_value" ]; then# Wine only reads these keys when it starts, so restart Wine to apply them.without_lock_fds "$WINESERVER" -k >> "$log" 2>&1 || truewithout_lock_fds "$WINESERVER" -w >> "$log" 2>&1 || true@@ -673,6 +713,9 @@ import_prefix_settings() {if [ "$import_status" -eq 0 ] && [ "$hidraw_planned" -eq 1 ] && [ "$NOTPROTON_DISABLE_HIDRAW" = "1" ]; thenecho "controllers: hidraw disabled (NOTPROTON_DISABLE_HIDRAW=1)" >> "$log" 2>&1 || truefi+ if [ "$import_status" -eq 0 ] && [ -n "$dpi_value" ]; then+ echo "video: LogPixels=$new_dpi" >> "$log" 2>&1 || true+ fiif [ "$import_status" -eq 0 ] && [ "$controllers_planned" -eq 1 ]; thenwrite_owned_controllers "$controllers_wanted" 2>/dev/null || trueif [ "$NOTPROTON_RAW_CONTROLLERS" = "1" ]; then@@ -1137,7 +1180,7 @@ if [ -n "$STEAM_COMPAT_DATA_PATH" ]; thenshow_alert "Saved-game folders need attention" "NotProton left the conflicting files in place. Open this prefix's notproton-run.log for details before trying again."exit 1fi- echo "video: RetinaMode=${NOTPROTON_RETINA:-0}" >> "$log" 2>&1 || true+ [ "$verb" != waitforexitandrun ] || echo "video: RetinaMode=${NOTPROTON_RETINA:-0}" >> "$log" 2>&1 || truestage_step="game drive"map_game_drivestage_step="prefix settings"diff --git a/dylib/tests/settingscheck.sh b/dylib/tests/settingscheck.shindex b9b1c14..b567a03 100644--- a/dylib/tests/settingscheck.sh+++ b/dylib/tests/settingscheck.sh@@ -10,7 +10,7 @@ wrapper=$(sed -n '/^without_lock_fds() {$/,/^}$/p' "$SRC")[ -n "$wrapper" ] || { echo "FAIL: without_lock_fds not found in $SRC"; exit 1; }helpers=""for helper in controller_ids ids_without hidraw_lines write_owned_controllers plan_hidden_controllers \- plan_disable_hidraw winebus_lines; do+ plan_disable_hidraw winebus_lines plan_logpixels video_lines; dopart=$(sed -n "/^$helper() {\$/,/^}\$/p" "$SRC")[ -n "$part" ] || { echo "FAIL: $helper not found in $SRC"; exit 1; }helpers="$helpers@@ -39,14 +39,16 @@ settings() {printf '%s\r\n' 'Windows Registry Editor Version 5.00' '' \'[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug]' '"Auto"="0"' '' \'[HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug]' '"Auto"="0"' '' \- '[HKEY_CURRENT_USER\Software\Wine\WineDbg]' '"ShowCrashDialog"=dword:00000000' '' \- '[HKEY_CURRENT_USER\Software\Wine\Mac Driver]' "$1" '' \- '[HKEY_LOCAL_MACHINE\Software\Classes\steam]' '"URL Protocol"=""' '' \+ '[HKEY_CURRENT_USER\Software\Wine\WineDbg]' '"ShowCrashDialog"=dword:00000000' ''+ [ -z "$1" ] || printf '%s\r\n' '[HKEY_CURRENT_USER\Software\Wine\Mac Driver]' "$1" ''+ [ -z "$2" ] || printf '%s\r\n' '[HKEY_CURRENT_USER\Control Panel\Desktop]' "\"LogPixels\"=dword:$2" ''+ printf '%s\r\n' '[HKEY_LOCAL_MACHINE\Software\Classes\steam]' '"URL Protocol"=""' '' \'[HKEY_LOCAL_MACHINE\Software\Classes\steam\shell\open\command]' \'@="\"C:\\Program Files (x86)\\Steam\\steam.exe\" \"%1\""' ''}settings '"RetinaMode"=-' > "$work/retina-off"settings '"RetinaMode"="y"' > "$work/retina-on"+settings '' > "$work/helper"fails=0ok() { printf ' ok %s\n' "$1"; }@@ -97,7 +99,8 @@ is "a clean import only logs the controller count" "controllers: 3 kept off hidris "the launch carries on" returned "$(cat "$case_dir/out")"launch 1 0-same_file "Retina on sets RetinaMode to y" "$work/retina-on" "$case_dir/imported"+settings '"RetinaMode"="y"' 000000c0 > "$work/expected"+same_file "Retina on sets RetinaMode to y and doubles LogPixels" "$work/expected" "$case_dir/imported"launch 0 0same_file "Retina off deletes RetinaMode" "$work/retina-off" "$case_dir/imported"@@ -191,12 +194,12 @@ in_registry 054c/0ce6 057e/2006 057e/2007 057e/2009printf '%s\n' 054c/0ce6 057e/2006 057e/2007 057e/2009 > "$case_dir/notproton-hidden-controllers"IGNORE='' EXCEPT='' RAW='' VERB=runagain "" 0-same_file "a helper with no list keeps the hidden controllers" "$work/retina-off" "$case_dir/imported"+same_file "a helper with no list keeps the hidden controllers" "$work/helper" "$case_dir/imported"is "a helper does not restart the prefix" "reg import C:\\notproton-settings.X" "$(calls)"is "a helper keeps them tracked" "054c/0ce6 057e/2006 057e/2007 057e/2009" "$(owned)"IGNORE='' EXCEPT='' RAW='1' VERB=runagain "" 0-{ cat "$work/retina-off"; shown 054c/0ce6; shown 057e/2006; shown 057e/2007; shown 057e/2009; } > "$work/expected"+{ cat "$work/helper"; shown 054c/0ce6; shown 057e/2006; shown 057e/2007; shown 057e/2009; } > "$work/expected"same_file "NOTPROTON_RAW_CONTROLLERS=1 still clears them in a helper" "$work/expected" "$case_dir/imported"in_registry 054c/0ce6 057e/2006 057e/2007 057e/2009printf '%s\n' 054c/0ce6 057e/2006 057e/2007 057e/2009 > "$case_dir/notproton-hidden-controllers"@@ -231,6 +234,33 @@ again "" 0same_file "off" "$work/expected" "$case_dir/imported"unset HIDRAW+echo "== LogPixels"+user_reg() { printf '%s\n' '[Software\\Wine\\Mac Driver] 1791230000' "$1" '' '[Control Panel\\Desktop] 1791230000' "$2" '' > "$case_dir/pfx/user.reg"; }+new_case+in_registry 057e/2006 057e/2007 057e/2009+printf '%s\n' 057e/2006 057e/2007 057e/2009 > "$case_dir/notproton-hidden-controllers"+user_reg '"RetinaMode"="y"' '"LogPixels"=dword:000000c0'+again 1 0+same_file "already on" "$work/retina-on" "$case_dir/imported"+again 0 0+settings '"RetinaMode"=-' 00000060 > "$work/expected"+same_file "off halves it" "$work/expected" "$case_dir/imported"+is "off restarts the prefix" "wineserver -w" "$(calls | tail -1)"+is "off is logged" "video: LogPixels=96" "$(grep video "$case_dir/log")"+user_reg '"RetinaMode"="y"' ''+printf '%s\n' '[System\\ControlSet001\\Hardware Profiles\\Current\\Software\\Fonts] 1791230000' '"LogPixels"=dword:00000060' '' >> "$case_dir/pfx/system.reg"+again 1 0+settings '"RetinaMode"="y"' 000000c0 > "$work/expected"+same_file "on at 96 doubles it" "$work/expected" "$case_dir/imported"+user_reg '"RetinaMode"="y"' '"LogPixels"=dword:00000060'+again 0 0+same_file "off at 96 stays 96" "$work/retina-off" "$case_dir/imported"+user_reg '"RetinaMode"="y"' '"LogPixels"=dword:000000c0'+VERB=run+again "" 0+same_file "a helper leaves them alone" "$work/helper" "$case_dir/imported"+unset VERB+if [ "$fails" -eq 0 ]; thenecho "==> settingscheck: all assertions hold"else