From 4bee332d4031e7558012d160783d9c90f9f5d55f Mon Sep 17 00:00:00 2001
From: Htylol <dixperm909@yandex.ru>
Date: Sat, 28 Sep 2024 01:27:31 +0500
Subject: [PATCH] Added PW_STOP_PORTWINE_RESTART

---
 data_from_portwine/scripts/functions_helper | 16 ++++++++++++++--
 data_from_portwine/scripts/start.sh         |  8 ++++----
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper
index 56b78706..2213d1d5 100755
--- a/data_from_portwine/scripts/functions_helper
+++ b/data_from_portwine/scripts/functions_helper
@@ -1266,7 +1266,11 @@ stop_portwine () {
     pw_auto_create_shortcut
     add_in_stop_portwine
     unset SKIP_CHECK_UPDATES
-    exit 0
+    if [[ "$PW_STOP_PORTWINE_RESTART" == 1 ]] ; then
+        restart_pp
+    else
+        exit 0
+    fi
 }
 export -f stop_portwine
 
@@ -2199,6 +2203,7 @@ pw_create_unique_exe () {
 }
 
 start_portwine () {
+    pw_skip_update_new
     if [[ "${PW_LOCALE_SELECT}" != "disabled" ]] && [[ -n "${PW_LOCALE_SELECT}" ]] ; then
         export LC_ALL="${PW_LOCALE_SELECT}"
         if [[ "${PW_USE_RUNTIME}" == "1" ]] && [[ "${HOST_LC_ALL}" != "${LC_ALL}" ]] ; then
@@ -3495,7 +3500,6 @@ pw_yad_form_vulkan () {
 }
 
 portwine_launch () {
-    pw_skip_update_new
     start_portwine
     unset PW_VD_TMP
     if [[ "${PW_VIRTUAL_DESKTOP}" == "1" ]] ; then
@@ -3526,11 +3530,15 @@ pw_winecfg () {
     start_portwine
     export GST_PLUGIN_SYSTEM_PATH_1_0=""
     pw_run winecfg
+    export PW_STOP_PORTWINE_RESTART=1
+    stop_portwine
 }
 
 pw_winefile () {
     start_portwine
     pw_run winefile
+    export PW_STOP_PORTWINE_RESTART=1
+    stop_portwine
 }
 
 pw_winecmd () {
@@ -3538,6 +3546,7 @@ pw_winecmd () {
     start_portwine
     cd "${PORT_WINE_PATH}/data/prefixes/${PW_PREFIX_NAME}/drive_c" || fatal
     pw_run cmd
+    export PW_STOP_PORTWINE_RESTART=1
     stop_portwine
 }
 
@@ -3545,6 +3554,8 @@ pw_winereg () {
     start_portwine
     export GST_PLUGIN_SYSTEM_PATH_1_0=""
     pw_run regedit
+    export PW_STOP_PORTWINE_RESTART=1
+    stop_portwine
 }
 
 pw_start_cont_xterm () {
@@ -3558,6 +3569,7 @@ pw_start_cont_xterm () {
     ${PW_GAMEMODERUN_SLR} \
     ${PW_MANGOHUD_SLR} \
     ${PW_TERM} bash
+    restart_pp
 }
 
 # GUI INFO
diff --git a/data_from_portwine/scripts/start.sh b/data_from_portwine/scripts/start.sh
index 21f142a0..1cebd139 100755
--- a/data_from_portwine/scripts/start.sh
+++ b/data_from_portwine/scripts/start.sh
@@ -102,7 +102,7 @@ unset PW_PREFIX_NAME WINEPREFIX VULKAN_MOD PW_WINE_VER PW_ADD_TO_ARGS_IN_RUNTIME
 unset PW_NAME_D_NAME PW_NAME_D_ICON PW_NAME_D_EXEC PW_EXEC_FROM_DESKTOP PW_ALL_DF PW_GENERATE_BUTTONS PW_NAME_D_ICON PW_NAME_D_ICON_48
 unset MANGOHUD_CONFIG FPS_LIMIT PW_WINE_USE WINEDLLPATH WINE WINEDIR WINELOADER WINESERVER PW_USE_RUNTIME PORTWINE_CREATE_SHORTCUT_NAME MIRROR
 unset PW_LOCALE_SELECT PW_SETTINGS_INDICATION PW_GUI_START PW_AUTOINSTALL_EXE NOSTSTDIR RADV_DEBUG PW_NO_AUTO_CREATE_SHORTCUT
-unset PW_DESKTOP_FILES_REGEX
+unset PW_DESKTOP_FILES_REGEX PW_STOP_PORTWINE_RESTART
 
 export PORT_WINE_TMP_PATH="${PORT_WINE_PATH}/data/tmp"
 rm -f "$PORT_WINE_TMP_PATH"/*{exe,msi,tar}*
@@ -660,7 +660,6 @@ else
         fi
         PW_GENERATE_BUTTONS+="--field=   $(print_wrapped "${PW_DESKTOP_FILES_SHOW//".desktop"/""}" "25" "...")!${PW_NAME_D_ICON_48}.png!:FBTN%@bash -c \"button_click --desktop "${PW_DESKTOP_FILES// /#@_@#}"\"%"
     done
-    IFS="$orig_IFS"
 
     IFS="%"
     "${pw_yad}" --plug=$KEY_MENU --tabnum="${PW_GUI_SORT_TABS[4]}" --form --columns="$MAIN_GUI_COLUMNS" --homogeneous-column \
@@ -813,7 +812,7 @@ fi
     gui_pw_reinstall_pp|open_changelog|\
     128|gui_pw_update|\
     change_loc|gui_open_scripts_from_backup|\
-    gui_credits)
+    gui_credits|pw_start_cont_xterm)
         if [[ -z "${PW_ALL_DF}" ]] ; then
             export TAB_MAIN_MENU="4"
         else
@@ -822,7 +821,8 @@ fi
         ;;
     gui_proton_downloader|WINETRICKS|\
     116|pw_create_prefix_backup|\
-    gui_clear_pfx)
+    gui_clear_pfx|WINEREG|WINECMD|\
+    WINEFILE|WINECFG)
         if [[ -z "${PW_ALL_DF}" ]] ; then
             export TAB_MAIN_MENU="3"
         else