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/src/cmd/rio | |
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/src/cmd/rio')
-rw-r--r-- | sys/src/cmd/rio/scrl.c | 68 |
1 files changed, 30 insertions, 38 deletions
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); |