diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index 48122b842..38f87280c 100644 --- a/Build/Notepad3.ini +++ b/Build/Notepad3.ini @@ -12,7 +12,6 @@ SettingsVersion=5 ;DefaultDirectory= ;DefaultExtension=txt ;DenyVirtualSpaceAccess=0 -;DrawAnimatedWindow=true ; true or undefined = use system settings, false = do not draw animated regardless of system settings ;filebrowser.exe=minipath.exe ;grepWin.exe=grepWinNP3.exe ;FileCheckInterval=2000 ;(min: 200[msec] - if equal or less, notify immediately) diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 1ff3c833c..181c01f2a 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -1314,8 +1314,6 @@ void LoadSettings() Settings2.IMEInteraction = ((codePage == 949 || codePage == 1361) ? SC_IME_INLINE : SC_IME_WINDOWED); } - Settings2.DrawAnimatedWindow = IniSectionGetBool(IniSecSettings2, L"DrawAnimatedWindow", true); - Settings2.LaunchInstanceWndPosOffset = clampi(IniSectionGetInt(IniSecSettings2, L"LaunchInstanceWndPosOffset", 28), -10000, 10000); Settings2.LaunchInstanceFullVisible = IniSectionGetBool(IniSecSettings2, L"LaunchInstanceFullVisible", true); diff --git a/src/Dialogs.c b/src/Dialogs.c index ef94b48b6..b88d30a5d 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -699,28 +699,32 @@ static bool GetTrayWndRect(LPRECT lpTrayRect) { // Check to see if the system animation has been enabled/disabled -static bool IsSystemDrawAnimation() +bool HasDrawAnimation() { ANIMATIONINFO ai = { sizeof(ANIMATIONINFO), 0 }; SystemParametersInfo(SPI_GETANIMATION, sizeof(ai), &ai, 0); return ai.iMinAnimate; } -bool HasDrawAnimation() { - return IsSystemDrawAnimation() && Settings2.DrawAnimatedWindow; +void MinimizeWndToTaskbar(HWND hWnd) +{ + ShowWindow(hWnd, SW_MINIMIZE); } -void MinimizeWndToTray(HWND hWnd) { +void MinimizeWndToTray(HWND hWnd) +{ + MinimizeWndToTaskbar(hWnd); if (HasDrawAnimation()) { // Get the rect of the window. It is safe to use the rect of the whole // window - DrawAnimatedRects will only draw the caption - RECT rcFrom; - GetWindowRect(hWnd, &rcFrom); - RECT rcTo; - GetTrayWndRect(&rcTo); + RECT rcMiniMized; + GetTrayWndRect(&rcMiniMized); + WINDOWPLACEMENT wp = { sizeof(WINDOWPLACEMENT) }; + GetWindowPlacement(hWnd, &wp); // Get the system to draw our animation for us - DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo); + Sleep(100); // but give SW_MINIMIZE some time to do its stuff + DrawAnimatedRects(hWnd, IDANI_CAPTION, &wp.rcNormalPosition, &rcMiniMized); } // Add the tray icon. If we add it before the call to DrawAnimatedRects, @@ -731,58 +735,42 @@ void MinimizeWndToTray(HWND hWnd) { // Hide the window ShowWindow(hWnd, SW_HIDE); - Globals.bMinimizedToTray = true; } -void MinimizeWndToTaskbar(HWND hWnd) + +void RestoreWndFromTaskbar(HWND hWnd) { - if (!Settings2.DrawAnimatedWindow) { - ShowWindow(hWnd, SW_HIDE); // hide first, before minimize - } - ShowWindow(hWnd, SW_MINIMIZE); - ShowWindow(hWnd, SW_SHOW); // show taskbar icon + ShowWindow(hWnd, SW_RESTORE); + SetActiveWindow(hWnd); + SetForegroundWindow(hWnd); } -void RestoreWndFromTray(HWND hWnd) { + +void RestoreWndFromTray(HWND hWnd) +{ + ShowWindow(hWnd, SW_SHOW); if (HasDrawAnimation()) { // Get the rect of the tray and the window. Note that the window rect // is still valid even though the window is hidden - RECT rcFrom; - GetTrayWndRect(&rcFrom); - RECT rcTo; - GetWindowRect(hWnd, &rcTo); - // needed, if minimized: WININFO wi = GetMyWindowPlacement(hWnd, NULL, 0, false); RectFromWinInfo(&wi, &rcTo); - // Get the system to draw our animation for us - DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo); + RECT rcMiniMized; + GetTrayWndRect(&rcMiniMized); + WINDOWPLACEMENT wp = { sizeof(WINDOWPLACEMENT) }; + GetWindowPlacement(hWnd, &wp); + DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcMiniMized, &wp.rcNormalPosition); } // Show the window, and make sure we're the foreground window - ShowWindow(hWnd, SW_SHOW); - - SetActiveWindow(hWnd); - SetForegroundWindow(hWnd); + RestoreWndFromTaskbar(hWnd); // Remove the tray icon. As described above, remove the icon after the // call to DrawAnimatedRects, or the taskbar will not refresh itself // properly until DAR finished ShowNotifyIcon(hWnd, false); - Globals.bMinimizedToTray = false; } -void RestoreWndFromTaskbar(HWND hWnd) -{ - if (!Settings2.DrawAnimatedWindow) { - ShowWindow(hWnd, SW_HIDE); // hide first, before restore - } - ShowWindow(hWnd, SW_RESTORE); - ShowWindow(hWnd, SW_SHOW); - - SetActiveWindow(hWnd); - SetForegroundWindow(hWnd); -} //============================================================================= diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 56dcf0b7c..7dea48669 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -771,7 +771,6 @@ typedef struct SETTINGS2_T { int WrapAroundTooltipTimeout; int LargeIconScalePrecent; int DarkModeHiglightContrast; - bool DrawAnimatedWindow; float AnalyzeReliableConfidenceLevel; float LocaleAnsiCodePageAnalysisBonus;