From: Jeffrey Middleton Date: Wed, 15 Apr 2009 19:07:41 +0000 (-0500) Subject: screen_play: make center_playing_item aware of scroll offset X-Git-Tag: release-0.14~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=66450f4e9ee428d28d8e2a5159fb92ca8b1da7ec;p=ncmpc.git 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.) --- 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;