Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aca8ec5588
|
||
|
|
34c053c758
|
||
|
|
eebb274b9c
|
No files matched your search
@@ -1,17 +1,19 @@
|
||||
name: Build native binaries on Debian 11
|
||||
name: Build vk_gpu_info on Debian 11
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- scripts
|
||||
paths:
|
||||
- 'build-aux/src/**'
|
||||
- 'build-aux/src/vk_gpu_info.c'
|
||||
- 'build-aux/src/wine_gpu_names.h'
|
||||
- '.gitea/workflows/build-vk-gpu-info-debian.yml'
|
||||
|
||||
jobs:
|
||||
build-debian11:
|
||||
name: Build native binaries on Debian 11
|
||||
name: Build vk_gpu_info on Debian 11
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: debian:11
|
||||
@@ -20,13 +22,8 @@ jobs:
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
set -- build-essential cmake pkg-config libvulkan-dev libwayland-dev libx11-dev git curl wget nodejs npm
|
||||
if ! (apt-get update -o APT::Update::Error-Mode=any && apt-get install -y "$@"); then
|
||||
echo 'APT failed; retrying with security.debian.org for bullseye-security.'
|
||||
sed -i '/^[[:space:]]*deb .* bullseye-security /s|http://deb.debian.org/debian-security|http://security.debian.org/debian-security|' /etc/apt/sources.list &&
|
||||
apt-get update -o APT::Update::Error-Mode=any &&
|
||||
apt-get install -y "$@"
|
||||
fi
|
||||
apt-get update
|
||||
apt-get install -y build-essential pkg-config libvulkan-dev git curl wget nodejs npm
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: https://git.linux-gaming.ru/actions/setup-node@v2
|
||||
@@ -35,46 +32,26 @@ jobs:
|
||||
|
||||
- name: Checkout code
|
||||
uses: https://git.linux-gaming.ru/actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ gitea.ref }}
|
||||
token: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Build SDL3 for linking
|
||||
- name: Compile vk_gpu_info
|
||||
run: |
|
||||
# SDL 3.2.10 is not available in Debian 11. Only the backends are shipped.
|
||||
sdl_commit=877399b2b2cf21e67554ed9046410f268ce1d1b2
|
||||
curl --fail --location --max-time 120 \
|
||||
"https://codeload.github.com/libsdl-org/SDL/tar.gz/${sdl_commit}" -o /tmp/sdl3.tar.gz
|
||||
mkdir -p /tmp/sdl3-src
|
||||
tar -xzf /tmp/sdl3.tar.gz -C /tmp/sdl3-src --strip-components=1
|
||||
cmake -S /tmp/sdl3-src -B /tmp/sdl3-build \
|
||||
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/sdl3 \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib -DSDL_UNIX_CONSOLE_BUILD=ON \
|
||||
-DSDL_SHARED=ON -DSDL_STATIC=OFF -DSDL_TEST_LIBRARY=OFF
|
||||
cmake --build /tmp/sdl3-build --parallel "$(nproc)"
|
||||
cmake --install /tmp/sdl3-build
|
||||
|
||||
- name: Compile native binaries
|
||||
run: |
|
||||
export PKG_CONFIG_PATH="/tmp/sdl3/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
|
||||
mkdir -p build-aux/bin build-aux/lib
|
||||
gcc -std=c99 -o build-aux/bin/vk_gpu_info build-aux/src/vk_gpu_info.c -lvulkan
|
||||
gcc -shared -fPIC -Wl,-z,defs -o build-aux/lib/libportprotonqt_gamepad.so \
|
||||
build-aux/src/gamepad_backend.c $(pkg-config --cflags --libs sdl3)
|
||||
gcc -shared -fPIC -Wl,-z,defs -o build-aux/lib/libportprotonqt_keyboard.so \
|
||||
build-aux/src/keyboard_backend.c $(pkg-config --cflags --libs wayland-client x11)
|
||||
mkdir -p build-aux/bin
|
||||
gcc -o build-aux/bin/vk_gpu_info build-aux/src/vk_gpu_info.c -lvulkan
|
||||
|
||||
- name: Test vk_gpu_info execution
|
||||
run: |
|
||||
test -x build-aux/bin/vk_gpu_info
|
||||
timeout 10s build-aux/bin/vk_gpu_info || echo "Vulkan smoke test failed; CI may lack a Vulkan device."
|
||||
# Check if the executable was created
|
||||
if [ -f "build-aux/bin/vk_gpu_info" ]; then
|
||||
echo "vk_gpu_info executable created successfully"
|
||||
# Try to run it (may fail if no Vulkan devices present, but that's OK for build test)
|
||||
timeout 10s build-aux/bin/vk_gpu_info || echo "vk_gpu_info ran but may have failed due to lack of Vulkan hardware (expected in CI)"
|
||||
else
|
||||
echo "ERROR: vk_gpu_info executable was not created"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Upload native binaries
|
||||
- name: Upload vk_gpu_info binary
|
||||
uses: https://git.linux-gaming.ru/actions/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: native-binaries-debian11
|
||||
path: |
|
||||
build-aux/bin/vk_gpu_info
|
||||
build-aux/lib/libportprotonqt_gamepad.so
|
||||
build-aux/lib/libportprotonqt_keyboard.so
|
||||
if-no-files-found: error
|
||||
name: vk_gpu_info-debian11-binary
|
||||
path: build-aux/bin/vk_gpu_info
|
||||
@@ -46,6 +46,7 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
- Исправлено неполное меню PortProtonQt в системном трее Budgie
|
||||
- Обложки заполняют отведённую область без растягивания
|
||||
- Исправлена загрузка оценок времени прохождения с HowLongToBeat в карточках игр
|
||||
- При нажатии вниз на D-pad с верхней панели библиотеки фокус переходит на первую карточку верхнего ряда, а не перескакивает на нижние ряды
|
||||
|
||||
@@ -2464,8 +2464,9 @@ pw_specialk_set_ini_value () {
|
||||
[[ -f "$ini_file" ]] && sed -i '/./,$!d' "$ini_file"
|
||||
|
||||
if grep -q "^\[$section\]" "$ini_file" ; then
|
||||
if sed -n "/^\[$section\]/,/^\[/{p}" "$ini_file" | grep -q "^$key=" ; then
|
||||
sed -i "/^\[$section\]/,/^\[/{s/^$key=.*/$key=$value/}" "$ini_file"
|
||||
if sed -n "/^\[$section\]/,/^\[/{p}" "$ini_file" \
|
||||
| grep -q "^[[:space:]]*$key[[:space:]]*=" ; then
|
||||
sed -i "/^\[$section\]/,/^\[/{s/^[[:space:]]*$key[[:space:]]*=.*/$key=${value//\//\\/}/}" "$ini_file"
|
||||
else
|
||||
sed -i "/^\[$section\]/a $key=$value" "$ini_file"
|
||||
fi
|
||||
@@ -2558,6 +2559,187 @@ pw_specialk_sync_files () {
|
||||
|
||||
}
|
||||
|
||||
pw_reshade_sync_files () {
|
||||
local root="${PW_PLUGINS_PATH}/reshade_windows" runtime detect arch dll highest ogl vulkan source
|
||||
local manifest_reg package installed installed_arch installed_version extract_dir reshade_exe reshade_font font_win screenshot_path backup
|
||||
local PATH_TO_GAME="${PATH_TO_GAME:-}"
|
||||
runtime="$root/reshade/${PW_RESHADE_VER}_Addon"
|
||||
reshade_exe="${PW_RESHADE_EXE:-$PW_EXE_FILE}"
|
||||
if [[ ! -f "$reshade_exe" ]] ; then
|
||||
print_warning "ReShade executable not found: $reshade_exe. Using $PW_EXE_FILE."
|
||||
reshade_exe="$PW_EXE_FILE"
|
||||
fi
|
||||
if [[ "$PW_USE_RESHADE" == 1 ]] ; then
|
||||
detect=$(python_module graphics_detector "$reshade_exe")
|
||||
file "$reshade_exe" | grep -qE 'x86-64|PE32\+' && arch=64 || arch=32
|
||||
highest=$(echo "$detect" | grep '^HIGHEST_DX=' | cut -d= -f2)
|
||||
ogl=$(echo "$detect" | grep '^USES_OGL=' | cut -d= -f2)
|
||||
vulkan=$(echo "$detect" | grep '^USES_VULKAN=' | cut -d= -f2)
|
||||
source=$(echo "$detect" | grep '^SOURCE=' | cut -d= -f2-)
|
||||
[[ "${source##*/}" == UnityPlayer.dll && "$highest" != None ]] && vulkan=false
|
||||
fi
|
||||
if [[ -n "$PW_RESHADE_EXE" ]] ; then
|
||||
PATH_TO_GAME="$(dirname "$(realpath "$reshade_exe")")"
|
||||
fi
|
||||
if [[ "$PW_USE_RESHADE" == 1 ]] \
|
||||
&& [[ ! -f "$runtime/ReShade32.dll" || ! -f "$runtime/ReShade32.json" \
|
||||
|| ! -f "$runtime/ReShade64.dll" || ! -f "$runtime/ReShade64.json" ]] ; then
|
||||
try_download "https://reshade.me/downloads/ReShade_Setup_${PW_RESHADE_VER}_Addon.exe" \
|
||||
"${PORT_DATA_PATH}/data/tmp/ReShade_Setup_${PW_RESHADE_VER}_Addon.exe"
|
||||
create_new_dir "$runtime"
|
||||
unpack "${PORT_DATA_PATH}/data/tmp/ReShade_Setup_${PW_RESHADE_VER}_Addon.exe" \
|
||||
"$runtime" silent || fatal "Failed to extract ReShade."
|
||||
try_remove_file "${PORT_DATA_PATH}/data/tmp/ReShade_Setup_${PW_RESHADE_VER}_Addon.exe"
|
||||
fi
|
||||
if [[ "$PW_USE_RESHADE" == 1 && ! -f "$root/d3dcompiler_47.dll" ]] ; then
|
||||
try_download "https://github.com/itsOwen/LetMeReShade/releases/download/LetMeReShade_Binaries/d3dcompiler_47.dll" "$root/d3dcompiler_47.dll"
|
||||
fi
|
||||
if [[ "$PW_USE_RESHADE" == 1 && ! -f "$root/d3d8.dll" ]] ; then
|
||||
try_download "https://github.com/crosire/d3d8to9/releases/download/v${PW_D3D8TO9_VER}/d3d8.dll" "$root/d3d8.dll"
|
||||
fi
|
||||
if [[ "$PW_USE_RESHADE" == 1 && ! -d "$root/shaders/Shaders" ]] ; then
|
||||
try_remove_dir "$root/shaders"
|
||||
create_new_dir "$root/shaders/Shaders"
|
||||
create_new_dir "$root/shaders/Textures"
|
||||
for package in reshade_shaders sweetfx_shaders immerse_shaders astrayfx_shaders prod80_shaders retroarch_shaders ; do
|
||||
extract_dir="${PORT_DATA_PATH}/data/tmp/$package"
|
||||
if [[ "$package" == immerse_shaders ]] ; then
|
||||
try_download "https://github.com/martymcmodding/iMMERSE/archive/refs/heads/main.tar.gz" \
|
||||
"${PORT_DATA_PATH}/data/tmp/${package}.tar.gz"
|
||||
else
|
||||
try_download "https://github.com/itsOwen/LetMeReShade/releases/download/LetMeReShade_Binaries/${package}.tar.gz" \
|
||||
"${PORT_DATA_PATH}/data/tmp/${package}.tar.gz"
|
||||
fi
|
||||
try_remove_dir "$extract_dir"
|
||||
create_new_dir "$extract_dir"
|
||||
unpack "${PORT_DATA_PATH}/data/tmp/${package}.tar.gz" "$extract_dir" \
|
||||
silent || fatal "Failed to extract $package."
|
||||
find "$extract_dir" -type d -iname Shaders -exec cp -rf '{}/.' "$root/shaders/Shaders/" \;
|
||||
find "$extract_dir" -type d -iname Textures -exec cp -rf '{}/.' "$root/shaders/Textures/" \;
|
||||
try_remove_dir "$extract_dir"
|
||||
try_remove_file "${PORT_DATA_PATH}/data/tmp/${package}.tar.gz"
|
||||
done
|
||||
fi
|
||||
if [[ "$PW_USE_RESHADE" == 1 && "$vulkan" == true ]] ; then
|
||||
dll="Vulkan${arch}"
|
||||
elif [[ "$PW_USE_RESHADE" == 1 ]] ; then
|
||||
case "$highest" in
|
||||
"DirectX 10"|"DirectX 11"|"DirectX 12") dll=dxgi.dll ;;
|
||||
"DirectX 8"|"DirectX 9") dll=d3d9.dll ;;
|
||||
"DirectDraw") return 0 ;;
|
||||
*) [[ "$ogl" == true ]] && dll=opengl32.dll || dll=dxgi.dll ;;
|
||||
esac
|
||||
fi
|
||||
case "$PW_RESHADE_API" in
|
||||
vulkan) vulkan=true; dll="Vulkan${arch}" ;;
|
||||
dxgi.dll|d3d9.dll|opengl32.dll) vulkan=false; dll="$PW_RESHADE_API" ;;
|
||||
esac
|
||||
if [[ -f "$PATH_TO_GAME/reshade_version" ]] \
|
||||
&& { [[ "$PW_USE_RESHADE" != 1 ]] \
|
||||
|| [[ "$(<"$PATH_TO_GAME/reshade_version")" != "${PW_RESHADE_VER}_Addon"$'\n'"$dll" ]]; } ; then
|
||||
installed_version=$(sed -n '1p' "$PATH_TO_GAME/reshade_version")
|
||||
installed=$(sed -n '2p' "$PATH_TO_GAME/reshade_version")
|
||||
if [[ "$installed" == Vulkan32 || "$installed" == Vulkan64 ]] ; then
|
||||
installed_arch=${installed#Vulkan}
|
||||
manifest_reg="Z:${root//\//\\}\\reshade\\${installed_version}\\ReShade${installed_arch}.json"
|
||||
manifest_reg=${manifest_reg//\\/\\\\\\\\}
|
||||
get_and_set_reg_file --delete 'Software\Khronos\Vulkan\ImplicitLayers' \
|
||||
"$manifest_reg" "" "" user
|
||||
if [[ "$installed_arch" == 32 ]] ; then
|
||||
get_and_set_reg_file --delete 'Software\Wow6432Node\Khronos\Vulkan\ImplicitLayers' \
|
||||
"$manifest_reg" "" "" system
|
||||
else
|
||||
get_and_set_reg_file --delete 'Software\Khronos\Vulkan\ImplicitLayers' \
|
||||
"$manifest_reg" "" "" system
|
||||
fi
|
||||
fi
|
||||
try_remove_file "$PATH_TO_GAME/$installed"
|
||||
if [[ -L "$PATH_TO_GAME/${installed}.b" \
|
||||
&& $(readlink -f "$PATH_TO_GAME/${installed}.b") == "$root/reshade/"* ]] ; then
|
||||
unlink "$PATH_TO_GAME/${installed}.b"
|
||||
fi
|
||||
[[ -e "$PATH_TO_GAME/${installed}.b" ]] \
|
||||
&& mv -f "$PATH_TO_GAME/${installed}.b" "$PATH_TO_GAME/$installed"
|
||||
[[ -L "$PATH_TO_GAME/d3dcompiler_47.dll" ]] && unlink "$PATH_TO_GAME/d3dcompiler_47.dll"
|
||||
[[ -L "$PATH_TO_GAME/d3d8.dll" ]] && unlink "$PATH_TO_GAME/d3d8.dll"
|
||||
[[ -e "$PATH_TO_GAME/d3d8.dll.b" ]] \
|
||||
&& mv -f "$PATH_TO_GAME/d3d8.dll.b" "$PATH_TO_GAME/d3d8.dll"
|
||||
[[ -L "$PATH_TO_GAME/ReShade_shaders" ]] && unlink "$PATH_TO_GAME/ReShade_shaders"
|
||||
try_remove_file "$PATH_TO_GAME/ReShade.ini"
|
||||
try_remove_file "$PATH_TO_GAME/ReShadePreset.ini"
|
||||
try_remove_file "$PATH_TO_GAME/ReShade.log"
|
||||
try_remove_file "$PATH_TO_GAME/reshade_version"
|
||||
fi
|
||||
[[ "$PW_USE_RESHADE" != 1 ]] && return 0
|
||||
[[ -L "$PATH_TO_GAME/ReShade_shaders" ]] && unlink "$PATH_TO_GAME/ReShade_shaders"
|
||||
try_force_link_dir "$root/shaders" "$PATH_TO_GAME/ReShade_shaders"
|
||||
pw_specialk_set_ini_value "$PATH_TO_GAME/ReShade.ini" "GENERAL" "EffectSearchPaths" '.\\ReShade_shaders\\Shaders'
|
||||
pw_specialk_set_ini_value "$PATH_TO_GAME/ReShade.ini" "GENERAL" "TextureSearchPaths" '.\\ReShade_shaders\\Textures'
|
||||
if [[ -n "$PW_RESHADE_FONT" ]] ; then
|
||||
reshade_font=$(fc-match --format='%{file}' "$PW_RESHADE_FONT")
|
||||
else
|
||||
reshade_font=/usr/share/fonts/ttf/dejavu/DejaVuSans.ttf
|
||||
fi
|
||||
if [[ -f "$reshade_font" ]] ; then
|
||||
local reshade_prefix="${1:-${WINEPREFIX:-}}" font_dir font_name
|
||||
font_dir="$reshade_prefix/drive_c/PortProton/reshade-fonts"
|
||||
# Keep the symlink target inside the prefix so the container can read it.
|
||||
if [[ -n "$reshade_prefix" ]] \
|
||||
&& font_name=$(sha256sum < "$reshade_font") \
|
||||
&& mkdir -p -- "$font_dir/files" ; then
|
||||
font_name="${font_name%% *}.font"
|
||||
if { cmp -s -- "$reshade_font" "$font_dir/files/$font_name" \
|
||||
|| try_copy_file "$reshade_font" "$font_dir/files/$font_name"; } \
|
||||
&& ln -sfnT -- "files/$font_name" "$font_dir/$font_name" ; then
|
||||
font_win="C:/PortProton/reshade-fonts/$font_name"
|
||||
pw_specialk_set_ini_value "$PATH_TO_GAME/ReShade.ini" "STYLE" "Font" "$font_win"
|
||||
pw_specialk_set_ini_value "$PATH_TO_GAME/ReShade.ini" "STYLE" "EditorFont" "$font_win"
|
||||
else
|
||||
print_warning "Could not stage ReShade font: $reshade_font"
|
||||
fi
|
||||
else
|
||||
print_warning "Could not prepare ReShade font directory: $font_dir"
|
||||
fi
|
||||
elif [[ -n "$PW_RESHADE_FONT" ]] ; then
|
||||
print_warning "ReShade font not found: $PW_RESHADE_FONT"
|
||||
fi
|
||||
screenshot_path='.\\'
|
||||
if [[ -n "$PW_RESHADE_SCREENSHOT_PATH" ]] ; then
|
||||
create_new_dir "$PW_RESHADE_SCREENSHOT_PATH"
|
||||
screenshot_path="Z:${PW_RESHADE_SCREENSHOT_PATH//\//\\\\}"
|
||||
fi
|
||||
pw_specialk_set_ini_value "$PATH_TO_GAME/ReShade.ini" "INPUT" "KeyScreenshot" "$PW_RESHADE_SCREENSHOT_KEY"
|
||||
pw_specialk_set_ini_value "$PATH_TO_GAME/ReShade.ini" "INPUT" "KeyOverlay" "$PW_RESHADE_OVERLAY_KEY"
|
||||
pw_specialk_set_ini_value "$PATH_TO_GAME/ReShade.ini" "SCREENSHOT" "SavePath" "$screenshot_path"
|
||||
if [[ "$vulkan" == true ]] ; then
|
||||
manifest_reg="Z:${runtime//\//\\}\\ReShade${arch}.json"
|
||||
manifest_reg=${manifest_reg//\\/\\\\\\\\}
|
||||
get_and_set_reg_file --add 'Software\Khronos\Vulkan\ImplicitLayers' "$manifest_reg" REG_DWORD 0 user
|
||||
if [[ "$arch" == 32 ]] ; then
|
||||
get_and_set_reg_file --add 'Software\Wow6432Node\Khronos\Vulkan\ImplicitLayers' "$manifest_reg" REG_DWORD 0 system
|
||||
else
|
||||
get_and_set_reg_file --add 'Software\Khronos\Vulkan\ImplicitLayers' "$manifest_reg" REG_DWORD 0 system
|
||||
fi
|
||||
var_winedlloverride_update "vulkan-1=n,b"
|
||||
printf '%s\n%s\n' "${PW_RESHADE_VER}_Addon" "$dll" > "$PATH_TO_GAME/reshade_version"
|
||||
return 0
|
||||
fi
|
||||
[[ ! -f "$PATH_TO_GAME/reshade_version" \
|
||||
&& -e "$PATH_TO_GAME/$dll" && ! -e "$PATH_TO_GAME/${dll}.b" \
|
||||
&& ( ! -L "$PATH_TO_GAME/$dll" \
|
||||
|| $(readlink -f "$PATH_TO_GAME/$dll") != "$root/reshade/"* ) ]] \
|
||||
&& mv -f "$PATH_TO_GAME/$dll" "$PATH_TO_GAME/${dll}.b"
|
||||
try_force_link_file "$runtime/ReShade${arch}.dll" "$PATH_TO_GAME/$dll"
|
||||
try_force_link_file "$root/d3dcompiler_47.dll" "$PATH_TO_GAME/d3dcompiler_47.dll"
|
||||
var_winedlloverride_update "d3dcompiler_47=n;${dll%.*}=n,b"
|
||||
if [[ "$highest" == "DirectX 8" && "$dll" == d3d9.dll ]] ; then
|
||||
[[ -e "$PATH_TO_GAME/d3d8.dll" && ! -e "$PATH_TO_GAME/d3d8.dll.b" ]] && mv -f "$PATH_TO_GAME/d3d8.dll" "$PATH_TO_GAME/d3d8.dll.b"
|
||||
try_force_link_file "$root/d3d8.dll" "$PATH_TO_GAME/d3d8.dll"
|
||||
var_winedlloverride_update "d3d8=n,b"
|
||||
fi
|
||||
printf '%s\n%s\n' "${PW_RESHADE_VER}_Addon" "$dll" > "$PATH_TO_GAME/reshade_version"
|
||||
}
|
||||
|
||||
pw_prepare_gamescope_launch () {
|
||||
[[ "$PW_USE_NATIVE_WAYLAND" == "1" ]] && export PW_GAMESCOPE="0"
|
||||
|
||||
@@ -2993,6 +3175,7 @@ start_portproton () {
|
||||
|
||||
pw_optiscaler_sync_files
|
||||
pw_specialk_sync_files
|
||||
pw_reshade_sync_files
|
||||
|
||||
if [[ "${PW_USE_RAY_TRACING}" == "1" ]] ; then
|
||||
var_vkd3d_config_update dxr
|
||||
@@ -4118,7 +4301,6 @@ steamplay_launch () {
|
||||
|
||||
pw_optiscaler_sync_files
|
||||
pw_specialk_sync_files
|
||||
|
||||
PORT_WINE_PREFIX="$STEAM_COMPAT_DATA_PATH/pfx"
|
||||
|
||||
pw_prepare_gamescope_launch
|
||||
@@ -4184,6 +4366,8 @@ steamplay_launch () {
|
||||
fi
|
||||
fi
|
||||
|
||||
pw_reshade_sync_files "$PORT_WINE_PREFIX"
|
||||
|
||||
# Winetricks
|
||||
if [[ -n "${PW_DLL_INSTALL:-}" ]] ; then
|
||||
update_winetricks
|
||||
@@ -4431,7 +4615,9 @@ gui_edit_db () {
|
||||
KEY_EDIT_DB_GUI=$RANDOM
|
||||
DISABLE_EDIT_DB_LIST=""
|
||||
PW_EDIT_DB_LIST=(PW_MANGOHUD PW_MANGOHUD_USER_CONF PW_VKBASALT PW_VKBASALT_USER_CONF
|
||||
PW_VKBASALT_EFFECTS PW_VKBASALT_FFX_CAS PW_DGVOODOO2 PW_USE_SPECIALK
|
||||
PW_VKBASALT_EFFECTS PW_VKBASALT_FFX_CAS PW_DGVOODOO2 PW_USE_SPECIALK PW_USE_RESHADE
|
||||
PW_RESHADE_EXE PW_RESHADE_API PW_RESHADE_FONT PW_RESHADE_SCREENSHOT_PATH
|
||||
PW_RESHADE_SCREENSHOT_KEY PW_RESHADE_OVERLAY_KEY
|
||||
PW_USE_ESYNC PW_USE_FSYNC PW_USE_NTSYNC PW_USE_RAY_TRACING PW_USE_NVAPI_AND_DLSS PW_USE_OPTISCALER
|
||||
PW_USE_LS_FRAME_GEN PW_WINE_FULLSCREEN_FSR PW_HIDE_NVIDIA_GPU PW_VIRTUAL_DESKTOP PW_USE_TERMINAL
|
||||
PW_USE_GAMEMODE PW_USE_INHIBIT_SLEEP PW_USE_D3D_EXTRAS PW_FIX_VIDEO_IN_GAME PW_REDUCE_PULSE_LATENCY
|
||||
@@ -4465,6 +4651,10 @@ gui_edit_db () {
|
||||
DISABLE_EDIT_DB_LIST+=" PW_VKBASALT PW_VKBASALT_USER_CONF PW_USE_RAY_TRACING PW_USE_OBS_VKCAPTURE PW_USE_GALLIUM_ZINK PW_USE_WINED3D_VULKAN"
|
||||
fi
|
||||
[[ "${PW_USE_SPECIALK}" == "1" ]] && DISABLE_EDIT_DB_LIST+=" PW_DGVOODOO2"
|
||||
[[ "${PW_USE_RESHADE}" == "1" ]] && DISABLE_EDIT_DB_LIST+=" PW_USE_OPTISCALER PW_USE_SPECIALK"
|
||||
if [[ "${PW_USE_OPTISCALER}" == "1" || "${PW_USE_SPECIALK}" == "1" ]] ; then
|
||||
DISABLE_EDIT_DB_LIST+=" PW_USE_RESHADE"
|
||||
fi
|
||||
|
||||
[[ ! -e "/dev/ntsync" ]] && DISABLE_EDIT_DB_LIST+=" PW_USE_NTSYNC"
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ export VKD3D_SAREK_VER="sarek-2.6.0"
|
||||
export PW_LSFG_VK_VER="2.0.0-dev25-p11"
|
||||
export PW_OPTISCALER_VER="v03-0.9.0-pre8"
|
||||
export PW_SPECIALK_VER="SK_26_5_15"
|
||||
export PW_RESHADE_VER="6.8.0"
|
||||
export PW_D3D8TO9_VER="1.15.1"
|
||||
export PW_GALLIUM_NINE_VER="0.10"
|
||||
export DOTPFX_VER="48v9"
|
||||
export DEFPFX_VER="v1"
|
||||
@@ -33,6 +35,13 @@ check_variables PROTON_USE_XALIA "0"
|
||||
check_variables PW_USE_RUNTIME "1"
|
||||
check_variables PW_USE_D7VK "0"
|
||||
check_variables PW_USE_SPECIALK "0"
|
||||
check_variables PW_USE_RESHADE "0"
|
||||
check_variables PW_RESHADE_API "auto"
|
||||
check_variables PW_RESHADE_EXE ""
|
||||
check_variables PW_RESHADE_FONT ""
|
||||
check_variables PW_RESHADE_SCREENSHOT_PATH ""
|
||||
check_variables PW_RESHADE_SCREENSHOT_KEY "44,0,0,0"
|
||||
check_variables PW_RESHADE_OVERLAY_KEY "36,0,0,0"
|
||||
check_variables PW_USE_ESYNC "0"
|
||||
check_variables PW_USE_FSYNC "0"
|
||||
check_variables PW_USE_NTSYNC "0"
|
||||
|
||||
@@ -57,6 +57,7 @@ from portprotonqt.dialogs.dialog_utils import create_dialog_hints_widget, update
|
||||
from portprotonqt.dialogs.proton_manager import show_proton_manager
|
||||
from portprotonqt.dialogs.settings_mangohud import MANGOHUD_ENV_KEYS, MangoHudSettingsMixin
|
||||
from portprotonqt.dialogs.settings_gamescope import GAMESCOPE_ENV_KEYS, GamescopeSettingsMixin
|
||||
from portprotonqt.dialogs.settings_reshade import RESHADE_ENV_KEYS, ReShadeSettingsMixin
|
||||
from portprotonqt.dialogs.settings_vkbasalt import VKBASALT_ENV_KEYS, VkBasaltSettingsMixin
|
||||
from portprotonqt.localization import _, format_setting_name_for_display
|
||||
from portprotonqt.logger import get_logger
|
||||
@@ -77,6 +78,7 @@ from portprotonqt.virtual_keyboard import VirtualKeyboard
|
||||
logger = get_logger(__name__)
|
||||
theme_manager = ThemeManager()
|
||||
TOGGLE_BOOL_KEYS = {
|
||||
'PW_USE_RESHADE',
|
||||
'PW_MANGOHUD',
|
||||
'PW_MANGOHUD_USER_CONF',
|
||||
'PW_GAMESCOPE',
|
||||
@@ -88,6 +90,8 @@ DEFAULT_WINE_SETTING_KEYS = {
|
||||
'PW_PREFIX_NAME': 'PW_DEFAULT_PREFIX_NAME',
|
||||
'PW_VULKAN_USE': 'PW_DEFAULT_VULKAN_USE',
|
||||
}
|
||||
|
||||
|
||||
def _normalize_prefix_directories(prefixes_dir):
|
||||
if not os.path.isdir(prefixes_dir):
|
||||
return
|
||||
@@ -152,6 +156,7 @@ class ExeSettingsDialog(
|
||||
DraggableDialog,
|
||||
MangoHudSettingsMixin,
|
||||
GamescopeSettingsMixin,
|
||||
ReShadeSettingsMixin,
|
||||
VkBasaltSettingsMixin,
|
||||
):
|
||||
"""Dialog for configuring executable-specific settings."""
|
||||
@@ -216,6 +221,7 @@ class ExeSettingsDialog(
|
||||
self.advanced_settings_by_key = {}
|
||||
self.init_mangohud_state()
|
||||
self.init_gamescope_state()
|
||||
self.init_reshade_state()
|
||||
self.init_vkbasalt_state()
|
||||
self.blocked_keys = set()
|
||||
self.numa_nodes = {}
|
||||
@@ -230,6 +236,7 @@ class ExeSettingsDialog(
|
||||
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
|
||||
self.toggle_settings = get_toggle_settings()
|
||||
self.toggle_settings.pop('PW_USE_RESHADE', None)
|
||||
if self.game_source == "native":
|
||||
self.toggle_settings = {key: description for key, description in self.toggle_settings.items() if key in NATIVE_TOGGLE_KEYS}
|
||||
self.setWindowTitle(_("Native") + " — " + _("Settings"))
|
||||
@@ -413,6 +420,8 @@ class ExeSettingsDialog(
|
||||
self.mangohud_tab_layout = QVBoxLayout(self.mangohud_tab)
|
||||
self.vkbasalt_tab = QWidget()
|
||||
self.vkbasalt_tab_layout = QVBoxLayout(self.vkbasalt_tab)
|
||||
self.reshade_tab = QWidget()
|
||||
self.reshade_tab_layout = QVBoxLayout(self.reshade_tab)
|
||||
self.gamescope_tab = QWidget()
|
||||
self.gamescope_tab_layout = QVBoxLayout(self.gamescope_tab)
|
||||
|
||||
@@ -420,6 +429,7 @@ class ExeSettingsDialog(
|
||||
self.tab_widget.addTab(self.advanced_tab, _("Advanced"))
|
||||
self.tab_widget.addTab(self.mangohud_tab, "MangoHud")
|
||||
self.tab_widget.addTab(self.vkbasalt_tab, "vkBasalt")
|
||||
self.tab_widget.addTab(self.reshade_tab, "ReShade")
|
||||
if self.gamescope_available:
|
||||
self.tab_widget.addTab(self.gamescope_tab, "Gamescope")
|
||||
|
||||
@@ -543,6 +553,7 @@ class ExeSettingsDialog(
|
||||
|
||||
self.setup_mangohud_tab()
|
||||
self.setup_vkbasalt_tab()
|
||||
self.setup_reshade_tab()
|
||||
if self.gamescope_available:
|
||||
self.setup_gamescope_tab()
|
||||
|
||||
@@ -645,6 +656,7 @@ class ExeSettingsDialog(
|
||||
or key in MANGOHUD_ENV_KEYS
|
||||
or key in GAMESCOPE_ENV_KEYS
|
||||
or key in VKBASALT_ENV_KEYS
|
||||
or key in RESHADE_ENV_KEYS
|
||||
or key in TOGGLE_BOOL_KEYS
|
||||
):
|
||||
if val.startswith('"') and val.endswith('"') and len(val) >= 2:
|
||||
@@ -679,6 +691,8 @@ class ExeSettingsDialog(
|
||||
self.current_settings[key] = ''
|
||||
for key in VKBASALT_ENV_KEYS:
|
||||
self.current_settings[key] = ''
|
||||
for key in RESHADE_ENV_KEYS:
|
||||
self.current_settings[key] = ''
|
||||
elif not self.user_conf:
|
||||
self.current_settings.setdefault('PW_MANGOHUD', '0')
|
||||
self.current_settings.setdefault('PW_VKBASALT', '0')
|
||||
@@ -707,6 +721,8 @@ class ExeSettingsDialog(
|
||||
self.populate_advanced()
|
||||
self.populate_mangohud()
|
||||
self.populate_vkbasalt()
|
||||
self.populate_reshade()
|
||||
self.reshade_enable_button.setEnabled('PW_USE_RESHADE' not in self.blocked_keys)
|
||||
if self.gamescope_available:
|
||||
self.populate_gamescope()
|
||||
self.populate_favorites(select_tab=True)
|
||||
@@ -1542,6 +1558,7 @@ class ExeSettingsDialog(
|
||||
|
||||
self._filter_mangohud_settings(search_text)
|
||||
self._filter_vkbasalt_settings(search_text)
|
||||
self._filter_reshade_settings(search_text)
|
||||
self._filter_gamescope_settings(search_text)
|
||||
|
||||
def _connect_autosave(self) -> None:
|
||||
@@ -1585,6 +1602,7 @@ class ExeSettingsDialog(
|
||||
self.original_display_values.update(self.saved_display_values)
|
||||
self.mangohud_original_values.update(self.saved_values)
|
||||
self.vkbasalt_original_values.update(self.saved_values)
|
||||
self.reshade_original_values.update(self.saved_values)
|
||||
self.gamescope_original_values.update(self.saved_values)
|
||||
self.clear_ppdb_button.setEnabled(True)
|
||||
self.saving = False
|
||||
@@ -1669,6 +1687,7 @@ class ExeSettingsDialog(
|
||||
if self.gamescope_available:
|
||||
gamescope_changes = self._collect_gamescope_changes()
|
||||
vkbasalt_changes = self._collect_vkbasalt_changes()
|
||||
reshade_changes = self._collect_reshade_changes()
|
||||
if self.user_conf:
|
||||
if self.current_settings.get('PW_MANGOHUD') != '1':
|
||||
mangohud_changes = [
|
||||
@@ -1685,12 +1704,20 @@ class ExeSettingsDialog(
|
||||
change for change in gamescope_changes
|
||||
if change.startswith('PW_GAMESCOPE=')
|
||||
]
|
||||
specialized_changes = mangohud_changes + vkbasalt_changes + gamescope_changes
|
||||
if self.current_settings.get('PW_USE_RESHADE') != '1':
|
||||
reshade_changes = [
|
||||
change for change in reshade_changes
|
||||
if change.startswith('PW_USE_RESHADE=')
|
||||
]
|
||||
specialized_changes = (
|
||||
mangohud_changes + vkbasalt_changes + reshade_changes + gamescope_changes
|
||||
)
|
||||
if self.user_conf:
|
||||
defaults = ('', '0', '0.00', 'Home')
|
||||
specialized_changes = [
|
||||
change for change in specialized_changes
|
||||
if change.split('=', 1)[0] in self.original_values
|
||||
or change.startswith('PW_USE_RESHADE=')
|
||||
or change.split('=', 1)[1] not in defaults
|
||||
]
|
||||
changes.extend(specialized_changes)
|
||||
@@ -1929,6 +1956,8 @@ class ExeSettingsDialog(
|
||||
)
|
||||
return False
|
||||
|
||||
if isinstance(obj, QWidget) and self._handle_reshade_key_button_event(obj, event):
|
||||
return True
|
||||
if isinstance(obj, QWidget) and self._handle_vkbasalt_key_button_event(obj, event):
|
||||
self._schedule_save()
|
||||
return True
|
||||
|
||||
@@ -0,0 +1,446 @@
|
||||
"""ReShade settings support for executable settings dialog."""
|
||||
|
||||
import os
|
||||
from typing import Any, cast
|
||||
|
||||
from PySide6.QtCore import QEvent, Qt
|
||||
from PySide6.QtGui import QKeyEvent, QKeySequence
|
||||
from PySide6.QtWidgets import (
|
||||
QGridLayout,
|
||||
QGroupBox,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QLineEdit,
|
||||
QPushButton,
|
||||
QScrollArea,
|
||||
QSizePolicy,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from portprotonqt.custom_widgets import AutoSizeButton, CustomComboBox
|
||||
from portprotonqt.localization import _
|
||||
from portprotonqt.theme_manager import ThemeManager
|
||||
|
||||
RESHADE_ENV_KEYS = [
|
||||
'PW_RESHADE_EXE',
|
||||
'PW_RESHADE_API',
|
||||
'PW_RESHADE_FONT',
|
||||
'PW_RESHADE_SCREENSHOT_PATH',
|
||||
'PW_RESHADE_SCREENSHOT_KEY',
|
||||
'PW_RESHADE_OVERLAY_KEY',
|
||||
]
|
||||
RESHADE_API_OPTIONS = {
|
||||
"Auto": "auto",
|
||||
"DXGI": "dxgi.dll",
|
||||
"DirectX 8/9": "d3d9.dll",
|
||||
"OpenGL": "opengl32.dll",
|
||||
"Vulkan": "vulkan",
|
||||
}
|
||||
RESHADE_SPECIAL_KEYS = {
|
||||
Qt.Key.Key_Cancel: 3,
|
||||
Qt.Key.Key_Backspace: 8,
|
||||
Qt.Key.Key_Tab: 9,
|
||||
Qt.Key.Key_Clear: 12,
|
||||
Qt.Key.Key_Return: 13,
|
||||
Qt.Key.Key_Enter: 13,
|
||||
Qt.Key.Key_Pause: 19,
|
||||
Qt.Key.Key_CapsLock: 20,
|
||||
Qt.Key.Key_Escape: 27,
|
||||
Qt.Key.Key_Space: 32,
|
||||
Qt.Key.Key_PageUp: 33,
|
||||
Qt.Key.Key_PageDown: 34,
|
||||
Qt.Key.Key_End: 35,
|
||||
Qt.Key.Key_Home: 36,
|
||||
Qt.Key.Key_Left: 37,
|
||||
Qt.Key.Key_Up: 38,
|
||||
Qt.Key.Key_Right: 39,
|
||||
Qt.Key.Key_Down: 40,
|
||||
Qt.Key.Key_Print: 44,
|
||||
Qt.Key.Key_Insert: 45,
|
||||
Qt.Key.Key_Delete: 46,
|
||||
Qt.Key.Key_Help: 47,
|
||||
Qt.Key.Key_Meta: 91,
|
||||
Qt.Key.Key_Menu: 93,
|
||||
Qt.Key.Key_Sleep: 95,
|
||||
Qt.Key.Key_NumLock: 144,
|
||||
Qt.Key.Key_ScrollLock: 145,
|
||||
Qt.Key.Key_Semicolon: 186,
|
||||
Qt.Key.Key_Equal: 187,
|
||||
Qt.Key.Key_Comma: 188,
|
||||
Qt.Key.Key_Minus: 189,
|
||||
Qt.Key.Key_Period: 190,
|
||||
Qt.Key.Key_Slash: 191,
|
||||
Qt.Key.Key_QuoteLeft: 192,
|
||||
Qt.Key.Key_BracketLeft: 219,
|
||||
Qt.Key.Key_Backslash: 220,
|
||||
Qt.Key.Key_BracketRight: 221,
|
||||
Qt.Key.Key_Apostrophe: 222,
|
||||
Qt.Key.Key_Back: 166,
|
||||
Qt.Key.Key_Forward: 167,
|
||||
Qt.Key.Key_Refresh: 168,
|
||||
Qt.Key.Key_Stop: 169,
|
||||
Qt.Key.Key_Search: 170,
|
||||
Qt.Key.Key_Favorites: 171,
|
||||
Qt.Key.Key_HomePage: 172,
|
||||
Qt.Key.Key_VolumeMute: 173,
|
||||
Qt.Key.Key_VolumeDown: 174,
|
||||
Qt.Key.Key_VolumeUp: 175,
|
||||
Qt.Key.Key_MediaNext: 176,
|
||||
Qt.Key.Key_MediaPrevious: 177,
|
||||
Qt.Key.Key_MediaStop: 178,
|
||||
Qt.Key.Key_MediaPlay: 179,
|
||||
Qt.Key.Key_LaunchMail: 180,
|
||||
Qt.Key.Key_LaunchMedia: 181,
|
||||
Qt.Key.Key_Launch0: 182,
|
||||
Qt.Key.Key_Launch1: 183,
|
||||
}
|
||||
RESHADE_KEYPAD_KEYS = {
|
||||
Qt.Key.Key_Asterisk: 106,
|
||||
Qt.Key.Key_Plus: 107,
|
||||
Qt.Key.Key_Comma: 108,
|
||||
Qt.Key.Key_Minus: 109,
|
||||
Qt.Key.Key_Period: 110,
|
||||
Qt.Key.Key_Slash: 111,
|
||||
}
|
||||
RESHADE_FIRST_FUNCTION_KEY = 112
|
||||
RESHADE_LAST_FUNCTION_KEY = 135
|
||||
RESHADE_FIRST_NUMPAD_KEY = 96
|
||||
|
||||
|
||||
class ReShadeSettingsMixin:
|
||||
"""Mixin with ReShade settings UI and serialization logic."""
|
||||
|
||||
theme: Any
|
||||
exe_path: str | None
|
||||
current_settings: dict[str, str]
|
||||
original_values: dict[str, str]
|
||||
reshade_tab: QWidget
|
||||
reshade_tab_layout: QVBoxLayout
|
||||
reshade_key_target: str | None = None
|
||||
|
||||
def init_reshade_state(self) -> None:
|
||||
self.reshade_original_values = {}
|
||||
|
||||
def setup_reshade_tab(self) -> None:
|
||||
"""Create ReShade tab widgets."""
|
||||
scroll = QScrollArea()
|
||||
scroll.setWidgetResizable(True)
|
||||
scroll.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
scroll.setStyleSheet(self.theme.SCROLL_STYLE + self.theme.TRANSPARENT_BACKGROUND_STYLE)
|
||||
container = QWidget()
|
||||
layout = QVBoxLayout(container)
|
||||
layout.setSpacing(self.theme.exeSettingsGroupBoxBlockSpacing)
|
||||
|
||||
actions = QGroupBox(_("Actions"))
|
||||
actions.setStyleSheet(self.theme.QGROUP_BOX_STYLE)
|
||||
actions_layout = QGridLayout(actions)
|
||||
self.reshade_enable_button = self._create_reshade_button("")
|
||||
self.reshade_enable_button.clicked.connect(self.toggle_reshade_enable)
|
||||
actions_layout.addWidget(self.reshade_enable_button, 0, 0)
|
||||
layout.addWidget(actions)
|
||||
|
||||
self._add_reshade_settings_group(layout)
|
||||
layout.addStretch()
|
||||
|
||||
scroll.setWidget(container)
|
||||
self.reshade_tab_layout.addWidget(scroll)
|
||||
|
||||
def _add_reshade_settings_group(self, parent_layout: QVBoxLayout) -> None:
|
||||
self.reshade_settings_group = QGroupBox(_("Settings"))
|
||||
self.reshade_settings_group.setStyleSheet(self.theme.QGROUP_BOX_STYLE)
|
||||
settings_layout = QGridLayout(self.reshade_settings_group)
|
||||
self.reshade_exe_edit = self._add_reshade_file_row(
|
||||
settings_layout, 0, "EXE", ".exe"
|
||||
)
|
||||
self.reshade_api_combo = CustomComboBox(theme=self.theme)
|
||||
self.reshade_api_combo.view().window().setWindowFlags(
|
||||
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
|
||||
)
|
||||
self.reshade_api_combo.view().window().setAttribute(
|
||||
Qt.WidgetAttribute.WA_TranslucentBackground
|
||||
)
|
||||
self.reshade_api_combo.setStyleSheet(
|
||||
self.theme.COMBOBOX_STYLE + self.theme.SCROLL_STYLE
|
||||
)
|
||||
self.reshade_api_combo.addItems(list(RESHADE_API_OPTIONS))
|
||||
settings_layout.addWidget(QLabel("API"), 1, 0)
|
||||
settings_layout.addWidget(self.reshade_api_combo, 1, 1)
|
||||
self.reshade_font_combo = CustomComboBox(theme=self.theme)
|
||||
self.reshade_font_combo.view().window().setWindowFlags(
|
||||
Qt.WindowType.Popup | Qt.WindowType.FramelessWindowHint
|
||||
)
|
||||
self.reshade_font_combo.view().window().setAttribute(
|
||||
Qt.WidgetAttribute.WA_TranslucentBackground
|
||||
)
|
||||
self.reshade_font_combo.setStyleSheet(
|
||||
self.theme.COMBOBOX_STYLE + self.theme.SCROLL_STYLE
|
||||
)
|
||||
self.reshade_font_combo.addItem(_("Default"), "")
|
||||
settings_layout.addWidget(QLabel(_("Font")), 2, 0)
|
||||
settings_layout.addWidget(self.reshade_font_combo, 2, 1)
|
||||
self.reshade_screenshot_edit = self._add_reshade_directory_row(
|
||||
settings_layout, 3, _("Screenshots")
|
||||
)
|
||||
self.reshade_screenshot_key_button = self._create_reshade_key_button(
|
||||
"screenshot"
|
||||
)
|
||||
settings_layout.addWidget(QLabel(_("Screenshot key")), 4, 0)
|
||||
settings_layout.addWidget(self.reshade_screenshot_key_button, 4, 1)
|
||||
self.reshade_overlay_key_button = self._create_reshade_key_button("overlay")
|
||||
settings_layout.addWidget(QLabel(_("Overlay key")), 5, 0)
|
||||
settings_layout.addWidget(self.reshade_overlay_key_button, 5, 1)
|
||||
parent_layout.addWidget(self.reshade_settings_group)
|
||||
self._load_reshade_fonts()
|
||||
|
||||
def _create_reshade_button(self, label: str) -> QPushButton:
|
||||
button = QPushButton(label)
|
||||
button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE)
|
||||
button.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
button.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
|
||||
return button
|
||||
|
||||
def _add_reshade_file_row(
|
||||
self, layout: QGridLayout, row: int, label: str, file_filter: str
|
||||
) -> QLineEdit:
|
||||
line_edit = QLineEdit()
|
||||
line_edit.setStyleSheet(self.theme.ADDGAME_INPUT_STYLE)
|
||||
button = AutoSizeButton(
|
||||
_("Browse…"), icon=ThemeManager().get_icon("folder", as_path=True)
|
||||
)
|
||||
button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE)
|
||||
button.clicked.connect(
|
||||
lambda _checked=False: self._select_reshade_file(line_edit, file_filter)
|
||||
)
|
||||
field_layout = QHBoxLayout()
|
||||
field_layout.addWidget(line_edit)
|
||||
field_layout.addWidget(button)
|
||||
layout.addWidget(QLabel(label), row, 0)
|
||||
layout.addLayout(field_layout, row, 1)
|
||||
return line_edit
|
||||
|
||||
def _select_reshade_file(self, line_edit: QLineEdit, file_filter: str) -> None:
|
||||
from portprotonqt.dialogs.file_explorer import FileExplorer
|
||||
|
||||
current_path = line_edit.text().strip()
|
||||
initial_path = os.path.dirname(current_path) if os.path.isfile(current_path) else None
|
||||
explorer = FileExplorer(
|
||||
self, theme=self.theme, file_filter=file_filter, initial_path=initial_path
|
||||
)
|
||||
explorer.file_signal.file_selected.connect(line_edit.setText)
|
||||
explorer.exec()
|
||||
|
||||
def _add_reshade_directory_row(
|
||||
self, layout: QGridLayout, row: int, label: str
|
||||
) -> QLineEdit:
|
||||
line_edit = QLineEdit()
|
||||
line_edit.setStyleSheet(self.theme.ADDGAME_INPUT_STYLE)
|
||||
button = AutoSizeButton(
|
||||
_("Browse…"), icon=ThemeManager().get_icon("folder", as_path=True)
|
||||
)
|
||||
button.setStyleSheet(self.theme.ACTION_BUTTON_STYLE)
|
||||
button.clicked.connect(
|
||||
lambda _checked=False: self._select_reshade_directory(line_edit)
|
||||
)
|
||||
field_layout = QHBoxLayout()
|
||||
field_layout.addWidget(line_edit)
|
||||
field_layout.addWidget(button)
|
||||
layout.addWidget(QLabel(label), row, 0)
|
||||
layout.addLayout(field_layout, row, 1)
|
||||
return line_edit
|
||||
|
||||
def _select_reshade_directory(self, line_edit: QLineEdit) -> None:
|
||||
from portprotonqt.dialogs.file_explorer import FileExplorer
|
||||
|
||||
initial_path = line_edit.text().strip() or os.path.dirname(self.exe_path or "")
|
||||
explorer = FileExplorer(
|
||||
self, theme=self.theme, initial_path=initial_path, directory_only=True
|
||||
)
|
||||
explorer.file_signal.file_selected.connect(line_edit.setText)
|
||||
explorer.exec()
|
||||
|
||||
def _create_reshade_key_button(self, target: str) -> QPushButton:
|
||||
button = self._create_reshade_button("")
|
||||
button.clicked.connect(lambda _checked=False: self._capture_reshade_key(target))
|
||||
button.installEventFilter(cast(QWidget, self))
|
||||
return button
|
||||
|
||||
def _capture_reshade_key(self, target: str) -> None:
|
||||
self.reshade_key_target = target
|
||||
button = self._get_reshade_key_button(target)
|
||||
button.setText(_("Press a button to choose"))
|
||||
button.grabKeyboard()
|
||||
|
||||
def _get_reshade_key_button(self, target: str) -> QPushButton:
|
||||
if target == "screenshot":
|
||||
return self.reshade_screenshot_key_button
|
||||
return self.reshade_overlay_key_button
|
||||
|
||||
def _handle_reshade_key_button_event(self, obj: QWidget, event: QEvent) -> bool:
|
||||
target = self.reshade_key_target
|
||||
if target is None or obj is not self._get_reshade_key_button(target):
|
||||
return False
|
||||
if event.type() != QEvent.Type.KeyPress:
|
||||
return False
|
||||
key_event = cast(QKeyEvent, event)
|
||||
key_value = self._reshade_virtual_key(
|
||||
key_event.key(), key_event.modifiers()
|
||||
)
|
||||
if key_value is None:
|
||||
return True
|
||||
modifiers = key_event.modifiers()
|
||||
value = ",".join(str(item) for item in (
|
||||
key_value,
|
||||
int(bool(modifiers & Qt.KeyboardModifier.ControlModifier)),
|
||||
int(bool(modifiers & Qt.KeyboardModifier.ShiftModifier)),
|
||||
int(bool(modifiers & Qt.KeyboardModifier.AltModifier)),
|
||||
))
|
||||
self.current_settings[f'PW_RESHADE_{target.upper()}_KEY'] = value
|
||||
button = self._get_reshade_key_button(target)
|
||||
button.setText(QKeySequence(key_event.keyCombination()).toString())
|
||||
button.releaseKeyboard()
|
||||
self.reshade_key_target = None
|
||||
return True
|
||||
|
||||
def _reshade_virtual_key(
|
||||
self, key: int, modifiers: Qt.KeyboardModifier
|
||||
) -> int | None:
|
||||
is_keypad = bool(modifiers & Qt.KeyboardModifier.KeypadModifier)
|
||||
if is_keypad and Qt.Key.Key_0.value <= key <= Qt.Key.Key_9.value:
|
||||
return RESHADE_FIRST_NUMPAD_KEY + key - Qt.Key.Key_0.value
|
||||
if is_keypad:
|
||||
try:
|
||||
keypad_key = RESHADE_KEYPAD_KEYS.get(Qt.Key(key))
|
||||
except ValueError:
|
||||
keypad_key = None
|
||||
if keypad_key is not None:
|
||||
return keypad_key
|
||||
if Qt.Key.Key_0.value <= key <= Qt.Key.Key_9.value:
|
||||
return key
|
||||
if Qt.Key.Key_A.value <= key <= Qt.Key.Key_Z.value:
|
||||
return key
|
||||
if Qt.Key.Key_F1.value <= key <= Qt.Key.Key_F24.value:
|
||||
return RESHADE_FIRST_FUNCTION_KEY + key - Qt.Key.Key_F1.value
|
||||
try:
|
||||
return RESHADE_SPECIAL_KEYS.get(Qt.Key(key))
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
def _format_reshade_key(self, value: str) -> str:
|
||||
try:
|
||||
key, control, shift, alt = (int(item) for item in value.split(","))
|
||||
except ValueError:
|
||||
return value
|
||||
qt_key = next(
|
||||
(item for item, code in RESHADE_SPECIAL_KEYS.items() if code == key), None
|
||||
)
|
||||
if qt_key is not None:
|
||||
name = QKeySequence(qt_key).toString()
|
||||
elif RESHADE_FIRST_FUNCTION_KEY <= key <= RESHADE_LAST_FUNCTION_KEY:
|
||||
name = f"F{key - RESHADE_FIRST_FUNCTION_KEY + 1}"
|
||||
else:
|
||||
name = chr(key)
|
||||
modifiers = [
|
||||
label for active, label in (
|
||||
(control, "Ctrl"), (shift, "Shift"), (alt, "Alt")
|
||||
) if active
|
||||
]
|
||||
return "+".join([*modifiers, name])
|
||||
|
||||
def _load_reshade_fonts(self) -> None:
|
||||
selected_family = self.current_settings.get('PW_RESHADE_FONT', '')
|
||||
font_options = cast(Any, self)._get_mangohud_font_options()
|
||||
families = {name for name, _path in font_options}
|
||||
self.reshade_font_combo.clear()
|
||||
self.reshade_font_combo.addItem(_("Default"), "")
|
||||
for family in sorted(families, key=str.casefold):
|
||||
self.reshade_font_combo.addItem(family, family)
|
||||
self._select_reshade_font(selected_family)
|
||||
|
||||
def _select_reshade_font(self, family: str) -> None:
|
||||
for index in range(self.reshade_font_combo.count()):
|
||||
if self.reshade_font_combo.itemData(index) == family:
|
||||
self.reshade_font_combo.setCurrentIndex(index)
|
||||
return
|
||||
if family:
|
||||
self.reshade_font_combo.addItem(family, family)
|
||||
self.reshade_font_combo.setCurrentIndex(self.reshade_font_combo.count() - 1)
|
||||
|
||||
def populate_reshade(self) -> None:
|
||||
"""Populate ReShade tab from current settings."""
|
||||
reshade_exe = self.current_settings.get('PW_RESHADE_EXE', '') or self.exe_path or ''
|
||||
self.reshade_exe_edit.setText(reshade_exe)
|
||||
api_value = self.current_settings.get('PW_RESHADE_API', 'auto')
|
||||
api_label = next(
|
||||
(label for label, value in RESHADE_API_OPTIONS.items() if value == api_value),
|
||||
"Auto",
|
||||
)
|
||||
self.reshade_api_combo.setCurrentText(api_label)
|
||||
font_family = self.current_settings.get('PW_RESHADE_FONT', '')
|
||||
self._select_reshade_font(font_family)
|
||||
screenshot_path = self.current_settings.get('PW_RESHADE_SCREENSHOT_PATH', '')
|
||||
screenshot_key = self.current_settings.get(
|
||||
'PW_RESHADE_SCREENSHOT_KEY', '44,0,0,0'
|
||||
)
|
||||
overlay_key = self.current_settings.get(
|
||||
'PW_RESHADE_OVERLAY_KEY', '36,0,0,0'
|
||||
)
|
||||
self.reshade_screenshot_edit.setText(screenshot_path)
|
||||
self.reshade_screenshot_key_button.setText(
|
||||
self._format_reshade_key(screenshot_key)
|
||||
)
|
||||
self.reshade_overlay_key_button.setText(self._format_reshade_key(overlay_key))
|
||||
self.current_settings['PW_RESHADE_SCREENSHOT_KEY'] = screenshot_key
|
||||
self.current_settings['PW_RESHADE_OVERLAY_KEY'] = overlay_key
|
||||
self.reshade_original_values = {
|
||||
key: self.current_settings.get(key, '') for key in RESHADE_ENV_KEYS
|
||||
}
|
||||
self.reshade_original_values['PW_RESHADE_EXE'] = reshade_exe
|
||||
self.reshade_original_values['PW_RESHADE_SCREENSHOT_KEY'] = screenshot_key
|
||||
self.reshade_original_values['PW_RESHADE_OVERLAY_KEY'] = overlay_key
|
||||
self._update_reshade_widgets()
|
||||
|
||||
def toggle_reshade_enable(self) -> None:
|
||||
enabled = self.current_settings.get('PW_USE_RESHADE') == '1'
|
||||
self.current_settings['PW_USE_RESHADE'] = '0' if enabled else '1'
|
||||
self._update_reshade_widgets()
|
||||
|
||||
def _update_reshade_widgets(self) -> None:
|
||||
enabled = self.current_settings.get('PW_USE_RESHADE') == '1'
|
||||
self.reshade_enable_button.setText(
|
||||
_("Disable {0}").format("ReShade")
|
||||
if enabled else _("Enable {0}").format("ReShade")
|
||||
)
|
||||
self.reshade_enable_button.setStyleSheet(
|
||||
self.theme.ACTION_BUTTON_ACTIVE_STYLE if enabled else self.theme.ACTION_BUTTON_STYLE
|
||||
)
|
||||
self.reshade_settings_group.setVisible(enabled)
|
||||
|
||||
def _collect_reshade_changes(self) -> list[str]:
|
||||
changes = []
|
||||
enabled = '1' if self.current_settings.get('PW_USE_RESHADE') == '1' else '0'
|
||||
original_enabled = '1' if self.original_values.get('PW_USE_RESHADE') == '1' else '0'
|
||||
if enabled != original_enabled:
|
||||
changes.append(f"PW_USE_RESHADE={enabled}")
|
||||
values = {
|
||||
'PW_RESHADE_EXE': self.reshade_exe_edit.text().strip(),
|
||||
'PW_RESHADE_API': RESHADE_API_OPTIONS[self.reshade_api_combo.currentText()],
|
||||
'PW_RESHADE_FONT': str(self.reshade_font_combo.currentData() or ''),
|
||||
'PW_RESHADE_SCREENSHOT_PATH': self.reshade_screenshot_edit.text().strip(),
|
||||
'PW_RESHADE_SCREENSHOT_KEY': self.current_settings['PW_RESHADE_SCREENSHOT_KEY'],
|
||||
'PW_RESHADE_OVERLAY_KEY': self.current_settings['PW_RESHADE_OVERLAY_KEY'],
|
||||
}
|
||||
for key, value in values.items():
|
||||
if value != self.reshade_original_values.get(key, ''):
|
||||
changes.append(f"{key}={value}")
|
||||
return changes
|
||||
|
||||
def _filter_reshade_settings(self, search_text: str) -> None:
|
||||
enabled = self.current_settings.get('PW_USE_RESHADE') == '1'
|
||||
self.reshade_settings_group.setVisible(
|
||||
enabled and (
|
||||
not search_text
|
||||
or search_text in "exe api font screenshot overlay"
|
||||
or search_text in _("Settings").lower()
|
||||
)
|
||||
)
|
||||
@@ -1032,6 +1032,8 @@ class MainWindow(
|
||||
self._on_only_installed_changed(current_filter[1])
|
||||
return
|
||||
self.games = games
|
||||
if self.tray_manager is not None:
|
||||
self.tray_manager.refresh_tray_menu()
|
||||
focus_first_card = not self.game_library_manager.games and not getattr(
|
||||
self, "_preserve_library_focus_after_load", False
|
||||
)
|
||||
|
||||
@@ -141,6 +141,7 @@ install_data(
|
||||
'dialogs/settings_dialog.py',
|
||||
'dialogs/settings_mangohud.py',
|
||||
'dialogs/settings_gamescope.py',
|
||||
'dialogs/settings_reshade.py',
|
||||
'dialogs/settings_vkbasalt.py',
|
||||
'dialogs/proton_manager.py',
|
||||
'dialogs/prefix_backup.py',
|
||||
|
||||
@@ -149,6 +149,7 @@ def get_toggle_settings():
|
||||
'PW_USE_SPECIALK': _("Enable SpecialK (injection library for fixing graphics, latency and more)"),
|
||||
# Upscalers and Frame Generation
|
||||
'PW_USE_OPTISCALER': _("Enable OptiScaler (replacement upscaler / frame generator)"),
|
||||
'PW_USE_RESHADE': _("Enable ReShade post-processing"),
|
||||
'PW_USE_LS_FRAME_GEN': _("Enable Lossless Scaling frame generation (experimental)"),
|
||||
'PW_WINE_FULLSCREEN_FSR': _("FSR upscaling in fullscreen with ProtonGE below native resolution"),
|
||||
# Ray Tracing
|
||||
|
||||
@@ -137,16 +137,20 @@ class IBusLayout(X11Layout):
|
||||
|
||||
|
||||
class CosmicLayout:
|
||||
use_cosmic_protocol = True
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.display = self.layout = None
|
||||
self.group = None
|
||||
# Labwc sends the keymap first and may defer the group until a modifier event.
|
||||
self.group = None if self.use_cosmic_protocol else 0
|
||||
self.error = None
|
||||
self.callbacks, self.proxies = [], []
|
||||
self.keyboard = self.manager = self.tracker = None
|
||||
self.lib = load_library()
|
||||
self._configure_library()
|
||||
self.group_interface = self._interface('zcosmic_keyboard_layout_v1')
|
||||
self.manager_interface = self._interface('zcosmic_keyboard_layout_manager_v1')
|
||||
if self.use_cosmic_protocol:
|
||||
self.group_interface = self._interface('zcosmic_keyboard_layout_v1')
|
||||
self.manager_interface = self._interface('zcosmic_keyboard_layout_manager_v1')
|
||||
try:
|
||||
self.display = self.lib.portproton_keyboard_wayland_connect(None)
|
||||
if not self.display:
|
||||
@@ -158,7 +162,7 @@ class CosmicLayout:
|
||||
for _ in range(4):
|
||||
self._check(self.lib.wl_display_roundtrip(self.display))
|
||||
if self.layout is None or self.group is None:
|
||||
raise RuntimeError('COSMIC keyboard layout protocol or keymap unavailable')
|
||||
raise RuntimeError('Wayland keyboard layout or keymap unavailable')
|
||||
except Exception:
|
||||
self.close()
|
||||
raise
|
||||
@@ -216,7 +220,8 @@ class CosmicLayout:
|
||||
self.seat = self._new(self.registry, (0, self._interface('wl_seat')),
|
||||
C.c_uint32(name), interface, C.c_uint32(1), C.c_void_p())
|
||||
self._listen(self.seat, [(self._capabilities, [C.c_uint32])])
|
||||
elif interface == b'zcosmic_keyboard_layout_manager_v1' and self.manager is None:
|
||||
elif (self.use_cosmic_protocol and interface == b'zcosmic_keyboard_layout_manager_v1'
|
||||
and self.manager is None):
|
||||
self.manager = self._new(self.registry, (0, self.manager_interface),
|
||||
C.c_uint32(name), interface, C.c_uint32(1), C.c_void_p())
|
||||
self._track()
|
||||
@@ -225,12 +230,14 @@ class CosmicLayout:
|
||||
if capabilities & 2 and self.keyboard is None:
|
||||
self.keyboard = self._new(self.seat, (1, self._interface('wl_keyboard')), C.c_void_p())
|
||||
u, p = C.c_uint32, C.c_void_p
|
||||
modifiers = (lambda *args: None) if self.use_cosmic_protocol else (
|
||||
lambda serial, depressed, latched, locked, group: self._group(group))
|
||||
self._listen(self.keyboard, [
|
||||
(self._keymap, [u, C.c_int, u]),
|
||||
(lambda *args: None, [u, p, p]),
|
||||
(lambda *args: None, [u, p]),
|
||||
(lambda *args: None, [u, u, u, u]),
|
||||
(lambda *args: None, [u, u, u, u, u])])
|
||||
(modifiers, [u, u, u, u, u])])
|
||||
self._track()
|
||||
elif not capabilities & 2 and self.keyboard is not None:
|
||||
self.error = RuntimeError('COSMIC: keyboard disconnected')
|
||||
@@ -289,6 +296,11 @@ class CosmicLayout:
|
||||
self.display = None
|
||||
|
||||
|
||||
class LabwcLayout(CosmicLayout):
|
||||
# Labwc broadcasts wl_keyboard group changes even without keyboard focus.
|
||||
use_cosmic_protocol = False
|
||||
|
||||
|
||||
SOURCE_SCHEMA = 'org.gnome.desktop.input-sources'
|
||||
BINDINGS_SCHEMA = 'org.gnome.desktop.wm.keybindings'
|
||||
SHORTCUT_MODIFIERS = {
|
||||
@@ -385,6 +397,8 @@ def compositor(environment: Any) -> Any:
|
||||
if name in desktop), None)
|
||||
if name is not None:
|
||||
return name
|
||||
if environment.get("WAYLAND_DISPLAY") and (environment.get("LABWC_PID") or "labwc" in desktop):
|
||||
return "labwc"
|
||||
return 'wayland' if environment.get('WAYLAND_DISPLAY') else None
|
||||
|
||||
|
||||
@@ -635,7 +649,8 @@ def detect_layout() -> object:
|
||||
logger.warning('IBus layout detection unavailable: %s', error)
|
||||
return X11Layout()
|
||||
adapter = {'cosmic': CosmicLayout, 'niri': NiriLayout, 'sway': SwayLayout,
|
||||
'hyprland': HyprlandLayout, 'umbriel': UmbrielLayout, 'mango': MangoLayout}.get(name)
|
||||
'hyprland': HyprlandLayout, 'umbriel': UmbrielLayout, 'mango': MangoLayout,
|
||||
'labwc': LabwcLayout}.get(name)
|
||||
if adapter is None:
|
||||
raise RuntimeError('No keyboard layout adapter for this compositor')
|
||||
return adapter()
|
||||
@@ -42,6 +42,7 @@ class SystemInputWorker(QThread):
|
||||
self.stopping = Event()
|
||||
self.enabled = Event()
|
||||
self.modifiers: set[int] = set()
|
||||
self.pending_super = False
|
||||
self.caps_lock = False
|
||||
self.layout: Any = None
|
||||
self.manual_layout = False
|
||||
@@ -109,10 +110,13 @@ class SystemInputWorker(QThread):
|
||||
self.warning.emit(f'{error}. Manual US/RU labels; external layout changes are not tracked.')
|
||||
|
||||
def _execute(self, device: UInput, action: str, codes: tuple[int, ...]) -> None:
|
||||
from portprotonqt.system_keyboard.detection import CinnamonLayout, GSettingsLayout, KDELayout, X11Layout, is_x11_session
|
||||
from portprotonqt.system_keyboard.detection import CinnamonLayout, GSettingsLayout, KDELayout, LabwcLayout, X11Layout, is_x11_session
|
||||
import os
|
||||
if action in {'tap', 'caps', 'language', 'modifiers'} and not self.enabled.is_set():
|
||||
return
|
||||
if isinstance(self.layout, LabwcLayout) and action == 'modifiers':
|
||||
self._set_labwc_modifiers(device, codes)
|
||||
return
|
||||
if action == 'modifiers':
|
||||
modifier_only = ((self.modifiers == {ecodes.KEY_LEFTMETA}
|
||||
and not is_x11_session(os.environ))
|
||||
@@ -126,6 +130,7 @@ class SystemInputWorker(QThread):
|
||||
self.send_keys(device, chord)
|
||||
self._set_modifiers(device, codes)
|
||||
elif action == 'release':
|
||||
self.pending_super = False
|
||||
self._set_modifiers(device, ())
|
||||
elif action == 'caps':
|
||||
if isinstance(self.layout, X11Layout) and is_x11_session(os.environ):
|
||||
@@ -133,6 +138,7 @@ class SystemInputWorker(QThread):
|
||||
else:
|
||||
self.send_keys(device, (ecodes.KEY_CAPSLOCK,))
|
||||
elif action == 'language':
|
||||
self.pending_super = False
|
||||
self._set_modifiers(device, ())
|
||||
if (type(self.layout) is X11Layout
|
||||
and 'gnome' in os.environ.get('XDG_CURRENT_DESKTOP', '').lower().split(':')):
|
||||
@@ -154,10 +160,32 @@ class SystemInputWorker(QThread):
|
||||
self.send_keys(device, (ecodes.KEY_KBD_LAYOUT_NEXT,))
|
||||
elif action == 'tap':
|
||||
try:
|
||||
if self.pending_super:
|
||||
self.pending_super = False
|
||||
self._set_modifiers(device, (ecodes.KEY_LEFTMETA,))
|
||||
self.send_keys(device, tuple(code for code in codes if code not in self.modifiers))
|
||||
finally:
|
||||
self._set_modifiers(device, ())
|
||||
|
||||
def _set_labwc_modifiers(self, device: UInput, codes: tuple[int, ...]) -> None:
|
||||
requested = set(codes)
|
||||
super_key = {ecodes.KEY_LEFTMETA}
|
||||
if self.pending_super and not requested:
|
||||
# Send both edges after the click; labwc cancels release bindings on pointer presses.
|
||||
self.pending_super = False
|
||||
self.send_keys(device, (ecodes.KEY_LEFTMETA,))
|
||||
return
|
||||
self.pending_super = requested == super_key and not self.modifiers
|
||||
if self.pending_super:
|
||||
return
|
||||
shift_keys = {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT}
|
||||
if (len(self.modifiers) == 2 and ecodes.KEY_LEFTALT in self.modifiers
|
||||
and self.modifiers & shift_keys and self.modifiers - requested):
|
||||
# XKB already switched when the chord was pressed; do not replay it.
|
||||
requested.difference_update(self.modifiers)
|
||||
self._set_modifiers(device, (ecodes.KEY_LEFTALT,))
|
||||
self._set_modifiers(device, tuple(requested))
|
||||
|
||||
def _set_modifiers(self, device: UInput, codes: tuple[int, ...]) -> None:
|
||||
requested = set(codes)
|
||||
for code in sorted(self.modifiers - requested, reverse=True):
|
||||
@@ -193,9 +221,10 @@ class SystemInputWorker(QThread):
|
||||
name = current[0] if isinstance(current, tuple) else getattr(self.layout, 'language', 'System')
|
||||
if hasattr(self.layout, 'layout_identifier'):
|
||||
name = self.layout.layout_identifier()
|
||||
active = self.modifiers | ({ecodes.KEY_LEFTMETA} if self.pending_super else set())
|
||||
self.state_changed.emit({'labels': labels, 'caps': caps,
|
||||
'shift': bool(self.modifiers & {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT}),
|
||||
'modifiers': tuple(sorted(self.modifiers)), 'layout': name})
|
||||
'shift': bool(active & {ecodes.KEY_LEFTSHIFT, ecodes.KEY_RIGHTSHIFT}),
|
||||
'modifiers': tuple(sorted(active)), 'layout': name})
|
||||
except Exception as error:
|
||||
logger.warning("Cannot update system keyboard labels: %s", error)
|
||||
self.warning.emit(str(error))
|
||||
|
||||
@@ -14,6 +14,7 @@ from evdev import ecodes
|
||||
from PySide6.QtCore import QEvent, QObject, QPoint, QPointF, QSocketNotifier, Qt, QTimer
|
||||
from PySide6.QtGui import QCloseEvent, QIcon, QMouseEvent, QImage, QRegion
|
||||
from PySide6.QtWidgets import QApplication, QFrame, QLabel, QPushButton, QSizePolicy, QWidget
|
||||
from shiboken6 import isValid
|
||||
|
||||
from portprotonqt.config import gamepad_config, ui_config
|
||||
from portprotonqt.input_manager.constants import GamepadType
|
||||
@@ -583,6 +584,8 @@ class WaylandWindow(QObject):
|
||||
if not width or not height or width * height > MAX_SURFACE_PIXELS:
|
||||
raise ValueError('Invalid Wayland layer-surface dimensions')
|
||||
self._request(self.layer, (6, None), (C.c_uint32(serial),))
|
||||
if self.configured and (width, height) == (self.window.width(), self.window.height()):
|
||||
return
|
||||
self.window.resize(width, height)
|
||||
self.window._position_keyboard()
|
||||
self.configured = self.dirty = True
|
||||
@@ -742,6 +745,13 @@ class WaylandWindow(QObject):
|
||||
self.window.keyboard.stop_backspace_repeat()
|
||||
|
||||
def _mouse_event(self, kind: QEvent.Type) -> None:
|
||||
pressed = self.pressed_widget
|
||||
if pressed is not None and (not isValid(pressed) or not self.window.isAncestorOf(pressed)):
|
||||
self.pressed_widget = None
|
||||
self.window.keyboard.stop_backspace_repeat()
|
||||
self.dirty = True
|
||||
if kind == QEvent.Type.MouseButtonRelease and self.pressed_widget is None:
|
||||
return
|
||||
point = self.position.toPoint()
|
||||
target = self.pressed_widget or self.window.childAt(point) or self.window.keyboard
|
||||
if isinstance(target, QPushButton) and self.window.keyboard.selected_button is not target:
|
||||
|
||||
@@ -83,15 +83,8 @@ class TrayManager:
|
||||
self.pause_game_action.setEnabled(False)
|
||||
self.pause_game_action.triggered.connect(self.toggle_game_pause)
|
||||
|
||||
self.tray_menu.addAction(self.pause_game_action)
|
||||
self.tray_menu.addAction(self.stop_game_action)
|
||||
self.tray_menu.addSeparator()
|
||||
self.tray_menu.addSeparator()
|
||||
|
||||
exit_action = QAction(_("Exit"), self.main_window)
|
||||
exit_action.triggered.connect(self.force_exit)
|
||||
self.tray_menu.addAction(exit_action)
|
||||
|
||||
# Some D-Bus tray hosts read the menu without opening the local QMenu.
|
||||
self.refresh_tray_menu()
|
||||
self.tray_menu.aboutToShow.connect(self.refresh_tray_menu)
|
||||
self.tray_icon.setContextMenu(self.tray_menu)
|
||||
self.tray_icon.show()
|
||||
|
||||
@@ -476,6 +476,7 @@ def test_failed_protondb_completion_preserves_library_scroll(
|
||||
main.stackedWidget = SimpleNamespace(currentIndex=lambda: 0)
|
||||
main.getColorPalette_from_pixmap = MagicMock()
|
||||
main.game_library_manager = manager
|
||||
main.tray_manager = MagicMock()
|
||||
main._get_portproton_desktop_files = lambda: set()
|
||||
monkeypatch.setattr(portproton_api, "get_user_conf_setting", lambda _key: None)
|
||||
monkeypatch.setattr(api, "load_protondb_status", lambda _appid: None)
|
||||
@@ -503,6 +504,7 @@ def test_failed_protondb_completion_preserves_library_scroll(
|
||||
QApplication.processEvents()
|
||||
QApplication.processEvents()
|
||||
|
||||
main.tray_manager.refresh_tray_menu.assert_called_once_with()
|
||||
assert scrollbar.value() == previous_value
|
||||
assert not manager._focus_first_card_after_update
|
||||
|
||||
|
||||
@@ -370,6 +370,31 @@ def test_shutdown_waits_for_compatibility_analysis() -> None:
|
||||
assert window.compatibility_workers == []
|
||||
|
||||
|
||||
def test_tray_exports_complete_menu_before_first_open(monkeypatch: MonkeyPatch) -> None:
|
||||
_application = QApplication.instance() or QApplication([])
|
||||
from portprotonqt import tray_manager as tray_module
|
||||
|
||||
icon = MagicMock()
|
||||
theme = MagicMock()
|
||||
theme.get_icon.return_value = None
|
||||
monkeypatch.setattr(tray_module, "QSystemTrayIcon", lambda _parent: icon)
|
||||
monkeypatch.setattr(tray_module, "ThemeManager", lambda: theme)
|
||||
monkeypatch.setattr(tray_module.ui_config, "get_theme", lambda: "standart")
|
||||
monkeypatch.setattr(tray_module.display_config, "get_tray_menu_mode", lambda: "detailed")
|
||||
window = cast(Any, QWidget())
|
||||
window.games = []
|
||||
|
||||
def check_export(menu: QMenu) -> None:
|
||||
labels = [action.text() for action in menu.actions() if not action.isSeparator()]
|
||||
assert labels == [tray_module._(text) for text in (
|
||||
"Pause Game", "Stop Game", "No recent games", "Exit",
|
||||
)]
|
||||
|
||||
icon.setContextMenu.side_effect = check_export
|
||||
manager = TrayManager(window)
|
||||
icon.setContextMenu.assert_called_once_with(manager.tray_menu)
|
||||
|
||||
|
||||
def test_minimal_tray_contains_game_actions() -> None:
|
||||
_application = QApplication.instance() or QApplication([])
|
||||
manager = TrayManager.__new__(TrayManager)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"""Tests for config/portproton.py — exec_line parsing, icon sanitization, launcher tail extraction."""
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from pytest import MonkeyPatch
|
||||
from pytest import MonkeyPatch, mark
|
||||
|
||||
from portprotonqt.config.portproton import (
|
||||
extract_exec_target_path,
|
||||
@@ -192,3 +193,182 @@ class TestThemedLaunchIconNames:
|
||||
|
||||
def test_reg_has_icon(self):
|
||||
assert "reg" in THEMED_LAUNCH_ICON_NAMES[".reg"]
|
||||
|
||||
|
||||
def test_run_after_batch_is_created_next_to_exe() -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text(
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
assert 'run_after_dir="$(dirname "${PW_EXE_FILE}")"' in helper
|
||||
assert 'pw_exe_file_win="$("${WINELOADER}" winepath -w "${PW_EXE_FILE}"' in helper
|
||||
assert "chcp 65001 >nul" in helper
|
||||
assert 'start "" "%PW_RUN_AFTER_MAIN_PATH%" ${LAUNCH_PARAMETERS}' in helper
|
||||
assert 'start "" "%PW_RUN_AFTER_SECOND_PATH%"' in helper
|
||||
assert 'PW_RUN_AFTER_MAIN_PATH="${pw_exe_file_win}"' in helper
|
||||
assert 'PW_RUN_AFTER_SECOND_PATH="${run_after_first_win}"' in helper
|
||||
assert 'LAUNCH_PARAMETERS="" proxy_launch_parameters="" \\' in helper
|
||||
assert 'pw_run "${PW_VD_TMP[@]}" "${run_after_bat}"' in helper
|
||||
|
||||
|
||||
def test_game_launch_marker_is_emitted_for_wine_and_proton() -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text(
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
marker = "printf '%s\\n' 'PORTPROTONQT_GAME_LAUNCH_STARTED'"
|
||||
assert helper.count(marker) == 2
|
||||
|
||||
|
||||
def test_user_conf_get_without_name_lists_active_values(tmp_path: Path) -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text()
|
||||
definition = helper.split("manage_user_conf_value () {", 1)[1].split(
|
||||
"use_exiftool () {", 1
|
||||
)[0]
|
||||
user_conf = tmp_path / "user.conf"
|
||||
user_conf.write_text(
|
||||
'# comment\nexport PW_USE_ESYNC="1"\n# export PW_USE_FSYNC="1"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
script = "manage_user_conf_value () {" + definition + '\nmanage_user_conf_value get\n'
|
||||
|
||||
result = subprocess.run(
|
||||
["bash", "-c", script], capture_output=True, text=True,
|
||||
env={"PATH": os.defpath, "USER_CONF": str(user_conf)}, check=False,
|
||||
)
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert result.stdout == 'PW_USE_ESYNC="1"\n'
|
||||
|
||||
|
||||
@mark.parametrize("runtime,logging", [("0", "0"), ("0", "1"), ("1", "0"), ("1", "1")])
|
||||
def test_wine_exit_code_survives_log_output_and_wineserver_wait(
|
||||
tmp_path: Path, runtime: str, logging: str,
|
||||
) -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text()
|
||||
definition = helper.split("pw_run () {", 1)[1].split("export -f pw_run", 1)[0]
|
||||
script = "pw_run () {" + definition + '''
|
||||
check_variables () { :; }
|
||||
pw_launch_wrapper () { return 37; }
|
||||
wait_wineserver () { return 0; }
|
||||
print_info () { :; }
|
||||
PATH_TO_GAME="$1"
|
||||
PW_TMPFS_PATH="$1"
|
||||
PW_LOG_FILE="$1/wine.log"
|
||||
PW_EXE_FILE="$1/game.exe"
|
||||
PW_USE_RUNTIME="$2"
|
||||
PW_LOG="$3"
|
||||
pw_run "$PW_EXE_FILE"
|
||||
exit $?
|
||||
'''
|
||||
(tmp_path / "game.exe").touch()
|
||||
|
||||
result = subprocess.run(
|
||||
["bash", "-c", script, "bash", str(tmp_path), runtime, logging],
|
||||
capture_output=True, text=True, env={"PATH": os.defpath}, check=False,
|
||||
)
|
||||
|
||||
assert result.returncode == 37, result.stderr
|
||||
assert result.stdout.count("PORTPROTONQT_GAME_EXIT_CODE=37") == 1
|
||||
|
||||
|
||||
def test_vk_gpu_info_uses_build_aux_binary() -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text(
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
assert '/../../../bin/vk_gpu_info"' in helper
|
||||
assert "dev-scripts/vk_gpu_info" not in helper
|
||||
|
||||
|
||||
def test_reshade_prefers_directx_for_unity() -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text(
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
assert "source=$(echo \"$detect\" | grep '^SOURCE=' | cut -d= -f2-)" in helper
|
||||
assert (
|
||||
'[[ "${source##*/}" == UnityPlayer.dll && "$highest" != None ]] '
|
||||
"&& vulkan=false"
|
||||
) in helper
|
||||
|
||||
|
||||
def test_reshade_and_optiscaler_are_mutually_exclusive() -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text(
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
assert 'DISABLE_EDIT_DB_LIST+=" PW_USE_OPTISCALER PW_USE_SPECIALK"' in helper
|
||||
assert 'DISABLE_EDIT_DB_LIST+=" PW_USE_RESHADE"' in helper
|
||||
|
||||
|
||||
def test_reshade_repeated_link_does_not_create_nested_shaders(tmp_path: Path) -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text(
|
||||
encoding="utf-8",
|
||||
)
|
||||
link_function = helper.split("try_force_link_dir () {", 1)[1].split("\n}", 1)[0]
|
||||
shaders = tmp_path / "shaders"
|
||||
shaders.mkdir()
|
||||
game = tmp_path / "game"
|
||||
game.mkdir()
|
||||
script = f'try_force_link_dir () {{{link_function}\n}}\n'
|
||||
link_call = helper.split(' [[ "$PW_USE_RESHADE" != 1 ]] && return 0', 1)[1]
|
||||
link_call = link_call.split(' pw_specialk_set_ini_value', 1)[0]
|
||||
script += f'root="$1"\nPATH_TO_GAME="$2"\n{link_call * 2}'
|
||||
|
||||
subprocess.run(
|
||||
["bash", "-c", script, "bash", str(tmp_path), str(game)],
|
||||
check=True,
|
||||
)
|
||||
|
||||
assert (game / "ReShade_shaders").resolve() == shaders
|
||||
assert not (shaders / "shaders").exists()
|
||||
|
||||
|
||||
def test_reshade_disable_cleans_unreal_shipping_directory(tmp_path: Path) -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text(
|
||||
encoding="utf-8",
|
||||
)
|
||||
sync_function = helper.split("pw_reshade_sync_files () {", 1)[1].split("\n}", 1)[0]
|
||||
game_root = tmp_path / "game"
|
||||
game_root.mkdir()
|
||||
game_exe = game_root / "Praest.exe"
|
||||
game_exe.touch()
|
||||
game = game_root / "Praest" / "Binaries" / "Win64"
|
||||
game.mkdir(parents=True)
|
||||
runtime = tmp_path / "plugins" / "reshade_windows" / "reshade" / "6.8.0_Addon"
|
||||
runtime.mkdir(parents=True)
|
||||
reshade_dll = runtime / "ReShade32.dll"
|
||||
reshade_dll.touch()
|
||||
(game / "opengl32.dll").symlink_to(reshade_dll)
|
||||
(game / "opengl32.dll.b").symlink_to(reshade_dll)
|
||||
(game / "ReShadePreset.ini").write_text("[GENERAL]\n")
|
||||
(game / "reshade_version").write_text("6.8.0_Addon\nopengl32.dll\n")
|
||||
script = f'pw_reshade_sync_files () {{{sync_function}\n}}\n'
|
||||
script += 'try_remove_file () { rm -f "$1"; }\npw_reshade_sync_files\n'
|
||||
|
||||
subprocess.run(
|
||||
["bash", "-c", script],
|
||||
check=True,
|
||||
env={
|
||||
**os.environ,
|
||||
"PW_EXE_FILE": str(game_exe),
|
||||
"PW_PLUGINS_PATH": str(tmp_path / "plugins"),
|
||||
"PW_USE_RESHADE": "0",
|
||||
"PW_RESHADE_API": "",
|
||||
"PW_RESHADE_EXE": "",
|
||||
"PATH_TO_GAME": str(game),
|
||||
},
|
||||
)
|
||||
|
||||
assert not (game / "opengl32.dll").exists()
|
||||
assert not (game / "opengl32.dll.b").exists()
|
||||
assert not (game / "ReShadePreset.ini").exists()
|
||||
|
||||
|
||||
def test_ini_writer_matches_spaces_around_equals() -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text(
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
assert '^[[:space:]]*$key[[:space:]]*=' in helper
|
||||
@@ -456,3 +456,37 @@ def test_run_after_command_placeholder_preserves_arguments_and_status(
|
||||
)
|
||||
assert result.returncode == exit_code, result.stderr
|
||||
assert result.stdout == "yes\nаргумент с пробелами\n$(false)\n\n"
|
||||
|
||||
|
||||
@mark.parametrize("steam_play", [False, True])
|
||||
def test_reshade_font_link_stays_inside_prefix(tmp_path: Path, steam_play: bool) -> None:
|
||||
helper = Path("build-aux/share/portproton/scripts/functions_helper").read_text()
|
||||
ini_setter = helper.split("pw_specialk_set_ini_value () {", 1)[1].split("\n}\n", 1)[0]
|
||||
copy_file = helper.split("try_copy_file () {", 1)[1].split("\n}\n", 1)[0]
|
||||
marker = ' if [[ -f "$reshade_font" ]] ; then'
|
||||
font_block = marker + helper.split(marker, 1)[1].split("\n screenshot_path=", 1)[0]
|
||||
source = tmp_path / "host font.ttf"
|
||||
source.write_bytes(b"test font")
|
||||
ini = tmp_path / "ReShade.ini"
|
||||
ini.write_text("[STYLE]\nFont=Z:\\old.ttf\nEditorFont=Z:\\old.ttf\n")
|
||||
wine_prefix = tmp_path / "wine prefix"
|
||||
prefix = tmp_path / "Steam prefix" if steam_play else wine_prefix
|
||||
result = subprocess.run(
|
||||
["bash", "-ec", "pw_specialk_set_ini_value () {" + ini_setter + "\n}\n"
|
||||
+ "try_copy_file () {" + copy_file + "\n}\n"
|
||||
+ "stage_font () {\n" + font_block + '\n}\nstage_font "$@"',
|
||||
"bash", *([str(prefix)] if steam_play else [])],
|
||||
env={"PATH": os.defpath, "WINEPREFIX": str(wine_prefix),
|
||||
"reshade_font": str(source), "PATH_TO_GAME": str(tmp_path)},
|
||||
capture_output=True, text=True, check=False,
|
||||
)
|
||||
assert result.returncode == 0, result.stderr
|
||||
font, editor_font = ini.read_text().splitlines()[1:]
|
||||
assert font.startswith("Font=C:/PortProton/reshade-fonts/")
|
||||
assert editor_font == f"Editor{font}"
|
||||
link = prefix / "drive_c" / font.removeprefix("Font=C:/")
|
||||
assert link.is_symlink()
|
||||
assert not link.readlink().is_absolute()
|
||||
assert link.resolve().is_relative_to(prefix)
|
||||
source.unlink()
|
||||
assert link.read_bytes() == b"test font"
|
||||
@@ -36,6 +36,7 @@ from portprotonqt.dialogs.settings_mangohud import (
|
||||
MANGOHUD_TOGGLE_DESCRIPTIONS,
|
||||
MangoHudSettingsMixin,
|
||||
)
|
||||
from portprotonqt.dialogs.settings_reshade import ReShadeSettingsMixin
|
||||
from portprotonqt.dialogs.settings_vkbasalt import VkBasaltSettingsMixin
|
||||
|
||||
|
||||
@@ -90,6 +91,45 @@ def test_settings_dialog_search_accepts_typing_without_search_focus() -> None:
|
||||
QApplication.sendPostedEvents(None, QEvent.Type.DeferredDelete)
|
||||
|
||||
|
||||
def test_reshade_collects_enable_exe_api_and_font() -> None:
|
||||
settings = ReShadeSettingsMixin()
|
||||
settings.current_settings = {
|
||||
"PW_USE_RESHADE": "1",
|
||||
"PW_RESHADE_SCREENSHOT_KEY": "44,0,0,0",
|
||||
"PW_RESHADE_OVERLAY_KEY": "36,0,0,0",
|
||||
}
|
||||
settings.original_values = {"PW_USE_RESHADE": "0"}
|
||||
settings.reshade_original_values = {
|
||||
"PW_RESHADE_EXE": "",
|
||||
"PW_RESHADE_API": "auto",
|
||||
"PW_RESHADE_FONT": "",
|
||||
"PW_RESHADE_SCREENSHOT_PATH": "",
|
||||
"PW_RESHADE_SCREENSHOT_KEY": "44,0,0,0",
|
||||
"PW_RESHADE_OVERLAY_KEY": "36,0,0,0",
|
||||
}
|
||||
settings.reshade_exe_edit = QLineEdit("/games/game.exe")
|
||||
settings.reshade_api_combo = CustomComboBox()
|
||||
settings.reshade_api_combo.addItems(["Auto", "Vulkan"])
|
||||
settings.reshade_api_combo.setCurrentText("Vulkan")
|
||||
settings.reshade_font_combo = CustomComboBox()
|
||||
settings.reshade_font_combo.addItem("DejaVu Sans", "DejaVu Sans")
|
||||
settings.reshade_screenshot_edit = QLineEdit("/screenshots")
|
||||
|
||||
assert settings._collect_reshade_changes() == [
|
||||
"PW_USE_RESHADE=1",
|
||||
"PW_RESHADE_EXE=/games/game.exe",
|
||||
"PW_RESHADE_API=vulkan",
|
||||
"PW_RESHADE_FONT=DejaVu Sans",
|
||||
"PW_RESHADE_SCREENSHOT_PATH=/screenshots",
|
||||
]
|
||||
assert settings._reshade_virtual_key(
|
||||
Qt.Key.Key_Semicolon.value, Qt.KeyboardModifier.NoModifier
|
||||
) == 186
|
||||
assert settings._reshade_virtual_key(
|
||||
Qt.Key.Key_1.value, Qt.KeyboardModifier.KeypadModifier
|
||||
) == 97
|
||||
|
||||
|
||||
def test_mangohud_search_ignores_unavailable_categories() -> None:
|
||||
settings = MangoHudSettingsMixin()
|
||||
settings.mangohud_category_groups = {}
|
||||
@@ -844,6 +884,16 @@ def autosave_dialog(request, monkeypatch, tmp_path) -> tuple[QDialog, list[list[
|
||||
dialog.mangohud_original_values = {}
|
||||
dialog.vkbasalt_original_values = {}
|
||||
dialog.gamescope_original_values = {}
|
||||
dialog.current_settings.update({
|
||||
'PW_RESHADE_SCREENSHOT_KEY': '44,0,0,0',
|
||||
'PW_RESHADE_OVERLAY_KEY': '36,0,0,0',
|
||||
})
|
||||
dialog.reshade_original_values = {**dialog.current_settings, 'PW_RESHADE_API': 'auto'}
|
||||
dialog.reshade_exe_edit = QLineEdit(dialog)
|
||||
dialog.reshade_api_combo = CustomComboBox(dialog)
|
||||
dialog.reshade_api_combo.addItems(['Auto', 'Vulkan'])
|
||||
dialog.reshade_font_combo = CustomComboBox(dialog)
|
||||
dialog.reshade_screenshot_edit = QLineEdit(dialog)
|
||||
calls: list[list[str]] = []
|
||||
monkeypatch.setattr(dialog, '_collect_mangohud_changes', lambda: [])
|
||||
monkeypatch.setattr(dialog, '_collect_vkbasalt_changes', lambda: [])
|
||||
@@ -853,6 +903,39 @@ def autosave_dialog(request, monkeypatch, tmp_path) -> tuple[QDialog, list[list[
|
||||
return dialog, calls, user_conf
|
||||
|
||||
|
||||
@pytest.mark.parametrize('autosave_dialog', [False, True], indirect=True)
|
||||
def test_reshade_button_autosaves_without_main_checkbox(autosave_dialog: tuple) -> None:
|
||||
from PySide6.QtCore import QProcess
|
||||
from portprotonqt.dialogs.settings_dialog import ExeSettingsDialog
|
||||
|
||||
widget, calls, user_conf = autosave_dialog
|
||||
dialog = cast(ExeSettingsDialog, widget)
|
||||
dialog.theme = SimpleNamespace(ACTION_BUTTON_ACTIVE_STYLE='', ACTION_BUTTON_STYLE='')
|
||||
dialog.search_edit = QLineEdit(dialog)
|
||||
dialog.reshade_settings_group = QGroupBox(dialog)
|
||||
dialog.reshade_enable_button = QPushButton(dialog)
|
||||
dialog.reshade_enable_button.clicked.connect(dialog.toggle_reshade_enable)
|
||||
dialog._connect_autosave()
|
||||
dialog.reshade_api_combo.setCurrentText('Vulkan')
|
||||
|
||||
for value in ('1', '0'):
|
||||
dialog.reshade_enable_button.click()
|
||||
assert dialog.save_timer.isActive()
|
||||
dialog.apply_changes()
|
||||
expected = ['PW_USE_RESHADE', value] if user_conf else [f'PW_USE_RESHADE={value}']
|
||||
if not user_conf and value == '1':
|
||||
expected.append('PW_RESHADE_API=vulkan')
|
||||
assert calls[-1][-len(expected):] == expected
|
||||
process = dialog.user_conf_process if user_conf else dialog.save_process
|
||||
process.finished.emit(0, QProcess.ExitStatus.NormalExit)
|
||||
if user_conf and value == '1':
|
||||
assert calls[-1][-2:] == ['PW_RESHADE_API', 'vulkan']
|
||||
dialog.user_conf_process.finished.emit(0, QProcess.ExitStatus.NormalExit)
|
||||
assert not dialog.saving
|
||||
assert dialog.original_values['PW_USE_RESHADE'] == value
|
||||
dialog.deleteLater()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('autosave_dialog', [False, True], indirect=True)
|
||||
def test_settings_autosave_ignores_download_action(autosave_dialog: tuple) -> None:
|
||||
from portprotonqt.dialogs.settings_dialog import ExeSettingsDialog
|
||||
|
||||
@@ -297,6 +297,41 @@ def test_modifiers_send_real_press_and_release_events(
|
||||
assert not worker.modifiers
|
||||
|
||||
|
||||
@pytest.mark.parametrize('action, codes, events', [
|
||||
('modifiers', (), [(ecodes.KEY_LEFTMETA, 1), (ecodes.KEY_LEFTMETA, 0)]),
|
||||
('tap', (ecodes.KEY_E,), [(ecodes.KEY_LEFTMETA, 1), (ecodes.KEY_E, 1),
|
||||
(ecodes.KEY_E, 0), (ecodes.KEY_LEFTMETA, 0)]),
|
||||
('release', (), []),
|
||||
])
|
||||
def test_labwc_super_sends_one_chord_after_click(action: str, codes: tuple[int, ...], events: list) -> None:
|
||||
worker = SystemInputWorker()
|
||||
worker.layout = detection.LabwcLayout.__new__(detection.LabwcLayout)
|
||||
worker.enabled.set()
|
||||
device = MagicMock()
|
||||
worker._execute(device, 'modifiers', (ecodes.KEY_LEFTMETA,))
|
||||
device.write.assert_not_called()
|
||||
worker._execute(device, action, codes)
|
||||
assert [call.args for call in device.write.call_args_list] == [
|
||||
(ecodes.EV_KEY, key, value) for key, value in events
|
||||
]
|
||||
assert not worker.modifiers and not worker.pending_super
|
||||
|
||||
|
||||
def test_labwc_alt_shift_releases_both_without_replaying() -> None:
|
||||
worker = SystemInputWorker()
|
||||
worker.layout = detection.LabwcLayout.__new__(detection.LabwcLayout)
|
||||
worker.enabled.set()
|
||||
device = MagicMock()
|
||||
worker._execute(device, 'modifiers', (ecodes.KEY_LEFTALT,))
|
||||
worker._execute(device, 'modifiers', (ecodes.KEY_LEFTALT, ecodes.KEY_LEFTSHIFT))
|
||||
worker._execute(device, 'modifiers', (ecodes.KEY_LEFTALT,))
|
||||
assert [call.args for call in device.write.call_args_list] == [
|
||||
(ecodes.EV_KEY, ecodes.KEY_LEFTALT, 1), (ecodes.EV_KEY, ecodes.KEY_LEFTSHIFT, 1),
|
||||
(ecodes.EV_KEY, ecodes.KEY_LEFTSHIFT, 0), (ecodes.EV_KEY, ecodes.KEY_LEFTALT, 0),
|
||||
]
|
||||
assert not worker.modifiers
|
||||
|
||||
|
||||
def test_alt_shift_replay_preserves_remaining_alt(application: QApplication) -> None:
|
||||
worker = SystemInputWorker()
|
||||
worker.enabled.set()
|
||||
@@ -727,14 +762,37 @@ def test_wayland_protocol_metadata_is_native(application: QApplication) -> None:
|
||||
window._interface('not_a_protocol')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('desktop', ['labwc', 'wayfire', 'Qtile', 'river', 'unknown'])
|
||||
def test_budgie_wayland_uses_labwc_layout(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setenv('XDG_CURRENT_DESKTOP', 'Budgie')
|
||||
monkeypatch.setenv('WAYLAND_DISPLAY', 'wayland-test')
|
||||
monkeypatch.setenv('LABWC_PID', '123')
|
||||
adapter = MagicMock()
|
||||
monkeypatch.setattr(detection, 'LabwcLayout', adapter)
|
||||
assert detection.detect_layout() is adapter.return_value
|
||||
|
||||
|
||||
def test_labwc_updates_group_from_keyboard_modifiers() -> None:
|
||||
layout = detection.LabwcLayout.__new__(detection.LabwcLayout)
|
||||
fake = cast(Any, layout)
|
||||
fake.keyboard = fake.manager = None
|
||||
fake.seat = 1
|
||||
fake._interface = MagicMock()
|
||||
fake._new = MagicMock(return_value=2)
|
||||
fake._listen = MagicMock()
|
||||
layout._capabilities(2)
|
||||
modifiers, _ = fake._listen.call_args.args[1][-1]
|
||||
modifiers(0, 0, 0, 0, 2)
|
||||
assert layout.group == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize('desktop', ['wayfire', 'Qtile', 'river', 'unknown'])
|
||||
def test_generic_wayland_uses_manual_labels_without_xwayland(
|
||||
monkeypatch: pytest.MonkeyPatch, desktop: str,
|
||||
) -> None:
|
||||
monkeypatch.setenv('XDG_CURRENT_DESKTOP', desktop)
|
||||
monkeypatch.setenv('WAYLAND_DISPLAY', 'wayland-test')
|
||||
for variable in ('HYPRLAND_INSTANCE_SIGNATURE', 'SWAYSOCK', 'NIRI_SOCKET',
|
||||
'UMBRIEL_SOCKET', 'MANGO_INSTANCE_SIGNATURE'):
|
||||
'UMBRIEL_SOCKET', 'MANGO_INSTANCE_SIGNATURE', 'LABWC_PID'):
|
||||
monkeypatch.delenv(variable, raising=False)
|
||||
x11 = MagicMock()
|
||||
monkeypatch.setattr(detection, 'X11Layout', x11)
|
||||
@@ -984,6 +1042,26 @@ def test_kde_selection_uses_native_backend(monkeypatch: pytest.MonkeyPatch) -> N
|
||||
assert detection.detect_layout() is factory.return_value
|
||||
|
||||
|
||||
def test_wayland_repeated_configure_does_not_rebuild_keyboard() -> None:
|
||||
native: Any = system_window.WaylandWindow.__new__(system_window.WaylandWindow)
|
||||
native.layer = 1
|
||||
native._request = MagicMock()
|
||||
native.window = MagicMock()
|
||||
native.window.width.return_value = 1280
|
||||
native.window.height.return_value = 720
|
||||
native.configured = False
|
||||
native._configured(1, 1280, 720)
|
||||
native.dirty = False
|
||||
native._configured(2, 1280, 720)
|
||||
native.window._position_keyboard.assert_called_once_with()
|
||||
assert native._request.call_count == 2
|
||||
assert not native.dirty
|
||||
native._configured(3, 1920, 1080)
|
||||
native.window.resize.assert_called_with(1920, 1080)
|
||||
assert native.window._position_keyboard.call_count == 2
|
||||
assert native.dirty
|
||||
|
||||
|
||||
def test_wayland_mouse_moves_selection_and_shows_pressed_state(
|
||||
keyboard_window: SystemKeyboardWindow, application: QApplication,
|
||||
) -> None:
|
||||
@@ -1012,6 +1090,41 @@ def test_wayland_mouse_moves_selection_and_shows_pressed_state(
|
||||
assert keyboard_window.worker.commands.get_nowait() == ('tap', (ecodes.KEY_Q,))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('deleted', [False, True])
|
||||
def test_wayland_release_after_keyboard_rebuild(
|
||||
keyboard_window: SystemKeyboardWindow, application: QApplication, deleted: bool,
|
||||
) -> None:
|
||||
from PySide6.QtCore import QEvent, QPointF
|
||||
from shiboken6 import isValid
|
||||
|
||||
keyboard_window.ready = True
|
||||
keyboard_window.show_keyboard()
|
||||
application.processEvents()
|
||||
keyboard = keyboard_window.keyboard
|
||||
target = keyboard.buttons['q']
|
||||
native: Any = system_window.WaylandWindow.__new__(system_window.WaylandWindow)
|
||||
native.window = keyboard_window
|
||||
native.pressed_widget = None
|
||||
native.position = QPointF(target.mapTo(keyboard_window, target.rect().center()))
|
||||
native._mouse_event(QEvent.Type.MouseButtonPress)
|
||||
keyboard.update_keyboard()
|
||||
if deleted:
|
||||
QApplication.sendPostedEvents(target, QEvent.Type.DeferredDelete)
|
||||
assert isValid(target) is not deleted
|
||||
|
||||
native._mouse_event(QEvent.Type.MouseButtonRelease)
|
||||
assert native.pressed_widget is None
|
||||
assert keyboard_window.worker.commands.empty()
|
||||
|
||||
application.processEvents()
|
||||
replacement = keyboard.buttons['q']
|
||||
native.position = QPointF(replacement.mapTo(keyboard_window, replacement.rect().center()))
|
||||
assert keyboard_window.childAt(native.position.toPoint()) is replacement
|
||||
native._mouse_event(QEvent.Type.MouseButtonPress)
|
||||
native._mouse_event(QEvent.Type.MouseButtonRelease)
|
||||
assert keyboard_window.worker.commands.get_nowait() == ('tap', (ecodes.KEY_Q,))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('failed', [False, True])
|
||||
def test_kde_dbus_connection_is_retained_and_closed(
|
||||
monkeypatch: pytest.MonkeyPatch, tmp_path: Any, failed: bool,
|
||||
|
||||
Reference in new issue
Block a user