refresh main screen only if necessary
This commit is contained in:
@@ -106,9 +106,13 @@ void Clock::Update()
|
||||
if (Width > size_t(COLS) || Height > MainHeight)
|
||||
myPlaylist->SwitchTo();
|
||||
|
||||
time_t rawtime;
|
||||
time(&rawtime);
|
||||
tm *time = localtime(&rawtime);
|
||||
static time_t now = 0, past;
|
||||
time(&past);
|
||||
if (past <= now)
|
||||
return;
|
||||
time(&now);
|
||||
|
||||
tm *time = localtime(&now);
|
||||
|
||||
mask = 0;
|
||||
Set(time->tm_sec % 10, 0);
|
||||
@@ -160,6 +164,7 @@ void Clock::Update()
|
||||
}
|
||||
}
|
||||
}
|
||||
w->Refresh();
|
||||
}
|
||||
|
||||
void Clock::Prepare()
|
||||
|
||||
@@ -466,6 +466,10 @@ namespace NCurses
|
||||
///
|
||||
void HighlightColor(Color color) { itsHighlightColor = color; }
|
||||
|
||||
/// @return state of highlighting
|
||||
///
|
||||
bool isHighlighted() { return highlightEnabled; }
|
||||
|
||||
/// Turns on/off highlighting
|
||||
/// @param state state of hihglighting
|
||||
///
|
||||
|
||||
@@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
||||
Mpd.SetErrorHandler(NcmpcppErrorCallback, 0);
|
||||
|
||||
// local variables
|
||||
int input;
|
||||
int input = 0;
|
||||
|
||||
bool main_exit = 0;
|
||||
bool design_changed = 0;
|
||||
@@ -285,6 +285,7 @@ int main(int argc, char *argv[])
|
||||
// header stuff end
|
||||
|
||||
myScreen->Update();
|
||||
if (input != ERR)
|
||||
myScreen->RefreshWindow();
|
||||
myScreen->ReadKey(input);
|
||||
|
||||
|
||||
@@ -316,8 +316,6 @@ void Playlist::FixPositions(size_t beginning)
|
||||
void Playlist::EnableHighlighting()
|
||||
{
|
||||
Items->Highlighting(1);
|
||||
if (w == Items)
|
||||
Items->Refresh();
|
||||
UpdateTimer();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,10 @@ void StatusbarApplyFilterImmediately(const std::wstring &ws)
|
||||
{
|
||||
static std::wstring cmp;
|
||||
if (cmp != ws)
|
||||
{
|
||||
myScreen->ApplyFilter(ToString((cmp = ws)));
|
||||
myScreen->RefreshWindow();
|
||||
}
|
||||
TraceMpdStatus();
|
||||
}
|
||||
|
||||
@@ -113,10 +115,7 @@ void TraceMpdStatus()
|
||||
static timeval past, now;
|
||||
|
||||
gettimeofday(&now, 0);
|
||||
if ((Mpd.Connected()
|
||||
&& (/*(now.tv_sec == past.tv_sec && now.tv_usec >= past.tv_usec+500000) || */now.tv_sec > past.tv_sec))
|
||||
|| UpdateStatusImmediately
|
||||
)
|
||||
if ((Mpd.Connected() && now.tv_sec > past.tv_sec) || UpdateStatusImmediately)
|
||||
{
|
||||
Mpd.UpdateStatus();
|
||||
BlockItemListUpdate = 0;
|
||||
@@ -124,10 +123,15 @@ void TraceMpdStatus()
|
||||
UpdateStatusImmediately = 0;
|
||||
gettimeofday(&past, 0);
|
||||
}
|
||||
wFooter->Refresh();
|
||||
|
||||
if (myScreen == myPlaylist && now.tv_sec == myPlaylist->Timer()+Config.playlist_disable_highlight_delay)
|
||||
myPlaylist->Items->Highlighting(!Config.playlist_disable_highlight_delay);
|
||||
if (myScreen->ActiveWindow() == myPlaylist->Items
|
||||
&& now.tv_sec == myPlaylist->Timer()+Config.playlist_disable_highlight_delay
|
||||
&& myPlaylist->Items->isHighlighted()
|
||||
&& Config.playlist_disable_highlight_delay)
|
||||
{
|
||||
myPlaylist->Items->Highlighting(0);
|
||||
myPlaylist->Items->Refresh();
|
||||
}
|
||||
|
||||
if (lock_statusbar_delay > 0)
|
||||
{
|
||||
@@ -234,13 +238,6 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
|
||||
myPlaylist->Items->at(pos).CopyPtr(0);
|
||||
(*it)->NullMe();
|
||||
}
|
||||
|
||||
if (myScreen == myPlaylist)
|
||||
{
|
||||
if (!playlist_length || myPlaylist->Items->Size() < myPlaylist->Items->GetHeight())
|
||||
myPlaylist->Items->Window::Clear();
|
||||
myPlaylist->Items->Refresh();
|
||||
}
|
||||
if (was_filtered)
|
||||
{
|
||||
myPlaylist->ApplyFilter(myPlaylist->Items->GetFilter());
|
||||
@@ -253,9 +250,6 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
|
||||
Playlist::ReloadTotalLength = 1;
|
||||
Playlist::ReloadRemaining = 1;
|
||||
|
||||
if (myScreen == myPlaylist)
|
||||
RedrawHeader = 1;
|
||||
|
||||
if (myPlaylist->Items->Empty())
|
||||
{
|
||||
myPlaylist->Items->Reset();
|
||||
@@ -308,8 +302,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
|
||||
}
|
||||
if (changed.PlayerState)
|
||||
{
|
||||
PlayerState mpd_state = Mpd.GetState();
|
||||
switch (mpd_state)
|
||||
switch (Mpd.GetState())
|
||||
{
|
||||
case psUnknown:
|
||||
{
|
||||
@@ -350,10 +343,13 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
|
||||
}
|
||||
}
|
||||
if (Config.new_design)
|
||||
{
|
||||
if (!myPlaylist->isPlaying())
|
||||
{
|
||||
*wHeader << XY(0, 1) << fmtBold << player_state << fmtBoldEnd;
|
||||
wHeader->Refresh();
|
||||
}
|
||||
}
|
||||
else if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
{
|
||||
*wFooter << XY(0, 1);
|
||||
@@ -387,9 +383,6 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
|
||||
playing_song_scroll_begin = 0;
|
||||
first_line_scroll_begin = 0;
|
||||
second_line_scroll_begin = 0;
|
||||
|
||||
if (Mpd.GetState() == psPlay)
|
||||
changed.ElapsedTime = 1;
|
||||
}
|
||||
static time_t now, past = 0;
|
||||
time(&now);
|
||||
@@ -624,11 +617,11 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
|
||||
*wHeader << clEnd;
|
||||
wHeader->Refresh();
|
||||
}
|
||||
if (myScreen->ActiveWindow() == myPlaylist->Items)
|
||||
myPlaylist->Items->Refresh();
|
||||
*wFooter << fmtBoldEnd;
|
||||
wFooter->GotoXY(sx, sy);
|
||||
wFooter->Refresh();
|
||||
if (changed.Playlist || changed.Database || changed.PlayerState || changed.SongID)
|
||||
myScreen->RefreshWindow();
|
||||
}
|
||||
|
||||
Window &Statusbar()
|
||||
|
||||
Reference in New Issue
Block a user