Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
queue: fetch full MPD queue instead of screen-trimmed subset Allocate the entire MPD queue, so the highlight can safely index across all songs and not be bounded by the size of the window
include/queue.h | 2 +- src/queue.c | 16 +++++----------- src/ui.c | 4 +---
diff --git a/include/queue.h b/include/queue.h index feb90de7902e6119e33494b0d55b35a12c267400..d242c81e8f1c0bd6f88512e90430fe52f357e5cb 100644 --- a/include/queue.h +++ b/include/queue.h @@ -2,7 +2,7 @@ #ifndef SEAMUS_QUEUE #define SEAMUS_QUEUE #include "seamus.h" -int fetch_current_queue(struct seamus_frontend *seamus, int max_count); +int fetch_current_queue(struct seamus_frontend *seamus); void print_songs_from_queue(struct seamus_frontend *seamus); #endif diff --git a/src/queue.c b/src/queue.c index 80d967e46e17e28e480eafc69dddc9b853f3f941..5773f26807c87de3801f7eda4f3fe68f0147d944 100644 --- a/src/queue.c +++ b/src/queue.c @@ -5,7 +5,7 @@ #include#include "seamus.h" int -fetch_current_queue(struct seamus_frontend *seamus, int max_count) +fetch_current_queue(struct seamus_frontend *seamus) { assert(seamus->conn != NULL); @@ -13,20 +13,14 @@ bool queue_status = mpd_send_list_queue_meta(seamus->conn); if (queue_status) { struct mpd_entity *entity; + int total = seamus->status->length; int index = 0; - int max_items = 0; - - if (seamus->status->length > max_count) { - max_items = max_count; - } else { - max_items = seamus->status->length; - } free(seamus->queue); - seamus->queue = calloc(max_items, sizeof(struct seamus_song)); - seamus->queue_size = max_items; + seamus->queue = calloc(total, sizeof(struct seamus_song)); + seamus->queue_size = total; - while (index < max_items) { + while (index < total) { entity = mpd_recv_entity(seamus->conn); if (entity == NULL) { diff --git a/src/ui.c b/src/ui.c index 23396516a636a5f6d05a707b647179d974c04cf4..42c973b78665a675b827af62a3139b4a33e7b5d2 100644 --- a/src/ui.c +++ b/src/ui.c @@ -289,10 +289,8 @@ seamus->version, seamus->status->version ); - // Update the current version rendered seamus->version = seamus->status->version; - int max_window_size = tickit_window_lines(seamus->main_window); - fetch_current_queue(seamus, max_window_size); + fetch_current_queue(seamus); } log_info("Rendering queue again");