* Replaced if-else with switch-case
This commit is contained in:
spx 2013-02-06 18:55:45 +09:00
parent 2ea8710f58
commit e96b02d3dc
3 changed files with 324 additions and 301 deletions

View File

@ -2779,12 +2779,13 @@ void CMeterWindow::UpdateWindow(int alpha, bool reset)
*/ */
LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
if (wParam == TIMER_METER) switch (wParam)
{ {
case TIMER_METER:
Update(false); Update(false);
} break;
else if (wParam == TIMER_MOUSE)
{ case TIMER_MOUSE:
if (!Rainmeter->IsMenuActive() && !m_Dragging) if (!Rainmeter->IsMenuActive() && !m_Dragging)
{ {
ShowWindowIfAppropriate(); ShowWindowIfAppropriate();
@ -2822,72 +2823,77 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
} }
} }
} break;
else if (wParam == TIMER_TRANSITION)
{ case TIMER_TRANSITION:
// Redraw only if there is active transition still going
bool bActiveTransition = false;
std::vector<CMeter*>::const_iterator j = m_Meters.begin();
for ( ; j != m_Meters.end(); ++j)
{ {
if ((*j)->HasActiveTransition()) // Redraw only if there is active transition still going
bool bActiveTransition = false;
std::vector<CMeter*>::const_iterator j = m_Meters.begin();
for ( ; j != m_Meters.end(); ++j)
{ {
bActiveTransition = true; if ((*j)->HasActiveTransition())
break; {
bActiveTransition = true;
break;
}
} }
}
if (bActiveTransition) if (bActiveTransition)
{
Redraw();
}
else
{
// Stop the transition timer
KillTimer(m_Window, TIMER_TRANSITION);
m_ActiveTransition = false;
}
}
else if (wParam == TIMER_FADE)
{
ULONGLONG ticks = CSystem::GetTickCount64();
if (m_FadeStartTime == 0)
{
m_FadeStartTime = ticks;
}
if (ticks - m_FadeStartTime > (ULONGLONG)m_FadeDuration)
{
KillTimer(m_Window, TIMER_FADE);
m_FadeStartTime = 0;
if (m_FadeEndValue == 0)
{ {
ShowWindow(m_Window, SW_HIDE); Redraw();
} }
else else
{ {
UpdateWindow(m_FadeEndValue, false); // Stop the transition timer
KillTimer(m_Window, TIMER_TRANSITION);
m_ActiveTransition = false;
} }
} }
else break;
{
double value = (double)(__int64)(ticks - m_FadeStartTime);
value /= m_FadeDuration;
value *= m_FadeEndValue - m_FadeStartValue;
value += m_FadeStartValue;
value = min(value, 255);
value = max(value, 0);
UpdateWindow((int)value, false); case TIMER_FADE:
{
ULONGLONG ticks = CSystem::GetTickCount64();
if (m_FadeStartTime == 0)
{
m_FadeStartTime = ticks;
}
if (ticks - m_FadeStartTime > (ULONGLONG)m_FadeDuration)
{
KillTimer(m_Window, TIMER_FADE);
m_FadeStartTime = 0;
if (m_FadeEndValue == 0)
{
ShowWindow(m_Window, SW_HIDE);
}
else
{
UpdateWindow(m_FadeEndValue, false);
}
}
else
{
double value = (double)(__int64)(ticks - m_FadeStartTime);
value /= m_FadeDuration;
value *= m_FadeEndValue - m_FadeStartValue;
value += m_FadeStartValue;
value = min(value, 255);
value = max(value, 0);
UpdateWindow((int)value, false);
}
} }
} break;
else if (wParam == TIMER_DEACTIVATE)
{ case TIMER_DEACTIVATE:
if (m_FadeStartTime == 0) if (m_FadeStartTime == 0)
{ {
KillTimer(m_Window, TIMER_DEACTIVATE); KillTimer(m_Window, TIMER_DEACTIVATE);
Rainmeter->DeleteMeterWindow(this, true); // "delete this;" Rainmeter->DeleteMeterWindow(this, true); // "delete this;"
} }
break;
} }
return 0; return 0;
@ -3308,184 +3314,189 @@ LRESULT CMeterWindow::OnMouseHScrollMove(UINT uMsg, WPARAM wParam, LPARAM lParam
*/ */
LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
if (wParam == IDM_SKIN_EDITSKIN) switch (wParam)
{ {
case IDM_SKIN_EDITSKIN:
Rainmeter->EditSkinFile(m_FolderPath, m_FileName); Rainmeter->EditSkinFile(m_FolderPath, m_FileName);
} break;
else if (wParam == IDM_SKIN_REFRESH)
{ case IDM_SKIN_REFRESH:
Refresh(false); Refresh(false);
} break;
else if (wParam == IDM_SKIN_OPENSKINSFOLDER)
{ case IDM_SKIN_OPENSKINSFOLDER:
Rainmeter->OpenSkinFolder(m_FolderPath); Rainmeter->OpenSkinFolder(m_FolderPath);
} break;
else if (wParam == IDM_SKIN_MANAGESKIN)
{ case IDM_SKIN_MANAGESKIN:
CDialogManage::OpenSkin(this); CDialogManage::OpenSkin(this);
} break;
else if (wParam == IDM_SKIN_VERYTOPMOST)
{ case IDM_SKIN_VERYTOPMOST:
SetWindowZPosition(ZPOSITION_ONTOPMOST); SetWindowZPosition(ZPOSITION_ONTOPMOST);
} break;
else if (wParam == IDM_SKIN_TOPMOST)
{ case IDM_SKIN_TOPMOST:
SetWindowZPosition(ZPOSITION_ONTOP); SetWindowZPosition(ZPOSITION_ONTOP);
} break;
else if (wParam == IDM_SKIN_BOTTOM)
{ case IDM_SKIN_BOTTOM:
SetWindowZPosition(ZPOSITION_ONBOTTOM); SetWindowZPosition(ZPOSITION_ONBOTTOM);
} break;
else if (wParam == IDM_SKIN_NORMAL)
{ case IDM_SKIN_NORMAL:
SetWindowZPosition(ZPOSITION_NORMAL); SetWindowZPosition(ZPOSITION_NORMAL);
} break;
else if (wParam == IDM_SKIN_ONDESKTOP)
{ case IDM_SKIN_ONDESKTOP:
SetWindowZPosition(ZPOSITION_ONDESKTOP); SetWindowZPosition(ZPOSITION_ONDESKTOP);
} break;
else if (wParam == IDM_SKIN_KEEPONSCREEN)
{ case IDM_SKIN_KEEPONSCREEN:
SetKeepOnScreen(!m_KeepOnScreen); SetKeepOnScreen(!m_KeepOnScreen);
} break;
else if (wParam == IDM_SKIN_CLICKTHROUGH)
{ case IDM_SKIN_CLICKTHROUGH:
SetClickThrough(!m_ClickThrough); SetClickThrough(!m_ClickThrough);
} break;
else if (wParam == IDM_SKIN_DRAGGABLE)
{ case IDM_SKIN_DRAGGABLE:
SetWindowDraggable(!m_WindowDraggable); SetWindowDraggable(!m_WindowDraggable);
} break;
else if (wParam == IDM_SKIN_HIDEONMOUSE)
{ case IDM_SKIN_HIDEONMOUSE:
SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_HIDE : HIDEMODE_NONE); SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_HIDE : HIDEMODE_NONE);
} break;
else if (wParam == IDM_SKIN_TRANSPARENCY_FADEIN)
{ case IDM_SKIN_TRANSPARENCY_FADEIN:
SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_FADEIN : HIDEMODE_NONE); SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_FADEIN : HIDEMODE_NONE);
} break;
else if (wParam == IDM_SKIN_TRANSPARENCY_FADEOUT)
{ case IDM_SKIN_TRANSPARENCY_FADEOUT:
SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_FADEOUT : HIDEMODE_NONE); SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_FADEOUT : HIDEMODE_NONE);
} break;
else if (wParam == IDM_SKIN_REMEMBERPOSITION)
{ case IDM_SKIN_REMEMBERPOSITION:
SetSavePosition(!m_SavePosition); SetSavePosition(!m_SavePosition);
} break;
else if (wParam == IDM_SKIN_SNAPTOEDGES)
{ case IDM_SKIN_SNAPTOEDGES:
SetSnapEdges(!m_SnapEdges); SetSnapEdges(!m_SnapEdges);
} break;
else if (wParam >= IDM_SKIN_TRANSPARENCY_0 && wParam <= IDM_SKIN_TRANSPARENCY_90)
{ case IDM_CLOSESKIN:
m_AlphaValue = (int)(255.0 - (wParam - IDM_SKIN_TRANSPARENCY_0) * (230.0 / (IDM_SKIN_TRANSPARENCY_90 - IDM_SKIN_TRANSPARENCY_0)));
UpdateWindow(m_AlphaValue, false);
WriteOptions(OPTION_ALPHAVALUE);
}
else if (wParam == IDM_CLOSESKIN)
{
Rainmeter->DeactivateSkin(this, -1); Rainmeter->DeactivateSkin(this, -1);
} break;
else if (wParam == IDM_SKIN_FROMRIGHT)
{ case IDM_SKIN_FROMRIGHT:
m_WindowXFromRight = !m_WindowXFromRight; m_WindowXFromRight = !m_WindowXFromRight;
ScreenToWindow(); ScreenToWindow();
WriteOptions(OPTION_POSITION); WriteOptions(OPTION_POSITION);
} break;
else if (wParam == IDM_SKIN_FROMBOTTOM)
{ case IDM_SKIN_FROMBOTTOM:
m_WindowYFromBottom = !m_WindowYFromBottom; m_WindowYFromBottom = !m_WindowYFromBottom;
ScreenToWindow(); ScreenToWindow();
WriteOptions(OPTION_POSITION); WriteOptions(OPTION_POSITION);
} break;
else if (wParam == IDM_SKIN_XPERCENTAGE)
{ case IDM_SKIN_XPERCENTAGE:
m_WindowXPercentage = !m_WindowXPercentage; m_WindowXPercentage = !m_WindowXPercentage;
ScreenToWindow(); ScreenToWindow();
WriteOptions(OPTION_POSITION); WriteOptions(OPTION_POSITION);
} break;
else if (wParam == IDM_SKIN_YPERCENTAGE)
{ case IDM_SKIN_YPERCENTAGE:
m_WindowYPercentage = !m_WindowYPercentage; m_WindowYPercentage = !m_WindowYPercentage;
ScreenToWindow(); ScreenToWindow();
WriteOptions(OPTION_POSITION); WriteOptions(OPTION_POSITION);
} break;
else if (wParam == IDM_SKIN_MONITOR_AUTOSELECT)
{ case IDM_SKIN_MONITOR_AUTOSELECT:
m_AutoSelectScreen = !m_AutoSelectScreen; m_AutoSelectScreen = !m_AutoSelectScreen;
ScreenToWindow(); ScreenToWindow();
WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN); WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN);
} break;
else if (wParam == IDM_SKIN_MONITOR_PRIMARY || wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST)
{
const MultiMonitorInfo& multimonInfo = CSystem::GetMultiMonitorInfo();
const std::vector<MonitorInfo>& monitors = multimonInfo.monitors;
int screenIndex; default:
bool screenDefined; if (wParam >= IDM_SKIN_TRANSPARENCY_0 && wParam <= IDM_SKIN_TRANSPARENCY_90)
if (wParam == IDM_SKIN_MONITOR_PRIMARY)
{ {
screenIndex = multimonInfo.primary; m_AlphaValue = (int)(255.0 - (wParam - IDM_SKIN_TRANSPARENCY_0) * (230.0 / (IDM_SKIN_TRANSPARENCY_90 - IDM_SKIN_TRANSPARENCY_0)));
screenDefined = false; UpdateWindow(m_AlphaValue, false);
WriteOptions(OPTION_ALPHAVALUE);
}
else if (wParam == IDM_SKIN_MONITOR_PRIMARY || wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST)
{
const MultiMonitorInfo& monitorsInfo = CSystem::GetMultiMonitorInfo();
const std::vector<MonitorInfo>& monitors = monitorsInfo.monitors;
int screenIndex;
bool screenDefined;
if (wParam == IDM_SKIN_MONITOR_PRIMARY)
{
screenIndex = monitorsInfo.primary;
screenDefined = false;
}
else
{
screenIndex = (wParam & 0x0ffff) - ID_MONITOR_FIRST;
screenDefined = true;
}
if (screenIndex >= 0 && (screenIndex == 0 || screenIndex <= (int)monitors.size() && monitors[screenIndex-1].active))
{
m_AutoSelectScreen = false;
m_WindowXScreen = m_WindowYScreen = screenIndex;
m_WindowXScreenDefined = m_WindowYScreenDefined = screenDefined;
m_Parser.ResetMonitorVariables(this); // Set present monitor variables
ScreenToWindow();
WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN);
}
}
else if (wParam >= IDM_SKIN_CUSTOMCONTEXTMENU_FIRST && wParam <= IDM_SKIN_CUSTOMCONTEXTMENU_LAST)
{
std::wstring action;
int position = (int)wParam - IDM_SKIN_CUSTOMCONTEXTMENU_FIRST + 1;
if (position == 1)
{
action = m_Parser.ReadString(L"Rainmeter", L"ContextAction", L"", false);
}
else
{
WCHAR buffer[128];
_snwprintf_s(buffer, _TRUNCATE, L"ContextAction%i", position);
action = m_Parser.ReadString(L"Rainmeter", buffer, L"", false);
}
if (!action.empty())
{
Rainmeter->ExecuteCommand(action.c_str(), this);
}
} }
else else
{ {
screenIndex = (wParam & 0x0ffff) - ID_MONITOR_FIRST; // Forward to tray window, which handles all the other commands
screenDefined = true; HWND tray = Rainmeter->GetTrayWindow()->GetWindow();
}
if (screenIndex >= 0 && (screenIndex == 0 || screenIndex <= (int)monitors.size() && monitors[screenIndex-1].active)) if (wParam == IDM_QUIT)
{ {
m_AutoSelectScreen = false; PostMessage(tray, WM_COMMAND, wParam, lParam);
}
m_WindowXScreen = m_WindowYScreen = screenIndex; else
m_WindowXScreenDefined = m_WindowYScreenDefined = screenDefined; {
SendMessage(tray, WM_COMMAND, wParam, lParam);
m_Parser.ResetMonitorVariables(this); // Set present monitor variables }
ScreenToWindow();
WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN);
}
}
else if (wParam >= IDM_SKIN_CUSTOMCONTEXTMENU_FIRST && wParam <= IDM_SKIN_CUSTOMCONTEXTMENU_LAST)
{
std::wstring action;
int position = (int)wParam - IDM_SKIN_CUSTOMCONTEXTMENU_FIRST + 1;
if (position == 1)
{
action = m_Parser.ReadString(L"Rainmeter", L"ContextAction", L"", false);
}
else
{
WCHAR buffer[128];
_snwprintf_s(buffer, _TRUNCATE, L"ContextAction%i", position);
action = m_Parser.ReadString(L"Rainmeter", buffer, L"", false);
}
if (!action.empty())
{
Rainmeter->ExecuteCommand(action.c_str(), this);
}
}
else
{
// Forward to tray window, which handles all the other commands
HWND tray = Rainmeter->GetTrayWindow()->GetWindow();
if (wParam == IDM_QUIT)
{
PostMessage(tray, WM_COMMAND, wParam, lParam);
}
else
{
SendMessage(tray, WM_COMMAND, wParam, lParam);
} }
break;
} }
return 0; return 0;

View File

@ -995,7 +995,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
ClearMultiMonitorInfo(); ClearMultiMonitorInfo();
CConfigParser::ClearMultiMonitorVariables(); CConfigParser::ClearMultiMonitorVariables();
case WM_SETTINGCHANGE: case WM_SETTINGCHANGE:
if (uMsg == WM_DISPLAYCHANGE || (uMsg == WM_SETTINGCHANGE && wParam == SPI_SETWORKAREA)) if (uMsg == WM_DISPLAYCHANGE || (/*uMsg == WM_SETTINGCHANGE &&*/ wParam == SPI_SETWORKAREA))
{ {
if (uMsg == WM_SETTINGCHANGE) // SPI_SETWORKAREA if (uMsg == WM_SETTINGCHANGE) // SPI_SETWORKAREA
{ {

View File

@ -464,156 +464,170 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
switch (uMsg) switch (uMsg)
{ {
case WM_COMMAND: case WM_COMMAND:
if (wParam == IDM_MANAGE) switch (wParam)
{ {
case IDM_MANAGE:
CDialogManage::Open(); CDialogManage::Open();
} break;
else if (wParam == IDM_ABOUT)
{ case IDM_ABOUT:
CDialogAbout::Open(); CDialogAbout::Open();
} break;
else if (wParam == IDM_SHOW_HELP)
{ case IDM_SHOW_HELP:
RunFile(RAINMETER_HELP); RunFile(RAINMETER_HELP);
} break;
else if (wParam == IDM_NEW_VERSION)
{ case IDM_NEW_VERSION:
RunFile(RAINMETER_OFFICIAL); RunFile(RAINMETER_OFFICIAL);
} break;
else if (wParam == IDM_REFRESH)
{ case IDM_REFRESH:
PostMessage(Rainmeter->GetWindow(), WM_RAINMETER_DELAYED_REFRESH_ALL, (WPARAM)NULL, (LPARAM)NULL); PostMessage(Rainmeter->GetWindow(), WM_RAINMETER_DELAYED_REFRESH_ALL, (WPARAM)NULL, (LPARAM)NULL);
} break;
else if (wParam == IDM_SHOWLOGFILE)
{ case IDM_SHOWLOGFILE:
Rainmeter->ShowLogFile(); Rainmeter->ShowLogFile();
} break;
else if (wParam == IDM_STARTLOG)
{ case IDM_STARTLOG:
Rainmeter->StartLogging(); Rainmeter->StartLogging();
} break;
else if (wParam == IDM_STOPLOG)
{ case IDM_STOPLOG:
Rainmeter->StopLogging(); Rainmeter->StopLogging();
} break;
else if (wParam == IDM_DELETELOGFILE)
{ case IDM_DELETELOGFILE:
Rainmeter->DeleteLogFile(); Rainmeter->DeleteLogFile();
} break;
else if (wParam == IDM_DEBUGLOG)
{ case IDM_DEBUGLOG:
Rainmeter->SetDebug(!Rainmeter->GetDebug()); Rainmeter->SetDebug(!Rainmeter->GetDebug());
} break;
else if (wParam == IDM_DISABLEDRAG)
{ case IDM_DISABLEDRAG:
Rainmeter->SetDisableDragging(!Rainmeter->GetDisableDragging()); Rainmeter->SetDisableDragging(!Rainmeter->GetDisableDragging());
} break;
else if (wParam == IDM_EDITCONFIG)
{ case IDM_EDITCONFIG:
Rainmeter->EditSettings(); Rainmeter->EditSettings();
} break;
else if (wParam == IDM_QUIT)
{ case IDM_QUIT:
PostQuitMessage(0); PostQuitMessage(0);
} break;
else if (wParam == IDM_OPENSKINSFOLDER)
{ case IDM_OPENSKINSFOLDER:
Rainmeter->OpenSkinFolder(); Rainmeter->OpenSkinFolder();
} break;
else
{
UINT mID = wParam & 0x0FFFF;
if (mID >= ID_THEME_FIRST && mID <= ID_THEME_LAST) default:
{ {
int pos = mID - ID_THEME_FIRST; UINT mID = wParam & 0x0FFFF;
const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts(); if (mID >= ID_THEME_FIRST && mID <= ID_THEME_LAST)
if (pos >= 0 && pos < (int)layouts.size())
{ {
Rainmeter->LoadLayout(layouts[pos]); int pos = mID - ID_THEME_FIRST;
}
}
else if (mID >= ID_CONFIG_FIRST && mID <= ID_CONFIG_LAST)
{
std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(mID);
if (indexes.first != -1 && indexes.second != -1)
{
Rainmeter->ToggleSkin(indexes.first, indexes.second);
}
}
else
{
// Forward the message to correct window
int index = (int)(wParam >> 16);
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
if (index < (int)windows.size()) const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts();
{ if (pos >= 0 && pos < (int)layouts.size())
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
for ( ; iter != windows.end(); ++iter)
{ {
--index; Rainmeter->LoadLayout(layouts[pos]);
if (index < 0) }
}
else if (mID >= ID_CONFIG_FIRST && mID <= ID_CONFIG_LAST)
{
std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(mID);
if (indexes.first != -1 && indexes.second != -1)
{
Rainmeter->ToggleSkin(indexes.first, indexes.second);
}
}
else
{
// Forward the message to correct window
int index = (int)(wParam >> 16);
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
if (index < (int)windows.size())
{
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
for ( ; iter != windows.end(); ++iter)
{ {
CMeterWindow* meterWindow = (*iter).second; --index;
SendMessage(meterWindow->GetWindow(), WM_COMMAND, mID, NULL); if (index < 0)
break; {
CMeterWindow* meterWindow = (*iter).second;
SendMessage(meterWindow->GetWindow(), WM_COMMAND, mID, NULL);
break;
}
} }
} }
} }
} }
break;
} }
break; // Don't send WM_COMMANDS any further break; // Don't send WM_COMMANDS any further
case WM_TRAY_NOTIFYICON: case WM_TRAY_NOTIFYICON:
{ {
UINT uMouseMsg = (UINT)lParam; UINT uMouseMsg = (UINT)lParam;
std::wstring bang; LPCWSTR bang;
// Check TrayExecute actions
switch (uMouseMsg) switch (uMouseMsg)
{ {
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
bang = Rainmeter->GetTrayExecuteM(); bang = Rainmeter->GetTrayExecuteM().c_str();
break; break;
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
bang = Rainmeter->GetTrayExecuteR(); bang = Rainmeter->GetTrayExecuteR().c_str();
break; break;
case WM_MBUTTONDBLCLK: case WM_MBUTTONDBLCLK:
bang = Rainmeter->GetTrayExecuteDM(); bang = Rainmeter->GetTrayExecuteDM().c_str();
break; break;
case WM_RBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
bang = Rainmeter->GetTrayExecuteDR(); bang = Rainmeter->GetTrayExecuteDR().c_str();
break;
default:
bang = L"";
break; break;
} }
if (!bang.empty() && if (*bang &&
!IsCtrlKeyDown()) // Ctrl is pressed, so only run default action !IsCtrlKeyDown()) // Ctrl is pressed, so only run default action
{ {
Rainmeter->ExecuteCommand(bang.c_str(), NULL); Rainmeter->ExecuteCommand(bang, NULL);
tray->m_TrayContextMenuEnabled = (uMouseMsg != WM_RBUTTONDOWN); tray->m_TrayContextMenuEnabled = (uMouseMsg != WM_RBUTTONDOWN);
break;
} }
else if (uMouseMsg == WM_RBUTTONDOWN)
// Run default UI action
switch (uMouseMsg)
{ {
case WM_RBUTTONDOWN:
tray->m_TrayContextMenuEnabled = true; tray->m_TrayContextMenuEnabled = true;
} break;
else if (uMouseMsg == WM_RBUTTONUP)
{ case WM_RBUTTONUP:
if (tray->m_TrayContextMenuEnabled) if (tray->m_TrayContextMenuEnabled)
{ {
POINT pos = CSystem::GetCursorPosition(); POINT pos = CSystem::GetCursorPosition();
Rainmeter->ShowContextMenu(pos, NULL); Rainmeter->ShowContextMenu(pos, NULL);
} }
} break;
else if (uMouseMsg == WM_LBUTTONUP || uMouseMsg == WM_LBUTTONDBLCLK)
{ case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
CDialogManage::Open(); CDialogManage::Open();
} break;
else if (uMouseMsg == NIN_BALLOONUSERCLICK)
{ case NIN_BALLOONUSERCLICK:
if (tray->m_Notification == TRAY_NOTIFICATION_WELCOME) if (tray->m_Notification == TRAY_NOTIFICATION_WELCOME)
{ {
CDialogManage::Open(); CDialogManage::Open();
@ -622,12 +636,13 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{ {
RunFile(RAINMETER_OFFICIAL); RunFile(RAINMETER_OFFICIAL);
} }
tray->m_Notification = TRAY_NOTIFICATION_NONE;
break;
case NIN_BALLOONHIDE:
case NIN_BALLOONTIMEOUT:
tray->m_Notification = TRAY_NOTIFICATION_NONE; tray->m_Notification = TRAY_NOTIFICATION_NONE;
} break;
else if (uMouseMsg == NIN_BALLOONHIDE || uMouseMsg == NIN_BALLOONTIMEOUT)
{
tray->m_Notification = TRAY_NOTIFICATION_NONE;
} }
} }
break; break;
@ -644,40 +659,37 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds); SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
}; };
if (wParam == RAINMETER_QUERY_ID_SKINS_PATH) switch (wParam)
{ {
case RAINMETER_QUERY_ID_SKINS_PATH:
sendCopyData(Rainmeter->GetSkinPath()); sendCopyData(Rainmeter->GetSkinPath());
return 0; return 0;
}
else if (wParam == RAINMETER_QUERY_ID_SETTINGS_PATH) case RAINMETER_QUERY_ID_SETTINGS_PATH:
{
sendCopyData(Rainmeter->GetSettingsPath()); sendCopyData(Rainmeter->GetSettingsPath());
return 0; return 0;
}
else if (wParam == RAINMETER_QUERY_ID_PLUGINS_PATH) case RAINMETER_QUERY_ID_PLUGINS_PATH:
{
sendCopyData(Rainmeter->GetPluginPath()); sendCopyData(Rainmeter->GetPluginPath());
return 0; return 0;
}
else if (wParam == RAINMETER_QUERY_ID_PROGRAM_PATH) case RAINMETER_QUERY_ID_PROGRAM_PATH:
{
sendCopyData(Rainmeter->GetPath()); sendCopyData(Rainmeter->GetPath());
return 0; return 0;
}
else if (wParam == RAINMETER_QUERY_ID_LOG_PATH) case RAINMETER_QUERY_ID_LOG_PATH:
{
sendCopyData(Rainmeter->GetLogFile()); sendCopyData(Rainmeter->GetLogFile());
return 0; return 0;
}
else if (wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR) case RAINMETER_QUERY_ID_CONFIG_EDITOR:
{
sendCopyData(Rainmeter->GetSkinEditor()); sendCopyData(Rainmeter->GetSkinEditor());
return 0; return 0;
}
else if (wParam == RAINMETER_QUERY_ID_IS_DEBUGGING) case RAINMETER_QUERY_ID_IS_DEBUGGING:
{ {
BOOL debug = Rainmeter->GetDebug(); BOOL debug = Rainmeter->GetDebug();
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM)debug); SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM)debug);
}
return 0; return 0;
} }
} }