From 01ac603abc5d626220ddba5bbfac4dc8fe207309 Mon Sep 17 00:00:00 2001 From: Martin Prikryl Date: Sat, 26 Jul 2025 10:40:20 +0000 Subject: [PATCH] =?UTF-8?q?Issue=202393=20=E2=80=93=20When=20restored=20af?= =?UTF-8?q?ter=20operation=20completed=20while=20minimized=20the=20window?= =?UTF-8?q?=20is=20disabled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://winscp.net/tracker/2393 Source commit: 4a7927649c3234d1b162cd2f3ad740f8745ba1af --- source/forms/CustomScpExplorer.cpp | 2 ++ source/windows/WinInterface.cpp | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/source/forms/CustomScpExplorer.cpp b/source/forms/CustomScpExplorer.cpp index d7cd1b919..3980831c4 100644 --- a/source/forms/CustomScpExplorer.cpp +++ b/source/forms/CustomScpExplorer.cpp @@ -10384,6 +10384,7 @@ void __fastcall TCustomScpExplorerForm::LockWindow(bool Force) // Shouldn't we use IsApplicationMinimized() here? if ((FLockSuspendLevel == 0) && !IsIconic(Application->Handle) && (Force || (Screen->ActiveForm == this))) { + AppLog(L"Disabling window"); Enabled = false; } @@ -10398,6 +10399,7 @@ void __fastcall TCustomScpExplorerForm::UnlockWindow() if (FLockLevel == 0) { DebugAssert(FLockSuspendLevel == 0); + AppLog(L"Re-enabling window"); Enabled = true; // VCL_COPY (TCustomForm.SetWindowFocus) if (Active && (ActiveControl != NULL)) diff --git a/source/windows/WinInterface.cpp b/source/windows/WinInterface.cpp index 3c282753c..7a99b11ad 100644 --- a/source/windows/WinInterface.cpp +++ b/source/windows/WinInterface.cpp @@ -1315,7 +1315,28 @@ static void __fastcall DoApplicationMinimizeRestore(bool Minimize) { if (Minimize) { - Application->Minimize(); + // WORKAROUND: + // VCL enables minimized windows (why?) and restores the previous disabled state on restore. + // But if we meanwhile re-enable the window (like when transfer finishes while minimized), + // the VCL will re-disable the window on restore. + // (This does not help in scenario, then the main window is minimized with its own title's minimize window, + // but then it should not be disabled in the first place) + bool WasDisabled = !MainForm->Enabled; + if (WasDisabled) + { + MainForm->Enabled = true; + } + try + { + Application->Minimize(); + } + __finally + { + if (WasDisabled) + { + MainForm->Enabled = false; + } + } MinimizedToTray = WinConfiguration->MinimizeToTray; } else