mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Code cleanup
This commit is contained in:
parent
33b8c49d1a
commit
f929109f01
@ -38,7 +38,7 @@ typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
|
|||||||
#define Li2Double(x) ((double)((x).QuadPart))
|
#define Li2Double(x) ((double)((x).QuadPart))
|
||||||
#define Ft2Double(x) ((double)((x).dwHighDateTime) * 4.294967296E9 + (double)((x).dwLowDateTime))
|
#define Ft2Double(x) ((double)((x).dwHighDateTime) * 4.294967296E9 + (double)((x).dwLowDateTime))
|
||||||
|
|
||||||
PROCNTQSI CMeasureCPU::c_NtQuerySystemInformation = NULL;
|
FPNTQSI CMeasureCPU::c_NtQuerySystemInformation = NULL;
|
||||||
int CMeasureCPU::c_NumOfProcessors = 0;
|
int CMeasureCPU::c_NumOfProcessors = 0;
|
||||||
ULONG CMeasureCPU::c_BufferSize = 0;
|
ULONG CMeasureCPU::c_BufferSize = 0;
|
||||||
|
|
||||||
@ -69,17 +69,6 @@ CMeasureCPU::CMeasureCPU(CMeterWindow* meterWindow, const WCHAR* name) : CMeasur
|
|||||||
m_OldTime()
|
m_OldTime()
|
||||||
{
|
{
|
||||||
m_MaxValue = 100.0;
|
m_MaxValue = 100.0;
|
||||||
|
|
||||||
if (c_NtQuerySystemInformation == NULL)
|
|
||||||
{
|
|
||||||
c_NtQuerySystemInformation = (PROCNTQSI)GetProcAddress(GetModuleHandle(L"ntdll"), "NtQuerySystemInformation");
|
|
||||||
}
|
|
||||||
if (c_NumOfProcessors == 0)
|
|
||||||
{
|
|
||||||
SYSTEM_INFO systemInfo;
|
|
||||||
GetSystemInfo(&systemInfo);
|
|
||||||
c_NumOfProcessors = (int)systemInfo.dwNumberOfProcessors;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -189,7 +178,7 @@ void CMeasureCPU::UpdateValue()
|
|||||||
c_BufferSize = bufSize;
|
c_BufferSize = bufSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* systemPerfInfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*)buf;
|
PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION systemPerfInfo = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)buf;
|
||||||
|
|
||||||
int processor = m_Processor - 1;
|
int processor = m_Processor - 1;
|
||||||
|
|
||||||
@ -217,3 +206,16 @@ void CMeasureCPU::CalcUsage(double idleTime, double systemTime)
|
|||||||
m_OldTime[0] = idleTime;
|
m_OldTime[0] = idleTime;
|
||||||
m_OldTime[1] = systemTime;
|
m_OldTime[1] = systemTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMeasureCPU::InitializeStatic()
|
||||||
|
{
|
||||||
|
c_NtQuerySystemInformation = (FPNTQSI)GetProcAddress(GetModuleHandle(L"ntdll"), "NtQuerySystemInformation");
|
||||||
|
|
||||||
|
SYSTEM_INFO systemInfo;
|
||||||
|
GetSystemInfo(&systemInfo);
|
||||||
|
c_NumOfProcessors = (int)systemInfo.dwNumberOfProcessors;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMeasureCPU::FinalizeStatic()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "Measure.h"
|
#include "Measure.h"
|
||||||
|
|
||||||
typedef LONG (WINAPI *PROCNTQSI)(UINT,PVOID,ULONG,PULONG);
|
typedef LONG (WINAPI *FPNTQSI)(UINT, PVOID, ULONG, PULONG);
|
||||||
|
|
||||||
class CMeasureCPU : public CMeasure
|
class CMeasureCPU : public CMeasure
|
||||||
{
|
{
|
||||||
@ -31,6 +31,9 @@ public:
|
|||||||
|
|
||||||
virtual UINT GetTypeID() { return TypeID<CMeasureCPU>(); }
|
virtual UINT GetTypeID() { return TypeID<CMeasureCPU>(); }
|
||||||
|
|
||||||
|
static void InitializeStatic();
|
||||||
|
static void FinalizeStatic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
||||||
virtual void UpdateValue();
|
virtual void UpdateValue();
|
||||||
@ -42,7 +45,7 @@ private:
|
|||||||
|
|
||||||
double m_OldTime[2];
|
double m_OldTime[2];
|
||||||
|
|
||||||
static PROCNTQSI c_NtQuerySystemInformation;
|
static FPNTQSI c_NtQuerySystemInformation;
|
||||||
|
|
||||||
static int c_NumOfProcessors;
|
static int c_NumOfProcessors;
|
||||||
static ULONG c_BufferSize;
|
static ULONG c_BufferSize;
|
||||||
|
@ -689,7 +689,7 @@ void CMeasureNet::WriteStats(const WCHAR* iniFile, const std::wstring& statsDate
|
|||||||
** Prepares in order to use the new APIs which are available on Vista or newer.
|
** Prepares in order to use the new APIs which are available on Vista or newer.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
void CMeasureNet::InitializeNewApi()
|
void CMeasureNet::InitializeStatic()
|
||||||
{
|
{
|
||||||
if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
|
if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
|
||||||
{
|
{
|
||||||
@ -717,7 +717,7 @@ void CMeasureNet::InitializeNewApi()
|
|||||||
** Frees the resources.
|
** Frees the resources.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
void CMeasureNet::FinalizeNewApi()
|
void CMeasureNet::FinalizeStatic()
|
||||||
{
|
{
|
||||||
if (c_GetIfTable2)
|
if (c_GetIfTable2)
|
||||||
{
|
{
|
||||||
|
@ -39,8 +39,8 @@ public:
|
|||||||
static void ReadStats(const std::wstring& iniFile, std::wstring& statsDate);
|
static void ReadStats(const std::wstring& iniFile, std::wstring& statsDate);
|
||||||
static void WriteStats(const WCHAR* iniFile, const std::wstring& statsDate);
|
static void WriteStats(const WCHAR* iniFile, const std::wstring& statsDate);
|
||||||
|
|
||||||
static void InitializeNewApi();
|
static void InitializeStatic();
|
||||||
static void FinalizeNewApi();
|
static void FinalizeStatic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum NET
|
enum NET
|
||||||
|
@ -30,6 +30,8 @@ std::unordered_map<std::wstring, Gdiplus::Font*> CMeterString::c_Fonts;
|
|||||||
#define PI (3.14159265f)
|
#define PI (3.14159265f)
|
||||||
#define CONVERT_TO_DEGREES(X) ((X) * (180.0f / PI))
|
#define CONVERT_TO_DEGREES(X) ((X) * (180.0f / PI))
|
||||||
|
|
||||||
|
extern CRainmeter* Rainmeter;
|
||||||
|
|
||||||
void StringToUpper(std::wstring& str)
|
void StringToUpper(std::wstring& str)
|
||||||
{
|
{
|
||||||
WCHAR* srcAndDest = &str[0];
|
WCHAR* srcAndDest = &str[0];
|
||||||
@ -859,4 +861,20 @@ void CMeterString::EnumerateInstalledFontFamilies()
|
|||||||
{
|
{
|
||||||
Log(LOG_ERROR, L"Font enumeration: InstalledFontCollection failed");
|
Log(LOG_ERROR, L"Font enumeration: InstalledFontCollection failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMeterString::InitializeStatic()
|
||||||
|
{
|
||||||
|
if (Rainmeter->GetDebug())
|
||||||
|
{
|
||||||
|
Log(LOG_DEBUG, L"------------------------------");
|
||||||
|
Log(LOG_DEBUG, L"* Font families:");
|
||||||
|
EnumerateInstalledFontFamilies();
|
||||||
|
Log(LOG_DEBUG, L"------------------------------");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMeterString::FinalizeStatic()
|
||||||
|
{
|
||||||
|
FreeFontCache();
|
||||||
|
}
|
||||||
|
@ -43,6 +43,9 @@ public:
|
|||||||
static void FreeFontCache(Gdiplus::PrivateFontCollection* collection = NULL);
|
static void FreeFontCache(Gdiplus::PrivateFontCollection* collection = NULL);
|
||||||
static void EnumerateInstalledFontFamilies();
|
static void EnumerateInstalledFontFamilies();
|
||||||
|
|
||||||
|
static void InitializeStatic();
|
||||||
|
static void FinalizeStatic();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
||||||
virtual void BindMeasures(CConfigParser& parser, const WCHAR* section);
|
virtual void BindMeasures(CConfigParser& parser, const WCHAR* section);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "DialogAbout.h"
|
#include "DialogAbout.h"
|
||||||
#include "DialogManage.h"
|
#include "DialogManage.h"
|
||||||
#include "MeasureNet.h"
|
#include "MeasureNet.h"
|
||||||
|
#include "MeasureCPU.h"
|
||||||
#include "MeterString.h"
|
#include "MeterString.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "UpdateCheck.h"
|
#include "UpdateCheck.h"
|
||||||
@ -738,9 +739,9 @@ CRainmeter::~CRainmeter()
|
|||||||
CMeasureNet::UpdateStats();
|
CMeasureNet::UpdateStats();
|
||||||
WriteStats(true);
|
WriteStats(true);
|
||||||
|
|
||||||
CMeasureNet::FinalizeNewApi();
|
CMeasureNet::FinalizeStatic();
|
||||||
|
CMeasureCPU::FinalizeStatic();
|
||||||
CMeterString::FreeFontCache();
|
CMeterString::FinalizeStatic();
|
||||||
|
|
||||||
// Change the work area back
|
// Change the work area back
|
||||||
if (m_DesktopWorkAreaChanged)
|
if (m_DesktopWorkAreaChanged)
|
||||||
@ -993,13 +994,10 @@ int CRainmeter::Initialize(LPCWSTR iniPath, LPCWSTR layout)
|
|||||||
TestSettingsFile(bDefaultIniLocation);
|
TestSettingsFile(bDefaultIniLocation);
|
||||||
|
|
||||||
CSystem::Initialize(m_Instance);
|
CSystem::Initialize(m_Instance);
|
||||||
CMeasureNet::InitializeNewApi();
|
|
||||||
|
|
||||||
if (m_Debug)
|
CMeasureNet::InitializeStatic();
|
||||||
{
|
CMeasureCPU::InitializeStatic();
|
||||||
Log(LOG_DEBUG, L"Enumerating font families...");
|
CMeterString::InitializeStatic();
|
||||||
CMeterString::EnumerateInstalledFontFamilies();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tray must exist before skins are read
|
// Tray must exist before skins are read
|
||||||
m_TrayWindow = new CTrayWindow();
|
m_TrayWindow = new CTrayWindow();
|
||||||
|
Loading…
Reference in New Issue
Block a user