+rm: remove "DrawAnimatedWindow" settings feature and rely on system window animation configuration

This commit is contained in:
METANEOCORTEX\Kotti 2024-05-28 01:40:55 +02:00
parent 6541a3201d
commit c16ca28dc9
4 changed files with 28 additions and 44 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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);
}
//=============================================================================

View File

@ -771,7 +771,6 @@ typedef struct SETTINGS2_T {
int WrapAroundTooltipTimeout;
int LargeIconScalePrecent;
int DarkModeHiglightContrast;
bool DrawAnimatedWindow;
float AnalyzeReliableConfidenceLevel;
float LocaleAnsiCodePageAnalysisBonus;