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
f4bfe8f4fc
commit
9c75cf3423
@ -567,8 +567,8 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
|
|||||||
{
|
{
|
||||||
if (CSystem::GetShowDesktop())
|
if (CSystem::GetShowDesktop())
|
||||||
{
|
{
|
||||||
// Insert after the tray window temporarily to keep order
|
// Insert after the system window temporarily to keep order
|
||||||
winPos = m_Rainmeter->GetTrayWindow()->GetWindow();
|
winPos = CSystem::GetWindow();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -588,29 +588,29 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
|
|||||||
// Set WS_EX_TOPMOST flag
|
// Set WS_EX_TOPMOST flag
|
||||||
SetWindowPos(m_Window, HWND_TOPMOST, 0, 0, 0, 0, ZPOS_FLAGS);
|
SetWindowPos(m_Window, HWND_TOPMOST, 0, 0, 0, 0, ZPOS_FLAGS);
|
||||||
|
|
||||||
|
winPos = CSystem::GetHelperWindow();
|
||||||
|
|
||||||
if (all)
|
if (all)
|
||||||
{
|
{
|
||||||
// Insert after the helper window
|
// Insert after the helper window
|
||||||
SetWindowPos(m_Window, CSystem::GetHelperWindow(), 0, 0, 0, 0, ZPOS_FLAGS);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Find the "backmost" topmost window
|
// Find the "backmost" topmost window
|
||||||
HWND hwnd = CSystem::GetHelperWindow();
|
while (winPos = ::GetNextWindow(winPos, GW_HWNDPREV))
|
||||||
while (hwnd = ::GetNextWindow(hwnd, GW_HWNDPREV))
|
|
||||||
{
|
{
|
||||||
if (GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
|
if (GetWindowLong(winPos, GWL_EXSTYLE) & WS_EX_TOPMOST)
|
||||||
{
|
{
|
||||||
// Insert after the found window
|
// Insert after the found window
|
||||||
if (0 != SetWindowPos(m_Window, hwnd, 0, 0, 0, 0, ZPOS_FLAGS))
|
if (0 != SetWindowPos(m_Window, winPos, 0, 0, 0, 0, ZPOS_FLAGS))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (all)
|
if (all)
|
||||||
|
@ -243,7 +243,7 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
|
|||||||
|
|
||||||
if (subStrings.size() >= 1)
|
if (subStrings.size() >= 1)
|
||||||
{
|
{
|
||||||
std::wstring config = subStrings[0];
|
const std::wstring& config = subStrings[0];
|
||||||
|
|
||||||
CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config);
|
CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config);
|
||||||
if (meterWindow)
|
if (meterWindow)
|
||||||
@ -266,12 +266,12 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
|
|||||||
|
|
||||||
if (subStrings.size() >= 2)
|
if (subStrings.size() >= 2)
|
||||||
{
|
{
|
||||||
std::wstring config = subStrings[0];
|
const std::wstring& config = subStrings[0];
|
||||||
|
|
||||||
CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config);
|
CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config);
|
||||||
if (meterWindow)
|
if (meterWindow)
|
||||||
{
|
{
|
||||||
std::wstring variable = subStrings[1];
|
const std::wstring& variable = subStrings[1];
|
||||||
std::wstring result_from_parser;
|
std::wstring result_from_parser;
|
||||||
|
|
||||||
if (meterWindow->GetParser().GetVariable(variable, result_from_parser))
|
if (meterWindow->GetParser().GetVariable(variable, result_from_parser))
|
||||||
@ -295,7 +295,7 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
|
|||||||
|
|
||||||
if (subStrings.size() >= 2)
|
if (subStrings.size() >= 2)
|
||||||
{
|
{
|
||||||
std::wstring config = subStrings[0];
|
const std::wstring& config = subStrings[0];
|
||||||
std::wstring arguments;
|
std::wstring arguments;
|
||||||
|
|
||||||
for (size_t i = 1; i < subStrings.size(); ++i)
|
for (size_t i = 1; i < subStrings.size(); ++i)
|
||||||
@ -334,7 +334,7 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
|
|||||||
|
|
||||||
if (subStrings.size() >= 1)
|
if (subStrings.size() >= 1)
|
||||||
{
|
{
|
||||||
std::wstring config = subStrings[0];
|
const std::wstring& config = subStrings[0];
|
||||||
|
|
||||||
CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config);
|
CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config);
|
||||||
if (meterWindow)
|
if (meterWindow)
|
||||||
@ -1581,21 +1581,21 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Instance = Instance;
|
m_Instance = Instance;
|
||||||
WCHAR tmpName[MAX_LINE_LENGTH];
|
WCHAR tmpSz[MAX_LINE_LENGTH];
|
||||||
GetModuleFileName(m_Instance, tmpName, MAX_LINE_LENGTH);
|
GetModuleFileName(m_Instance, tmpSz, MAX_LINE_LENGTH);
|
||||||
|
|
||||||
// Remove the module's name from the path
|
// Remove the module's name from the path
|
||||||
WCHAR* pos = wcsrchr(tmpName, L'\\');
|
WCHAR* pos = wcsrchr(tmpSz, L'\\');
|
||||||
if(pos)
|
if(pos)
|
||||||
{
|
{
|
||||||
*(pos + 1) = L'\0';
|
*(pos + 1) = L'\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmpName[0] = L'\0';
|
tmpSz[0] = L'\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Path = tmpName;
|
m_Path = tmpSz;
|
||||||
|
|
||||||
if(!c_DummyLitestep) InitalizeLitestep();
|
if(!c_DummyLitestep) InitalizeLitestep();
|
||||||
|
|
||||||
@ -1690,21 +1690,30 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
|||||||
m_SkinPath += L"Skins\\";
|
m_SkinPath += L"Skins\\";
|
||||||
|
|
||||||
// Read the skin folder from the ini file
|
// Read the skin folder from the ini file
|
||||||
WCHAR tmpSz[MAX_LINE_LENGTH];
|
tmpSz[0] = L'\0';
|
||||||
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
||||||
{
|
{
|
||||||
m_SkinPath = tmpSz;
|
m_SkinPath = tmpSz;
|
||||||
ExpandEnvironmentVariables(m_SkinPath);
|
ExpandEnvironmentVariables(m_SkinPath);
|
||||||
|
|
||||||
|
if (!m_SkinPath.empty())
|
||||||
|
{
|
||||||
|
WCHAR ch = m_SkinPath[m_SkinPath.size() - 1];
|
||||||
|
if (ch != L'\\' && ch != L'/')
|
||||||
|
{
|
||||||
|
m_SkinPath += L"\\";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (bDefaultIniLocation)
|
else if (bDefaultIniLocation)
|
||||||
{
|
{
|
||||||
// If the skin path is not defined in the Rainmeter.ini file use My Documents/Rainmeter/Skins
|
// If the skin path is not defined in the Rainmeter.ini file use My Documents/Rainmeter/Skins
|
||||||
TCHAR szPath[MAX_PATH] = {0};
|
tmpSz[0] = L'\0';
|
||||||
HRESULT hr = SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, szPath);
|
HRESULT hr = SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, tmpSz);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
// Make the folders if they don't exist yet
|
// Make the folders if they don't exist yet
|
||||||
m_SkinPath = szPath;
|
m_SkinPath = tmpSz;
|
||||||
m_SkinPath += L"\\Rainmeter";
|
m_SkinPath += L"\\Rainmeter";
|
||||||
CreateDirectory(m_SkinPath.c_str(), NULL);
|
CreateDirectory(m_SkinPath.c_str(), NULL);
|
||||||
m_SkinPath += L"\\Skins\\";
|
m_SkinPath += L"\\Skins\\";
|
||||||
@ -3070,6 +3079,8 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
|
|||||||
*/
|
*/
|
||||||
void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
||||||
{
|
{
|
||||||
|
WCHAR buffer[MAX_PATH];
|
||||||
|
|
||||||
// Clear old settings
|
// Clear old settings
|
||||||
m_DesktopWorkAreas.clear();
|
m_DesktopWorkAreas.clear();
|
||||||
|
|
||||||
@ -3100,8 +3111,8 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
|||||||
if (m_ConfigEditor.empty())
|
if (m_ConfigEditor.empty())
|
||||||
{
|
{
|
||||||
// Get the program path associated with .ini files
|
// Get the program path associated with .ini files
|
||||||
WCHAR buffer[MAX_PATH] = {0};
|
|
||||||
DWORD cchOut = MAX_PATH;
|
DWORD cchOut = MAX_PATH;
|
||||||
|
buffer[0] = L'\0';
|
||||||
|
|
||||||
HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".ini", L"open", buffer, &cchOut);
|
HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".ini", L"open", buffer, &cchOut);
|
||||||
if (SUCCEEDED(hr) && cchOut > 0)
|
if (SUCCEEDED(hr) && cchOut > 0)
|
||||||
@ -3123,8 +3134,8 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
|||||||
if (m_LogViewer.empty())
|
if (m_LogViewer.empty())
|
||||||
{
|
{
|
||||||
// Get the program path associated with .log files
|
// Get the program path associated with .log files
|
||||||
WCHAR buffer[MAX_PATH] = {0};
|
|
||||||
DWORD cchOut = MAX_PATH;
|
DWORD cchOut = MAX_PATH;
|
||||||
|
buffer[0] = L'\0';
|
||||||
|
|
||||||
HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".log", L"open", buffer, &cchOut);
|
HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".log", L"open", buffer, &cchOut);
|
||||||
if (SUCCEEDED(hr) && cchOut > 0)
|
if (SUCCEEDED(hr) && cchOut > 0)
|
||||||
@ -3916,11 +3927,7 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
|
|||||||
for (int i = 0; i < itemCount; ++i)
|
for (int i = 0; i < itemCount; ++i)
|
||||||
{
|
{
|
||||||
WCHAR buffer[MAX_PATH] = {0};
|
WCHAR buffer[MAX_PATH] = {0};
|
||||||
MENUITEMINFO itemInfo = {sizeof(MENUITEMINFO)};
|
if (GetMenuString(configMenu, i, buffer, MAX_PATH, MF_BYPOSITION))
|
||||||
itemInfo.fMask = MIIM_STRING;
|
|
||||||
itemInfo.dwTypeData = buffer;
|
|
||||||
itemInfo.cch = MAX_PATH;
|
|
||||||
if (GetMenuItemInfo(configMenu, (UINT)i, TRUE, &itemInfo))
|
|
||||||
{
|
{
|
||||||
if (_wcsicmp(root.c_str(), buffer) == 0)
|
if (_wcsicmp(root.c_str(), buffer) == 0)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ enum INTERVAL
|
|||||||
{
|
{
|
||||||
INTERVAL_SHOWDESKTOP = 250,
|
INTERVAL_SHOWDESKTOP = 250,
|
||||||
INTERVAL_COMPOSITION = 250,
|
INTERVAL_COMPOSITION = 250,
|
||||||
INTERVAL_NETSTATS = 10000,
|
INTERVAL_NETSTATS = 60000,
|
||||||
INTERVAL_DELETELATER = 1000
|
INTERVAL_DELETELATER = 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -106,6 +106,7 @@ void CSystem::Initialize(HINSTANCE instance)
|
|||||||
SetWindowPos(c_Window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
|
SetWindowPos(c_Window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
|
||||||
SetWindowPos(c_HelperWindow, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
|
SetWindowPos(c_HelperWindow, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
|
||||||
|
|
||||||
|
c_Monitors.monitors.reserve(8);
|
||||||
SetMultiMonitorInfo();
|
SetMultiMonitorInfo();
|
||||||
|
|
||||||
c_DwmCompositionEnabled = (DwmIsCompositionEnabled() == TRUE);
|
c_DwmCompositionEnabled = (DwmIsCompositionEnabled() == TRUE);
|
||||||
@ -256,8 +257,6 @@ void CSystem::SetMultiMonitorInfo()
|
|||||||
std::vector<MONITOR_INFO>& monitors = c_Monitors.monitors;
|
std::vector<MONITOR_INFO>& monitors = c_Monitors.monitors;
|
||||||
bool logging = CRainmeter::GetDebug();
|
bool logging = CRainmeter::GetDebug();
|
||||||
|
|
||||||
if (monitors.capacity() < 16) { monitors.reserve(16); }
|
|
||||||
|
|
||||||
c_Monitors.vsT = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
c_Monitors.vsT = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||||
c_Monitors.vsL = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
c_Monitors.vsL = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||||
c_Monitors.vsH = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
c_Monitors.vsH = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||||
@ -765,6 +764,8 @@ void CSystem::PrepareHelperWindow(HWND WorkerW)
|
|||||||
{
|
{
|
||||||
bool logging = CRainmeter::GetDebug() && DEBUG_VERBOSE;
|
bool logging = CRainmeter::GetDebug() && DEBUG_VERBOSE;
|
||||||
|
|
||||||
|
SetWindowPos(c_Window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); // always on bottom
|
||||||
|
|
||||||
if (c_ShowDesktop && WorkerW)
|
if (c_ShowDesktop && WorkerW)
|
||||||
{
|
{
|
||||||
// Set WS_EX_TOPMOST flag
|
// Set WS_EX_TOPMOST flag
|
||||||
@ -886,7 +887,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||||||
{
|
{
|
||||||
static int DesktopCompositionCheckCount = 0;
|
static int DesktopCompositionCheckCount = 0;
|
||||||
|
|
||||||
if (uMsg == WM_CREATE || hWnd != c_Window)
|
if (hWnd != c_Window)
|
||||||
{
|
{
|
||||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
@ -272,6 +272,8 @@ HICON CTrayWindow::CreateTrayIcon(double value)
|
|||||||
|
|
||||||
void CTrayWindow::ReadConfig(CConfigParser& parser)
|
void CTrayWindow::ReadConfig(CConfigParser& parser)
|
||||||
{
|
{
|
||||||
|
KillTimer(m_Window, TRAYTIMER);
|
||||||
|
|
||||||
delete m_Measure;
|
delete m_Measure;
|
||||||
m_Measure = NULL;
|
m_Measure = NULL;
|
||||||
|
|
||||||
@ -371,9 +373,13 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
|
|||||||
if (trayIcon != 0)
|
if (trayIcon != 0)
|
||||||
{
|
{
|
||||||
AddTrayIcon();
|
AddTrayIcon();
|
||||||
|
|
||||||
|
if (m_Measure)
|
||||||
|
{
|
||||||
SetTimer(m_Window, TRAYTIMER, 1000, NULL); // Update the tray once per sec
|
SetTimer(m_Window, TRAYTIMER, 1000, NULL); // Update the tray once per sec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user