From 66450f4e9ee428d28d8e2a5159fb92ca8b1da7ec Mon Sep 17 00:00:00 2001 From: Jeffrey Middleton Date: Wed, 15 Apr 2009 14:07:41 -0500 Subject: [PATCH] screen_play: make center_playing_item aware of scroll offset When moving the cursor to make sure it is visible after recentering, move it to the offset position from the edge of the screen. (Previously, it was placed at the edge, causing the offset to force the screen to scroll.) --- src/screen_play.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/screen_play.c b/src/screen_play.c index 7327364..28d3913 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -166,8 +166,9 @@ center_playing_item(mpdclient_t *c, bool center_cursor) } /* make sure the cursor is in the window */ - if (lw->selected < lw->start) { - lw->selected = lw->start; + if (lw->selected < lw->start + options.scroll_offset) { + if (lw->start > 0) + lw->selected = lw->start + options.scroll_offset; if (lw->range_selection) { lw->selected_start = lw->range_base; lw->selected_end = lw->selected; @@ -175,8 +176,9 @@ center_playing_item(mpdclient_t *c, bool center_cursor) lw->selected_start = lw->selected; lw->selected_end = lw->selected; } - } else if (lw->selected > lw->start + lw->rows - 1) { - lw->selected = lw->start + lw->rows - 1; + } else if (lw->selected > lw->start + lw->rows - 1 - options.scroll_offset) { + if (lw->start + lw->rows < length) + lw->selected = lw->start + lw->rows - 1 - options.scroll_offset; if (lw->range_selection) { lw->selected_start = lw->selected; lw->selected_end = lw->range_base; -- 2.30.2