diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-08-05 00:25:40 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-08-05 00:25:40 +0200 |
commit | 1df707a0b2aaddb750fb707ae413dc67a19027a3 (patch) | |
tree | 1ced2c77d885e8c8f323c465c998d8083551d21a /sys | |
parent | cdc0b89d816aab6322e04f715019a7f8da2f2b75 (diff) |
unsticky scrollbars
scrollbars used to put the mouse on the scrollbar while scrolling. if latency
is high, this often results to the cursor jumping back. instead, make button 2
srolling work without needing the mouse to be inside the scrollbar and leave
the mouse position alone.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/src/cmd/abaco/scrl.c | 21 | ||||
-rw-r--r-- | sys/src/cmd/acme/scrl.c | 7 | ||||
-rw-r--r-- | sys/src/cmd/rio/scrl.c | 68 | ||||
-rw-r--r-- | sys/src/cmd/samterm/scroll.c | 8 |
4 files changed, 41 insertions, 63 deletions
diff --git a/sys/src/cmd/abaco/scrl.c b/sys/src/cmd/abaco/scrl.c index 3b7072f97..3651b8363 100644 --- a/sys/src/cmd/abaco/scrl.c +++ b/sys/src/cmd/abaco/scrl.c @@ -108,11 +108,10 @@ textscroll(Text *t, int but) { uint p0, oldp0; Rectangle s; - int x, y, my, h, first; + int y, my, h, first; s = insetrect(t->scrollr, 1); h = s.max.y-s.min.y; - x = (s.min.x+s.max.x)/2; oldp0 = ~0; first = TRUE; do{ @@ -122,10 +121,6 @@ textscroll(Text *t, int but) my = s.min.y; if(my >= s.max.y) my = s.max.y; - if(!eqpt(mouse->xy, Pt(x, my))){ - moveto(mousectl, Pt(x, my)); - readmouse(mousectl); /* absorb event generated by moveto() */ - } if(but == 2){ y = my; p0 = (vlong)t->rs.nr*(y-s.min.y)/h; @@ -240,10 +235,12 @@ pagescroll(Page *p, int but, int horizontal) else m = mouse->xy.y; - if(m > om) - m += (m-om)*Panspeed; - else if(m < om) - m -= (om-m)*Panspeed; + if(but != 2){ + if(m > om) + m += (m-om)*Panspeed; + else if(m < om) + m -= (om-m)*Panspeed; + } if(m < smin) m = smin; @@ -255,10 +252,6 @@ pagescroll(Page *p, int but, int horizontal) mxy = Pt(m, i); else mxy = Pt(i, m); - if(!eqpt(mouse->xy, mxy)){ - moveto(mousectl, mxy); - readmouse(mousectl); /* absorb event generated by moveto() */ - } if(but == 2){ p0 = muldiv(m-smin, size, ss); p0 = max(p0, 0); diff --git a/sys/src/cmd/acme/scrl.c b/sys/src/cmd/acme/scrl.c index 757974067..1310bc763 100644 --- a/sys/src/cmd/acme/scrl.c +++ b/sys/src/cmd/acme/scrl.c @@ -108,11 +108,10 @@ textscroll(Text *t, int but) { uint p0, oldp0; Rectangle s; - int x, y, my, h, first; + int y, my, h, first; s = insetrect(t->scrollr, 1); h = s.max.y-s.min.y; - x = (s.min.x+s.max.x)/2; oldp0 = ~0; first = TRUE; do{ @@ -122,10 +121,6 @@ textscroll(Text *t, int but) my = s.min.y; if(my >= s.max.y) my = s.max.y; - if(!eqpt(mouse->xy, Pt(x, my))){ - moveto(mousectl, Pt(x, my)); - readmouse(mousectl); /* absorb event generated by moveto() */ - } if(but == 2){ y = my; p0 = (vlong)t->file->nc*(y-s.min.y)/h; diff --git a/sys/src/cmd/rio/scrl.c b/sys/src/cmd/rio/scrl.c index 1bd64899e..80228e016 100644 --- a/sys/src/cmd/rio/scrl.c +++ b/sys/src/cmd/rio/scrl.c @@ -135,48 +135,40 @@ wscroll(Window *w, int but) first = TRUE; do{ flushimage(display, 1); - if(w->mc.xy.x<s.min.x || s.max.x<=w->mc.xy.x){ - readmouse(&w->mc); - }else{ - my = w->mc.xy.y; - if(my < s.min.y) - my = s.min.y; - if(my >= s.max.y) - my = s.max.y; - if(!eqpt(w->mc.xy, Pt(x, my))){ - wmovemouse(w, Pt(x, my)); - readmouse(&w->mc); /* absorb event generated by moveto() */ - } - if(but == 2){ - y = my; - if(y > s.max.y-2) - y = s.max.y-2; - if(w->nr > 1024*1024) - p0 = ((w->nr>>10)*(y-s.min.y)/h)<<10; - else - p0 = w->nr*(y-s.min.y)/h; - if(oldp0 != p0) - wsetorigin(w, p0, FALSE); - oldp0 = p0; - readmouse(&w->mc); - continue; - } - if(but == 1) - p0 = wbacknl(w, w->org, (my-s.min.y)/w->font->height); + my = w->mc.xy.y; + if(my < s.min.y) + my = s.min.y; + if(my >= s.max.y) + my = s.max.y; + if(but == 2){ + y = my; + if(y > s.max.y-2) + y = s.max.y-2; + if(w->nr > 1024*1024) + p0 = ((w->nr>>10)*(y-s.min.y)/h)<<10; else - p0 = w->org+frcharofpt(w, Pt(s.max.x, my)); + p0 = w->nr*(y-s.min.y)/h; if(oldp0 != p0) - wsetorigin(w, p0, TRUE); + wsetorigin(w, p0, FALSE); oldp0 = p0; - /* debounce */ - if(first){ - flushimage(display, 1); - sleep(200); - nbrecv(w->mc.c, &w->mc.Mouse); - first = FALSE; - } - wscrsleep(w, 100); + readmouse(&w->mc); + continue; + } + if(but == 1) + p0 = wbacknl(w, w->org, (my-s.min.y)/w->font->height); + else + p0 = w->org+frcharofpt(w, Pt(s.max.x, my)); + if(oldp0 != p0) + wsetorigin(w, p0, TRUE); + oldp0 = p0; + /* debounce */ + if(first){ + flushimage(display, 1); + sleep(200); + nbrecv(w->mc.c, &w->mc.Mouse); + first = FALSE; } + wscrsleep(w, 100); }while(w->mc.buttons & (1<<(but-1))); while(w->mc.buttons) readmouse(&w->mc); diff --git a/sys/src/cmd/samterm/scroll.c b/sys/src/cmd/samterm/scroll.c index 105944b1b..d40ab688f 100644 --- a/sys/src/cmd/samterm/scroll.c +++ b/sys/src/cmd/samterm/scroll.c @@ -120,10 +120,10 @@ scroll(Flayer *l, int but) draw(scrback, Rect(0,0,Dx(l->scroll), Dy(l->scroll)), l->f.b, nil, l->scroll.min); do{ oin = in; - in = abs(x-mousep->xy.x)<=FLSCROLLWID/2; + in = (but > 3) || (but == 2) || abs(x-mousep->xy.x)<=FLSCROLLWID/2; if(oin && !in) scrunmark(l, r); - if(but > 3 || in){ + if(in){ scrmark(l, r); oy = y; my = mousep->xy.y; @@ -131,8 +131,6 @@ scroll(Flayer *l, int but) my = s.min.y; if(my >= s.max.y) my = s.max.y; - if(in && !eqpt(mousep->xy, Pt(x, my))) - moveto(mousectl, Pt(x, my)); 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); @@ -153,7 +151,7 @@ scroll(Flayer *l, int but) } } }while(but <= 3 && button(but)); - if(but > 3 || in){ + if(in){ h = s.max.y-s.min.y; scrunmark(l, r); p0 = 0; |