summaryrefslogtreecommitdiffstats
path: root/source/scrollbar.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2015-09-14 18:19:20 +0200
committerDave Davenport <qball@gmpclient.org>2015-09-14 18:19:20 +0200
commite53705de1123deb2b9e92f0b45a676c8bb55b631 (patch)
treec9ec60e1cae0abdfcd783e935554d421662bf152 /source/scrollbar.c
parentae043d524679c581e434f58a6bb2668f10b336cd (diff)
Fix scrolling on edges
Diffstat (limited to 'source/scrollbar.c')
-rw-r--r--source/scrollbar.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/source/scrollbar.c b/source/scrollbar.c
index 85ad3bb7..24660985 100644
--- a/source/scrollbar.c
+++ b/source/scrollbar.c
@@ -135,10 +135,11 @@ void scrollbar_draw ( scrollbar *sb )
unsigned int scrollbar_clicked ( scrollbar *sb, int y )
{
if ( sb != NULL ) {
+ y = MIN ( MAX ( 1, y ), sb->h - 1 ) - 1;
const short bh = sb->h - 2;
float sec = ( ( bh ) / (float) sb->length );
unsigned int sel = y / sec;
- return sel;
+ return MIN ( sel, sb->length - 1 );
}
return 0;
}