From 94b1145f7a831f701268713a0f8ca027dcb692bc Mon Sep 17 00:00:00 2001 From: jsmorley Date: Tue, 7 Feb 2012 19:13:59 +0000 Subject: [PATCH] Fixed for !DeactivateConfig. Default of current config broken in 1172. --- Library/Rainmeter.cpp | 36 ++++++++++++++++++++++-------------- Library/Rainmeter.h | 4 ++-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index bd7f9786..fb8ee038 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -325,19 +325,23 @@ void CRainmeter::Bang_ActivateConfig(const WCHAR* arg) ** !DeactivateConfig bang ** */ -void CRainmeter::Bang_DeactivateConfig(const WCHAR* arg) +void CRainmeter::Bang_DeactivateConfig(const WCHAR* arg, CMeterWindow* meterWindow) { std::vector subStrings = ParseString(arg); if (!subStrings.empty()) { - CMeterWindow* mw = GetMeterWindow(subStrings[0]); - if (mw) + meterWindow = GetMeterWindow(subStrings[0]); + if (!meterWindow) { - DeactivateConfig(mw, -1); + LogWithArgs(LOG_WARNING, L"!DeactivateConfig: \"%s\" not active", subStrings[0].c_str()); return; } - LogWithArgs(LOG_WARNING, L"!DeactivateConfig: \"%s\" not active", subStrings[0].c_str()); + } + + if (meterWindow) + { + DeactivateConfig(meterWindow, -1); } else { @@ -450,21 +454,25 @@ void CRainmeter::Bang_SetWallpaper(const WCHAR* arg) ** !SkinMenu bang ** */ -void CRainmeter::Bang_SkinMenu(const WCHAR* arg) +void CRainmeter::Bang_SkinMenu(const WCHAR* arg, CMeterWindow* meterWindow) { std::vector subStrings = ParseString(arg); if (!subStrings.empty()) { - CMeterWindow* mw = GetMeterWindow(subStrings[0]); - if (mw) + meterWindow = GetMeterWindow(subStrings[0]); + if (!meterWindow) { - POINT pos; - GetCursorPos(&pos); - ShowContextMenu(pos, mw); + LogWithArgs(LOG_WARNING, L"!SkinMenu: \"%s\" not active", subStrings[0].c_str()); return; } - LogWithArgs(LOG_WARNING, L"!SkinMenu: \"%s\" not active", subStrings[0].c_str()); + } + + if (meterWindow) + { + POINT pos; + GetCursorPos(&pos); + ShowContextMenu(pos, meterWindow); } else { @@ -1622,7 +1630,7 @@ void CRainmeter::ExecuteBang(const std::wstring& name, std::wstring& arg, CMeter } else if (_wcsicmp(bang, L"DeactivateConfig") == 0) { - Bang_DeactivateConfig(args); + Bang_DeactivateConfig(args, meterWindow); } else if (_wcsicmp(bang, L"ToggleConfig") == 0) { @@ -1794,7 +1802,7 @@ void CRainmeter::ExecuteBang(const std::wstring& name, std::wstring& arg, CMeter } else if (_wcsicmp(bang, L"SkinMenu") == 0) { - Bang_SkinMenu(args); + Bang_SkinMenu(args, meterWindow); } else if (_wcsicmp(bang, L"TrayMenu") == 0) { diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index 97292264..744f39af 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -217,12 +217,12 @@ private: void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs, CMeterWindow* meterWindow); void BangGroupWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs, CMeterWindow* meterWindow); void Bang_ActivateConfig(const WCHAR* arg); - void Bang_DeactivateConfig(const WCHAR* arg); + void Bang_DeactivateConfig(const WCHAR* arg, CMeterWindow* meterWindow); void Bang_ToggleConfig(const WCHAR* arg); void Bang_DeactivateConfigGroup(const WCHAR* arg); void Bang_SetClip(const WCHAR* arg); void Bang_SetWallpaper(const WCHAR* arg); - void Bang_SkinMenu(const WCHAR* arg); + void Bang_SkinMenu(const WCHAR* arg, CMeterWindow* meterWindow); void Bang_TrayMenu(); void Bang_WriteKeyValue(const WCHAR* arg, CMeterWindow* meterWindow);