https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e68bee751847c704ae554687519f5baa47375f95

commit e68bee751847c704ae554687519f5baa47375f95
Author:     Serge Gautherie <[email protected]>
AuthorDate: Fri Jan 24 14:47:58 2020 +0100
Commit:     Giannis Adamopoulos <[email protected]>
CommitDate: Sun Apr 26 21:41:39 2020 +0300

    [EXPLORER] trayclock: Better handle timers, especially when it is hidden
---
 base/shell/explorer/trayclock.cpp | 43 +++++++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 11 deletions(-)

diff --git a/base/shell/explorer/trayclock.cpp 
b/base/shell/explorer/trayclock.cpp
index 45a673693cc..e2ccc4a4a87 100644
--- a/base/shell/explorer/trayclock.cpp
+++ b/base/shell/explorer/trayclock.cpp
@@ -452,8 +452,7 @@ BOOL CTrayClockWnd::ResetTime()
         KillTimer(ID_TRAYCLOCK_TIMER);
         IsTimerEnabled = FALSE;
     }
-
-    if (IsInitTimerEnabled)
+    else if (IsInitTimerEnabled)
     {
         KillTimer(ID_TRAYCLOCK_TIMER_INIT);
     }
@@ -464,9 +463,6 @@ BOOL CTrayClockWnd::ResetTime()
     Ret = SetTimer(ID_TRAYCLOCK_TIMER_INIT, uiDueTime, NULL) != 0;
     IsInitTimerEnabled = Ret;
 
-    /* Update the time */
-    Update();
-
     return Ret;
 }
 
@@ -500,9 +496,6 @@ VOID CTrayClockWnd::CalibrateTimer()
             uiWait2. */
         Ret = SetTimer(ID_TRAYCLOCK_TIMER, uiWait2, NULL) != 0;
         IsTimerEnabled = Ret;
-
-        /* Update the time */
-        Update();
     }
     else
     {
@@ -510,6 +503,9 @@ VOID CTrayClockWnd::CalibrateTimer()
             minute/second ends. */
         ResetTime();
     }
+
+    /* Update the time */
+    Update();
 }
 
 LRESULT CTrayClockWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, 
BOOL& bHandled)
@@ -519,8 +515,7 @@ LRESULT CTrayClockWnd::OnDestroy(UINT uMsg, WPARAM wParam, 
LPARAM lParam, BOOL&
     {
         KillTimer(ID_TRAYCLOCK_TIMER);
     }
-
-    if (IsInitTimerEnabled)
+    else if (IsInitTimerEnabled)
     {
         KillTimer(ID_TRAYCLOCK_TIMER_INIT);
     }
@@ -668,7 +663,14 @@ LRESULT CTrayClockWnd::OnCreate(UINT uMsg, WPARAM wParam, 
LPARAM lParam, BOOL& b
 
     m_tooltip.AddTool(&ti);
 
-    ResetTime();
+    if (!g_TaskbarSettings.sr.HideClock)
+    {
+        ResetTime();
+    }
+
+    /* Update the time */
+    Update();
+
     return TRUE;
 }
 
@@ -702,6 +704,25 @@ LRESULT CTrayClockWnd::OnTaskbarSettingsChanged(UINT uMsg, 
WPARAM wParam, LPARAM
         g_TaskbarSettings.sr.HideClock = newSettings->sr.HideClock;
         ShowWindow(g_TaskbarSettings.sr.HideClock ? SW_HIDE : SW_SHOW);
         bRealign = TRUE;
+
+        if (g_TaskbarSettings.sr.HideClock)
+        {
+            /* Disable all timers */
+            if (IsTimerEnabled)
+            {
+                KillTimer(ID_TRAYCLOCK_TIMER);
+                IsTimerEnabled = FALSE;
+            }
+            else if (IsInitTimerEnabled)
+            {
+                KillTimer(ID_TRAYCLOCK_TIMER_INIT);
+                IsInitTimerEnabled = FALSE;
+            }
+        }
+        else
+        {
+            ResetTime();
+        }
     }
 
     if (bRealign)

Reply via email to