Skip to content

Commit

Permalink
Merge pull request rizonesoft#5199 from RaiKoHoff/Dev_Master
Browse files Browse the repository at this point in the history
Due to problems,  remove "DrawAnimatedWindow" settings feature ...
  • Loading branch information
hpwamr committed May 28, 2024
2 parents 6541a32 + c16ca28 commit 23895b2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 44 deletions.
1 change: 0 additions & 1 deletion Build/Notepad3.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/Config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
68 changes: 28 additions & 40 deletions src/Dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}


//=============================================================================
Expand Down
1 change: 0 additions & 1 deletion src/TypeDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,6 @@ typedef struct SETTINGS2_T {
int WrapAroundTooltipTimeout;
int LargeIconScalePrecent;
int DarkModeHiglightContrast;
bool DrawAnimatedWindow;

float AnalyzeReliableConfidenceLevel;
float LocaleAnsiCodePageAnalysisBonus;
Expand Down

0 comments on commit 23895b2

Please sign in to comment.