Disabled double update on initialization for meters

This commit is contained in:
spx 2012-05-04 18:23:35 -07:00
parent 2ba25f8aa2
commit 638b467675
2 changed files with 41 additions and 38 deletions

View File

@ -136,7 +136,7 @@ CMeterWindow::CMeterWindow(const std::wstring& config, const std::wstring& iniFi
m_TransparencyValue(), m_TransparencyValue(),
m_Refreshing(false), m_Refreshing(false),
m_Hidden(false), m_Hidden(false),
m_ResizeWindow(false), m_ResizeWindow(RESIZEMODE_NONE),
m_UpdateCounter(), m_UpdateCounter(),
m_MouseMoveCounter(), m_MouseMoveCounter(),
m_FontCollection(), m_FontCollection(),
@ -344,7 +344,7 @@ void CMeterWindow::Refresh(bool init, bool all)
Log(LOG_NOTICE, notice.c_str()); Log(LOG_NOTICE, notice.c_str());
m_Refreshing = true; m_Refreshing = true;
m_ResizeWindow = true; SetResizeWindowMode(RESIZEMODE_RESET);
if (!init) if (!init)
{ {
@ -411,7 +411,7 @@ void CMeterWindow::Refresh(bool init, bool all)
// Set the window region // Set the window region
UpdateWindow(m_AlphaValue, true); // Add/Remove layered flag UpdateWindow(m_AlphaValue, true); // Add/Remove layered flag
Update(false); Update(true);
if (m_BlurMode == BLURMODE_NONE) if (m_BlurMode == BLURMODE_NONE)
{ {
@ -1105,7 +1105,7 @@ void CMeterWindow::ShowMeter(const std::wstring& name, bool group)
if (CompareName((*j), meter, group)) if (CompareName((*j), meter, group))
{ {
(*j)->Show(); (*j)->Show();
m_ResizeWindow = true; // Need to recalculate the window size SetResizeWindowMode(RESIZEMODE_CHECK); // Need to recalculate the window size
if (!group) return; if (!group) return;
} }
} }
@ -1127,7 +1127,7 @@ void CMeterWindow::HideMeter(const std::wstring& name, bool group)
if (CompareName((*j), meter, group)) if (CompareName((*j), meter, group))
{ {
(*j)->Hide(); (*j)->Hide();
m_ResizeWindow = true; // Need to recalculate the window size SetResizeWindowMode(RESIZEMODE_CHECK); // Need to recalculate the window size
if (!group) return; if (!group) return;
} }
} }
@ -1156,7 +1156,7 @@ void CMeterWindow::ToggleMeter(const std::wstring& name, bool group)
{ {
(*j)->Hide(); (*j)->Hide();
} }
m_ResizeWindow = true; // Need to recalculate the window size SetResizeWindowMode(RESIZEMODE_CHECK); // Need to recalculate the window size
if (!group) return; if (!group) return;
} }
} }
@ -1179,7 +1179,7 @@ void CMeterWindow::MoveMeter(const std::wstring& name, int x, int y)
{ {
(*j)->SetX(x); (*j)->SetX(x);
(*j)->SetY(y); (*j)->SetY(y);
m_ResizeWindow = true; // Need to recalculate the window size SetResizeWindowMode(RESIZEMODE_CHECK); // Need to recalculate the window size
return; return;
} }
} }
@ -1203,7 +1203,7 @@ void CMeterWindow::UpdateMeter(const std::wstring& name, bool group)
if (bContinue && CompareName((*j), meter, group)) if (bContinue && CompareName((*j), meter, group))
{ {
UpdateMeter((*j), bActiveTransition, true); UpdateMeter((*j), bActiveTransition, true);
m_ResizeWindow = true; // Need to recalculate the window size SetResizeWindowMode(RESIZEMODE_CHECK); // Need to recalculate the window size
if (!group) if (!group)
{ {
bContinue = false; bContinue = false;
@ -2250,7 +2250,7 @@ void CMeterWindow::InitializeMeasures()
} }
/* /*
** Initializes all the meters and the background ** Initializes all the meters
** **
*/ */
void CMeterWindow::InitializeMeters() void CMeterWindow::InitializeMeters()
@ -2273,9 +2273,6 @@ void CMeterWindow::InitializeMeters()
(*j)->CreateToolTip(this); (*j)->CreateToolTip(this);
} }
} }
Update(true);
ResizeWindow(true);
} }
/* /*
@ -2490,8 +2487,8 @@ void CMeterWindow::Redraw()
{ {
if (m_ResizeWindow) if (m_ResizeWindow)
{ {
ResizeWindow(false); ResizeWindow(m_ResizeWindow == RESIZEMODE_RESET);
m_ResizeWindow = false; SetResizeWindowMode(RESIZEMODE_NONE);
} }
// Create or clear the doublebuffer // Create or clear the doublebuffer
@ -2624,7 +2621,7 @@ bool CMeterWindow::UpdateMeasure(CMeasure* measure, bool force)
} }
int updateDivider = measure->GetUpdateDivider(); int updateDivider = measure->GetUpdateDivider();
if (updateDivider >= 0 || force || m_Refreshing) if (updateDivider >= 0 || force)
{ {
if (measure->HasDynamicVariables() && if (measure->HasDynamicVariables() &&
(measure->GetUpdateCounter() + 1) >= updateDivider) (measure->GetUpdateCounter() + 1) >= updateDivider)
@ -2662,7 +2659,7 @@ bool CMeterWindow::UpdateMeter(CMeter* meter, bool& bActiveTransition, bool forc
} }
int updateDivider = meter->GetUpdateDivider(); int updateDivider = meter->GetUpdateDivider();
if (updateDivider >= 0 || force || m_Refreshing) if (updateDivider >= 0 || force)
{ {
if (meter->HasDynamicVariables() && if (meter->HasDynamicVariables() &&
(meter->GetUpdateCounter() + 1) >= updateDivider) (meter->GetUpdateCounter() + 1) >= updateDivider)
@ -2709,12 +2706,10 @@ bool CMeterWindow::UpdateMeter(CMeter* meter, bool& bActiveTransition, bool forc
** Updates all the measures and redraws the meters ** Updates all the measures and redraws the meters
** **
*/ */
void CMeterWindow::Update(bool nodraw) void CMeterWindow::Update(bool refresh)
{ {
++m_UpdateCounter; ++m_UpdateCounter;
if (!nodraw)
{
if (!m_Measures.empty()) if (!m_Measures.empty())
{ {
// Pre-updates // Pre-updates
@ -2728,12 +2723,11 @@ void CMeterWindow::Update(bool nodraw)
std::list<CMeasure*>::const_iterator i = m_Measures.begin(); std::list<CMeasure*>::const_iterator i = m_Measures.begin();
for ( ; i != m_Measures.end(); ++i) for ( ; i != m_Measures.end(); ++i)
{ {
UpdateMeasure((*i), false); UpdateMeasure((*i), refresh);
} }
} }
CDialogAbout::UpdateMeasures(this); CDialogAbout::UpdateMeasures(this);
}
// Update all meters // Update all meters
bool bActiveTransition = false; bool bActiveTransition = false;
@ -2741,19 +2735,19 @@ void CMeterWindow::Update(bool nodraw)
std::list<CMeter*>::const_iterator j = m_Meters.begin(); std::list<CMeter*>::const_iterator j = m_Meters.begin();
for ( ; j != m_Meters.end(); ++j) for ( ; j != m_Meters.end(); ++j)
{ {
if (UpdateMeter((*j), bActiveTransition, false)) if (UpdateMeter((*j), bActiveTransition, refresh))
{ {
bUpdate = true; bUpdate = true;
} }
} }
// Redraw all meters // Redraw all meters
if (!nodraw && (bUpdate || m_ResizeWindow || m_Refreshing)) if (bUpdate || m_ResizeWindow || refresh)
{ {
if (m_DynamicWindowSize) if (m_DynamicWindowSize)
{ {
// Resize the window // Resize the window
m_ResizeWindow = true; SetResizeWindowMode(RESIZEMODE_CHECK);
} }
// If our option is to disable when in an RDP session, then check if in an RDP session. // If our option is to disable when in an RDP session, then check if in an RDP session.

View File

@ -299,6 +299,15 @@ private:
SETTING_ALL = 0xFFFFFFFF SETTING_ALL = 0xFFFFFFFF
}; };
enum RESIZEMODE
{
RESIZEMODE_NONE = 0,
RESIZEMODE_CHECK,
RESIZEMODE_RESET
};
void SetResizeWindowMode(RESIZEMODE mode) { if (m_ResizeWindow != RESIZEMODE_RESET || mode != RESIZEMODE_CHECK) m_ResizeWindow = mode; }
bool HitTest(int x, int y); bool HitTest(int x, int y);
void GetSkinFolders(const std::wstring& folder); void GetSkinFolders(const std::wstring& folder);
@ -309,7 +318,7 @@ private:
void PostUpdate(bool bActiveTransition); void PostUpdate(bool bActiveTransition);
bool UpdateMeasure(CMeasure* measure, bool force); bool UpdateMeasure(CMeasure* measure, bool force);
bool UpdateMeter(CMeter* meter, bool& bActiveTransition, bool force); bool UpdateMeter(CMeter* meter, bool& bActiveTransition, bool force);
void Update(bool nodraw); void Update(bool refresh);
void UpdateWindow(int alpha, bool reset); void UpdateWindow(int alpha, bool reset);
void ReadConfig(); void ReadConfig();
void WriteConfig(INT setting = SETTING_ALL); void WriteConfig(INT setting = SETTING_ALL);
@ -433,7 +442,7 @@ private:
bool m_Refreshing; // This is true, when the meter is refreshing bool m_Refreshing; // This is true, when the meter is refreshing
bool m_Hidden; // True, if Rainmeter is hidden bool m_Hidden; // True, if Rainmeter is hidden
bool m_ResizeWindow; // If true, the window size is recalculated during the next update RESIZEMODE m_ResizeWindow; // If needed, the window size is recalculated during the next update
std::list<CMeasure*> m_Measures; // All the measures std::list<CMeasure*> m_Measures; // All the measures
std::list<CMeter*> m_Meters; // All the meters std::list<CMeter*> m_Meters; // All the meters