From 92864ea3600b5c0a787adcbf7d92b2af116e184c Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sat, 28 Jan 2012 18:44:19 +0000 Subject: [PATCH] Rainmeter.stats is now updated periodically only if NetTotal measure has been used in current session. --- Library/MeasureNet.cpp | 1 + Library/MeasureNet.h | 3 ++- Library/System.cpp | 6 +++++- Library/System.h | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Library/MeasureNet.cpp b/Library/MeasureNet.cpp index 56ef515b..2924e062 100644 --- a/Library/MeasureNet.cpp +++ b/Library/MeasureNet.cpp @@ -478,6 +478,7 @@ void CMeasureNet::ReadConfig(CConfigParser& parser, const WCHAR* section, NET ne { netName = L"NetTotalSpeed"; value = Rainmeter->GetGlobalConfig().netInSpeed + Rainmeter->GetGlobalConfig().netOutSpeed; + CSystem::SetNetworkStatisticsTimer(); } double maxValue = parser.ReadFloat(section, L"MaxValue", -1); diff --git a/Library/MeasureNet.h b/Library/MeasureNet.h index 3a16fc0f..9d7ea6c2 100644 --- a/Library/MeasureNet.h +++ b/Library/MeasureNet.h @@ -30,7 +30,8 @@ typedef VOID (NETIOAPI_API_ * FPFREEMIBTABLE)(PVOID Memory); class CMeasureNet : public CMeasure { public: - enum NET { + enum NET + { NET_IN, NET_OUT, NET_TOTAL diff --git a/Library/System.cpp b/Library/System.cpp index 35477d1d..07ff0044 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -124,7 +124,6 @@ void CSystem::Initialize(HINSTANCE instance) WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS); SetTimer(c_Window, TIMER_SHOWDESKTOP, INTERVAL_SHOWDESKTOP, NULL); - SetTimer(c_Window, TIMER_NETSTATS, INTERVAL_NETSTATS, NULL); SetTimer(c_Window, TIMER_DELETELATER, INTERVAL_DELETELATER, NULL); } @@ -159,6 +158,11 @@ void CSystem::Finalize() } } +void CSystem::SetNetworkStatisticsTimer() +{ + static bool set = SetTimer(c_Window, TIMER_NETSTATS, INTERVAL_NETSTATS, NULL); +} + /* ** MyInfoEnumProc ** diff --git a/Library/System.h b/Library/System.h index 9e3f638a..c239ea57 100644 --- a/Library/System.h +++ b/Library/System.h @@ -56,6 +56,8 @@ public: static void Initialize(HINSTANCE instance); static void Finalize(); + static void SetNetworkStatisticsTimer(); + static const MULTIMONITOR_INFO& GetMultiMonitorInfo() { return c_Monitors; } static size_t GetMonitorCount();