Code

screen_play: make center_playing_item aware of scroll offset
authorJeffrey Middleton <jefromi@gmail.com>
Wed, 15 Apr 2009 19:07:41 +0000 (14:07 -0500)
committerMax Kellermann <max@duempel.org>
Fri, 17 Apr 2009 07:49:16 +0000 (09:49 +0200)
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

index 7327364b010c22c12d4efc537c9144a0aecb76bf..28d39134625f8a32dbcec75a2926f1223a23e555 100644 (file)
@@ -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;