From aecef0b5f9221a97789824a979e6ed5059893211 Mon Sep 17 00:00:00 2001 From: spx Date: Mon, 11 Mar 2013 04:59:05 +0900 Subject: [PATCH] Additional changes to af8befd --- Library/MeterWindow.cpp | 19 ++++++++++++++----- Library/MeterWindow.h | 12 +++++++++++- Library/Rainmeter.cpp | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index d7771dc2..4dab1327 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -137,7 +137,7 @@ CMeterWindow::CMeterWindow(const std::wstring& folderPath, const std::wstring& f m_FadeStartValue(), m_FadeEndValue(), m_TransparencyValue(), - m_Refreshing(false), + m_State(STATE_INITIALIZING), m_Hidden(false), m_ResizeWindow(RESIZEMODE_NONE), m_UpdateCounter(), @@ -215,6 +215,8 @@ void CMeterWindow::Dispose(bool refresh) KillTimer(m_Window, TIMER_FADE); KillTimer(m_Window, TIMER_TRANSITION); + m_FadeStartTime = 0; + UnregisterMouseInput(); m_HasMouseScrollAction = false; @@ -389,6 +391,8 @@ void CMeterWindow::RemoveWindowExStyle(LONG_PTR flag) */ void CMeterWindow::Deactivate() { + m_State = STATE_CLOSING; + Rainmeter->RemoveMeterWindow(this); HideFade(); @@ -403,6 +407,9 @@ void CMeterWindow::Refresh(bool init, bool all) { assert(Rainmeter != NULL); + if (m_State == STATE_CLOSING) return; + m_State = STATE_REFRESHING; + Rainmeter->SetCurrentParser(&m_Parser); std::wstring notice = L"Refreshing skin \"" + m_FolderPath; @@ -411,7 +418,6 @@ void CMeterWindow::Refresh(bool init, bool all) notice += L'"'; Log(LOG_NOTICE, notice.c_str()); - m_Refreshing = true; SetResizeWindowMode(RESIZEMODE_RESET); if (!init) @@ -473,7 +479,7 @@ void CMeterWindow::Refresh(bool init, bool all) Rainmeter->SetCurrentParser(NULL); - m_Refreshing = false; + m_State = STATE_RUNNING; if (!m_OnRefreshAction.empty()) { @@ -3375,7 +3381,10 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam) break; case IDM_CLOSESKIN: - Rainmeter->DeactivateSkin(this, -1); + if (m_State != STATE_CLOSING) + { + Rainmeter->DeactivateSkin(this, -1); + } break; case IDM_SKIN_FROMRIGHT: @@ -3718,7 +3727,7 @@ LRESULT CMeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lPara { LPWINDOWPOS wp = (LPWINDOWPOS)lParam; - if (!m_Refreshing) + if (m_State != STATE_REFRESHING) { if (m_WindowZPosition == ZPOSITION_NORMAL && Rainmeter->IsNormalStayDesktop() && CSystem::GetShowDesktop()) { diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 8fa6ad00..b38f1ec3 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -237,6 +237,8 @@ public: bool GetMeterToolTipHidden() { return m_ToolTipHidden; } + bool IsClosing() { return m_State == STATE_CLOSING; } + const CMouse& GetMouse() { return m_Mouse; } void MakePathAbsolute(std::wstring& path); @@ -290,6 +292,14 @@ protected: LRESULT OnSetWindowFocus(UINT uMsg, WPARAM wParam, LPARAM lParam); private: + enum STATE + { + STATE_INITIALIZING, + STATE_REFRESHING, + STATE_RUNNING, + STATE_CLOSING + }; + enum OPTION { OPTION_POSITION = 0x00000001, @@ -433,7 +443,7 @@ private: int m_FadeEndValue; int m_TransparencyValue; - bool m_Refreshing; + STATE m_State; bool m_Hidden; RESIZEMODE m_ResizeWindow; diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 21b17ce4..66a177c3 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -2884,7 +2884,7 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow) MENU_ITEM(IDM_QUIT, ID_STR_EXIT) }; - if (!m_MenuActive) + if (!m_MenuActive && (!meterWindow || !meterWindow->IsClosing())) { m_MenuActive = true;