diff --git a/src/screen.c b/src/screen.c
index b272935fe2c04bda83531609fbc87016c60d14f6..0a056a866ec29ba266711eea5bc4c7044ac44885 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
/* ncmpc (Ncurses MPD Client)
- * (c) 2004-2010 The Music Player Daemon Project
+ * (c) 2004-2017 The Music Player Daemon Project
* Project homepage: http://musicpd.org
*
* This program is free software; you can redistribute it and/or modify
screen.main_window.cols = screen.cols;
screen.main_window.rows = screen.rows-4;
wresize(screen.main_window.w, screen.main_window.rows, screen.cols);
- wclear(screen.main_window.w);
/* progress window */
progress_bar_resize(&screen.progress_bar, screen.cols,
screen.rows - 2, 0);
- progress_bar_paint(&screen.progress_bar);
/* status window */
status_bar_resize(&screen.status_bar, screen.cols, screen.rows - 1, 0);
- status_bar_paint(&screen.status_bar, c->status, c->song);
screen.buf_size = screen.cols;
g_free(screen.buf);
{
struct mpdclient *c = data;
-#ifndef NCMPC_MINI
screen.welcome_source_id = 0;
-#endif
paint_top_window(mode_fn->get_title != NULL
? mode_fn->get_title(screen.buf, screen.buf_size)
/* create progress window */
progress_bar_init(&screen.progress_bar, screen.cols,
screen.rows - 2, 0);
- progress_bar_paint(&screen.progress_bar);
/* create status window */
status_bar_init(&screen.status_bar, screen.cols, screen.rows - 1, 0);
- status_bar_paint(&screen.status_bar, c->status, c->song);
#ifdef ENABLE_COLORS
if (options.enable_colors) {
}
#endif
- doupdate();
-
/* initialize screens */
screen_list_init(screen.main_window.w,
screen.main_window.cols, screen.main_window.rows);
mode_fn->open(c);
}
-void
-screen_paint(struct mpdclient *c)
+static void
+screen_refresh(struct mpdclient *c, bool main_dirty)
{
- const char *title = NULL;
-
- if (mode_fn->get_title != NULL)
- title = mode_fn->get_title(screen.buf, screen.buf_size);
-
- /* paint the title/header window */
- if( title )
- paint_top_window(title, c);
- else
- paint_top_window("", c);
+ /* update title/header window */
+ const char *title =
+#ifndef NCMPC_MINI
+ screen.welcome_source_id == 0 &&
+#endif
+ mode_fn->get_title != NULL
+ ? mode_fn->get_title(screen.buf, screen.buf_size)
+ : "";
+ assert(title != NULL);
+ paint_top_window(title, c);
/* paint the bottom window */
/* paint the main window */
- wclear(screen.main_window.w);
- if (mode_fn->paint != NULL)
- mode_fn->paint();
+ if (main_dirty) {
+ wclear(screen.main_window.w);
+ if (mode_fn->paint != NULL)
+ mode_fn->paint();
+ }
/* move the cursor to the origin */
doupdate();
}
+void
+screen_paint(struct mpdclient *c)
+{
+ screen_refresh(c, true);
+}
+
void
screen_update(struct mpdclient *c)
{
mpdclient_is_connected(c))
screen_status_printf(_("Database updated"));
was_connected = mpdclient_is_connected(c);
-
- /* update title/header window */
- if (screen.welcome_source_id != 0)
- paint_top_window("", c);
- else
#endif
- if (mode_fn->get_title != NULL) {
- paint_top_window(mode_fn->get_title(screen.buf,screen.buf_size), c);
- } else
- paint_top_window("", c);
-
- /* update progress window */
- update_progress_window(c, false);
-
- /* update status window */
- status_bar_paint(&screen.status_bar, c->status, c->song);
/* update the main window */
if (mode_fn->update != NULL)
mode_fn->update(c);
- /* move the cursor to the origin */
-
- if (!options.hardware_cursor)
- wmove(screen.main_window.w, 0, 0);
-
- wnoutrefresh(screen.main_window.w);
-
- /* tell curses to update */
- doupdate();
+ screen_refresh(c, false);
}
#ifdef HAVE_GETMOUSE