From 87325403b0b32e5c3f7f36dae92b9aaac0355175 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 27 Jan 2013 12:57:51 +0100 Subject: [PATCH] sam: make scroll wheel work outside scrollbar --- sys/src/cmd/samterm/main.c | 4 ++-- sys/src/cmd/samterm/scroll.c | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/sys/src/cmd/samterm/main.c b/sys/src/cmd/samterm/main.c index 232258fd7..0b650becf 100644 --- a/sys/src/cmd/samterm/main.c +++ b/sys/src/cmd/samterm/main.c @@ -100,7 +100,7 @@ threadmain(int argc, char *argv[]) if(nwhich!=which) current(nwhich); else if(scr) - scroll(which, 1); + scroll(which, (mousep->buttons&8) ? 4 : 1); else{ t=(Text *)which->user1; if(flselect(which)){ @@ -119,7 +119,7 @@ threadmain(int argc, char *argv[]) menu2hit(); }else if(mousep->buttons&(4|16)){ if(scr) - scroll(which, 3); + scroll(which, (mousep->buttons&16) ? 5 : 3); else menu3hit(); } diff --git a/sys/src/cmd/samterm/scroll.c b/sys/src/cmd/samterm/scroll.c index f3a632cec..105944b1b 100644 --- a/sys/src/cmd/samterm/scroll.c +++ b/sys/src/cmd/samterm/scroll.c @@ -123,7 +123,7 @@ scroll(Flayer *l, int but) in = abs(x-mousep->xy.x)<=FLSCROLLWID/2; if(oin && !in) scrunmark(l, r); - if(in){ + if(but > 3 || in){ scrmark(l, r); oy = y; my = mousep->xy.y; @@ -131,9 +131,9 @@ scroll(Flayer *l, int but) my = s.min.y; if(my >= s.max.y) my = s.max.y; - if(!eqpt(mousep->xy, Pt(x, my))) + if(in && !eqpt(mousep->xy, Pt(x, my))) moveto(mousectl, Pt(x, my)); - if(but == 1){ + if(but == 1 || but == 4){ p0 = l->origin-frcharofpt(&l->f, Pt(s.max.x, my)); rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot); y = rt.min.y; @@ -141,7 +141,7 @@ scroll(Flayer *l, int but) y = my; if(y > s.max.y-2) y = s.max.y-2; - }else if(but == 3){ + }else if(but == 3 || but == 5){ p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my)); rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot); y = rt.min.y; @@ -152,19 +152,21 @@ scroll(Flayer *l, int but) scrmark(l, r); } } - }while(button(but)); - if(in){ + }while(but <= 3 && button(but)); + if(but > 3 || in){ h = s.max.y-s.min.y; scrunmark(l, r); p0 = 0; - if(but == 1) + if(but == 1 || but == 4){ + but = 1; p0 = (long)(my-s.min.y)/l->f.font->height+1; - else if(but == 2){ + }else if(but == 2){ if(tot > 1024L*1024L) p0 = ((tot>>10)*(y-s.min.y)/h)<<10; else p0 = tot*(y-s.min.y)/h; - }else if(but == 3){ + }else if(but == 3 || but == 5){ + but = 3; p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my)); if(p0 > tot) p0 = tot;