From b0046d2968112d4c1d2fe564c7bbbb7202212a89 Mon Sep 17 00:00:00 2001 From: spx Date: Mon, 20 Feb 2012 09:37:46 +0000 Subject: [PATCH] Cosmetic changes. --- Library/Litestep.cpp | 11 ----------- Library/MeasureDiskSpace.cpp | 1 - Library/MeterButton.cpp | 2 +- Library/MeterWindow.cpp | 18 +++++++++--------- Library/StdAfx.h | 5 +++++ Library/TrayWindow.cpp | 2 +- Plugins/PluginWebParser/WebParser.cpp | 7 ++++--- 7 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Library/Litestep.cpp b/Library/Litestep.cpp index 7b6cdb6b..e93dec77 100644 --- a/Library/Litestep.cpp +++ b/Library/Litestep.cpp @@ -355,17 +355,6 @@ void LogInternal(int nLevel, ULONGLONG elapsed, LPCTSTR pszMessage) } } -BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage) -{ - // Ignore LOG_DEBUG messages from plugins unless in debug mode - if (nLevel != LOG_DEBUG || Rainmeter->GetDebug()) - { - Log(nLevel, pszMessage); - } - - return TRUE; -} - void Log(int nLevel, const WCHAR* message) { struct DELAYED_LOG_INFO diff --git a/Library/MeasureDiskSpace.cpp b/Library/MeasureDiskSpace.cpp index 68eae4b2..7c01eb70 100644 --- a/Library/MeasureDiskSpace.cpp +++ b/Library/MeasureDiskSpace.cpp @@ -120,7 +120,6 @@ bool CMeasureDiskSpace::Update() { UINT oldMode = SetErrorMode(0); SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); // Prevent the system from displaying message box - SetLastError(ERROR_SUCCESS); sizeResult = GetDiskFreeSpaceEx(drive, NULL, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes); SetErrorMode(oldMode); // Reset } diff --git a/Library/MeterButton.cpp b/Library/MeterButton.cpp index 749ec123..3af44231 100644 --- a/Library/MeterButton.cpp +++ b/Library/MeterButton.cpp @@ -312,7 +312,7 @@ bool CMeterButton::MouseMove(POINT pos) else { // If the left button is not down anymore the clicked state needs to be set false - if (!(GetKeyState(VK_LBUTTON) < 0)) + if (!IsLButtonDown()) { m_Clicked = false; } diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 114a91d7..1a654e58 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -2947,7 +2947,7 @@ void CMeterWindow::UpdateTransparency(int alpha, bool reset) SetWindowLong(m_Window, GWL_EXSTYLE, style | WS_EX_LAYERED); } - BLENDFUNCTION blendPixelFunction= {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA}; + BLENDFUNCTION blendPixelFunction = {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA}; POINT ptWindowScreenPosition = {m_ScreenX, m_ScreenY}; POINT ptSrc = {0, 0}; SIZE szWindow = {m_DIBSectionBufferW, m_DIBSectionBufferH}; @@ -3037,7 +3037,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam) } else { - bool keyDown = GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_SHIFT) < 0 || GetKeyState(VK_MENU) < 0; + bool keyDown = IsCtrlKeyDown() || IsShiftKeyDown() || IsAltKeyDown(); if (!keyDown || GetWindowFromPoint(pos) != m_Window) { @@ -3111,7 +3111,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam) if (m_FadeStartTime == 0) { KillTimer(m_Window, TIMER_DEACTIVATE); - Rainmeter->DeleteMeterWindow(this, true); + Rainmeter->DeleteMeterWindow(this, true); // "delete this;" } } @@ -3184,7 +3184,7 @@ void CMeterWindow::ShowFade() */ void CMeterWindow::ShowWindowIfAppropriate() { - bool keyDown = GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_SHIFT) < 0 || GetKeyState(VK_MENU) < 0; + bool keyDown = IsCtrlKeyDown() || IsShiftKeyDown() || IsAltKeyDown(); POINT pos; GetCursorPos(&pos); @@ -3407,7 +3407,7 @@ LRESULT CMeterWindow::OnEnterMenuLoop(UINT uMsg, WPARAM wParam, LPARAM lParam) */ LRESULT CMeterWindow::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam) { - bool keyDown = GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_SHIFT) < 0 || GetKeyState(VK_MENU) < 0; + bool keyDown = IsCtrlKeyDown() || IsShiftKeyDown() || IsAltKeyDown(); if (!keyDown) { @@ -3956,7 +3956,7 @@ LRESULT CMeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lPara if ((wp->flags & SWP_NOMOVE) == 0) { - if (m_SnapEdges && !(GetKeyState(VK_CONTROL) < 0 || GetKeyState(VK_SHIFT) < 0)) + if (m_SnapEdges && !(IsCtrlKeyDown() || IsShiftKeyDown())) { // only process movement (ignore anything without winpos values) if (wp->cx != 0 && wp->cy != 0) @@ -4153,7 +4153,7 @@ LRESULT CMeterWindow::OnLeftButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam) // Handle buttons HandleButtons(pos, BUTTONPROC_DOWN); - if (GetKeyState(VK_CONTROL) < 0 || // Ctrl is pressed, so only run default action + if (IsCtrlKeyDown() || // Ctrl is pressed, so only run default action (!DoAction(pos.x, pos.y, MOUSE_LMB_DOWN, false) && m_WindowDraggable)) { // Cancel the mouse event beforehand @@ -4262,7 +4262,7 @@ LRESULT CMeterWindow::OnRightButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam) // Handle buttons HandleButtons(pos, BUTTONPROC_MOVE); - if (GetKeyState(VK_CONTROL) < 0 || // Ctrl is pressed, so only run default action + if (IsCtrlKeyDown() || // Ctrl is pressed, so only run default action !DoAction(pos.x, pos.y, MOUSE_RMB_UP, false)) { // Run the DefWindowProc so the context menu works @@ -4412,7 +4412,7 @@ LRESULT CMeterWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam) HandleButtons(posc, BUTTONPROC_MOVE); // If RMB up or RMB down or double-click cause actions, do not show the menu! - if (!(GetKeyState(VK_CONTROL) < 0) && // Ctrl is pressed, so ignore any actions + if (!IsCtrlKeyDown() && // Ctrl is pressed, so ignore any actions (DoAction(posc.x, posc.y, MOUSE_RMB_UP, false) || DoAction(posc.x, posc.y, MOUSE_RMB_DOWN, true) || DoAction(posc.x, posc.y, MOUSE_RMB_DBLCLK, true))) { return 0; diff --git a/Library/StdAfx.h b/Library/StdAfx.h index 818df970..1988ad72 100644 --- a/Library/StdAfx.h +++ b/Library/StdAfx.h @@ -59,4 +59,9 @@ // RUNTIME #include +// ADDITIONAL MACRO +#define IsCtrlKeyDown() (GetKeyState(VK_CONTROL) < 0) +#define IsShiftKeyDown() (GetKeyState(VK_SHIFT) < 0) +#define IsAltKeyDown() (GetKeyState(VK_MENU) < 0) + #endif diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index 335fe96d..5e8b81e4 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -557,7 +557,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA break; } - if (!(GetKeyState(VK_CONTROL) < 0) && // Ctrl is pressed, so only run default action + if (!IsCtrlKeyDown() && // Ctrl is pressed, so only run default action !bang.empty()) { Rainmeter->ExecuteCommand(bang.c_str(), NULL); diff --git a/Plugins/PluginWebParser/WebParser.cpp b/Plugins/PluginWebParser/WebParser.cpp index 160d2545..cdda8276 100644 --- a/Plugins/PluginWebParser/WebParser.cpp +++ b/Plugins/PluginWebParser/WebParser.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -69,7 +69,7 @@ static std::vector g_Measures; static bool g_Debug = false; static HINTERNET g_InternetHandle = NULL; -static std::map g_CERs; +static std::unordered_map g_CERs; #define OVECCOUNT 300 // should be a multiple of 3 @@ -217,7 +217,7 @@ std::wstring& DecodeReferences(std::wstring& str, int opt) std::wstring name(str, pos, end - pos); - std::map::const_iterator iter = g_CERs.find(name); + std::unordered_map::const_iterator iter = g_CERs.find(name); if (iter != g_CERs.end()) { str.replace(start, end - start + 1, 1, (*iter).second); @@ -504,6 +504,7 @@ void FillCharacterEntityReferences() }; const int entityCount = _countof(entities); + g_CERs.rehash(entityCount); for (int i = 0; i < entityCount; ++i) { g_CERs.insert(std::pair(entities[i].name, entities[i].ch));