diff options
-rw-r--r-- | desktop/scrollbar.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c index 6dd9b0b15..b84ed08a1 100644 --- a/desktop/scrollbar.c +++ b/desktop/scrollbar.c @@ -458,8 +458,7 @@ void scrollbar_set_extents(struct scrollbar *s, int length, int visible_size, int full_size) { int well_length; - - /* TODO: update offset appropriately */ + int cur_excess = s->full_size - s->visible_size; if (length != -1) s->length = length; @@ -468,6 +467,9 @@ void scrollbar_set_extents(struct scrollbar *s, int length, if (full_size != -1) s->full_size = full_size; + /* Update scroll offset (scaled in proportion with change in excess) */ + s->offset = (s->full_size - s->visible_size) * s->offset / cur_excess; + well_length = s->length - 2 * SCROLLBAR_WIDTH; s->bar_len = (well_length * s->visible_size) / s->full_size; |