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.
This commit is contained in:
parent
cdc0b89d81
commit
1df707a0b2
4 changed files with 41 additions and 63 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue