summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 707cd9f)
raw | patch | inline | side by side (parent: 707cd9f)
author | Max Kellermann <max@duempel.org> | |
Thu, 25 Sep 2008 15:44:47 +0000 (17:44 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 25 Sep 2008 15:44:47 +0000 (17:44 +0200) |
Repaint the playlist window on demand. Don't repaint it
unconditionally in play_update().
unconditionally in play_update().
src/screen_play.c | patch | blob | history |
diff --git a/src/screen_play.c b/src/screen_play.c
index 3aaff229dbdaadfbe7f407ef5539679f336bb3da..64b170084ed06220cf4eaa33bd8a5ebcfb50ace0 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
static GTime input_timestamp;
static list_window_t *lw = NULL;
-static long long playlist_id;
+
+static void
+play_paint(struct mpdclient *c);
+
+static void
+playlist_repaint(struct mpdclient *c)
+{
+ play_paint(c);
+ wrefresh(lw->w);
+}
+
+static void
+playlist_repaint_if_active(struct mpdclient *c)
+{
+ if (get_cur_mode_id() == 0) /* XXX don't use the literal number */
+ playlist_repaint(c);
+}
static void
playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
}
list_window_check_selected(lw, c->playlist.list->len);
+ playlist_repaint_if_active(c);
}
static const char *
lw->selected = lw->start+offset;
list_window_check_selected(lw, length);
- return;
+ playlist_repaint(c);
}
static void
static void
play_update(mpd_unused screen_t *screen, mpdclient_t *c)
{
+ int new_flags = lw->flags;
+
/* hide the cursor when mpd are playing and the user are inactive */
if (options.hide_cursor > 0 &&
(c->status != NULL && c->status->state == MPD_STATUS_STATE_PLAY) &&
time(NULL) - input_timestamp >= options.hide_cursor ) {
- lw->flags |= LW_HIDE_CURSOR;
+ new_flags |= LW_HIDE_CURSOR;
} else {
- lw->flags &= ~LW_HIDE_CURSOR;
+ new_flags &= ~LW_HIDE_CURSOR;
+ }
+
+ if (new_flags != lw->flags) {
+ lw->flags = new_flags;
+ playlist_repaint(c);
}
/* center the cursor */
prev_song_id = c->song->id;
}
}
-
- if (c->playlist.id != playlist_id) {
- list_window_check_selected(lw, playlist_length(&c->playlist));
- play_paint(c);
- playlist_id = c->playlist.id;
- } else {
- list_window_paint(lw, list_callback, (void *) c);
- }
}
#ifdef HAVE_GETMOUSE
unsigned long bstate;
if (screen_get_mouse_event(c, &bstate, &row) ||
- list_window_mouse(lw, c->playlist.list->len, bstate, row))
+ list_window_mouse(lw, c->playlist.list->len, bstate, row)) {
+ playlist_repaint(c);
return 1;
+ }
if (bstate & BUTTON1_DOUBLE_CLICKED) {
/* stop */
lw->selected = selected;
list_window_check_selected(lw, c->playlist.list->len);
+ playlist_repaint(c);
return 1;
}
{
input_timestamp = time(NULL);
+ if (list_window_cmd(lw, playlist_length(&c->playlist), cmd)) {
+ playlist_repaint(c);
+ return 1;
+ }
+
switch(cmd) {
case CMD_PLAY:
mpdclient_cmd_play(c, lw->selected);
case CMD_LIST_RFIND:
case CMD_LIST_FIND_NEXT:
case CMD_LIST_RFIND_NEXT:
- return screen_find(screen,
- lw, c->playlist.list->len,
- cmd, list_callback, (void *) c);
+ screen_find(screen,
+ lw, playlist_length(&c->playlist),
+ cmd, list_callback, c);
+ playlist_repaint(c);
+ return 1;
+
case CMD_MOUSE_EVENT:
return handle_mouse_event(screen,c);
default:
break;
}
- return list_window_cmd(lw, c->playlist.list->len, cmd);
+
+ return 0;
}
const struct screen_functions screen_playlist = {