]> git.lizzy.rs Git - plan9front.git/commitdiff
rio: make scrollwheel handling consistent with sam
authorcinap_lenrek <cinap_lenrek@felloff.net>
Sun, 5 Jan 2014 01:37:42 +0000 (02:37 +0100)
committercinap_lenrek <cinap_lenrek@felloff.net>
Sun, 5 Jan 2014 01:37:42 +0000 (02:37 +0100)
scrollwheel now works proportional to y mouse position.
special case is when shift is hold down. then scrollwheel
will work like before and scroll one line up or down.

sys/src/cmd/rio/scrl.c
sys/src/cmd/rio/wind.c

index 24d0ae568db40a6f43c4148e3148946aa62b51a4..de02575385a6a262764ab391dc1f8e77d95abd99 100644 (file)
@@ -153,7 +153,7 @@ wscroll(Window *w, int but)
                        readmouse(&w->mc);
                        continue;
                }
-               if(but == 1)
+               if(but == 1 || but == 4)
                        p0 = wbacknl(w, w->org, (my-s.min.y)/w->font->height);
                else
                        p0 = w->org+frcharofpt(w, Pt(s.max.x, my));
@@ -163,6 +163,8 @@ wscroll(Window *w, int but)
                /* debounce */
                if(first){
                        flushimage(display, 1);
+                       if(but > 3)
+                               return;
                        sleep(200);
                        nbrecv(w->mc.c, &w->mc.Mouse);
                        first = FALSE;
index 429390a289139038b19fcae7959e5e1581859359..9b8f38d01b4f2152e14558b9c5818352cfd13e24 100644 (file)
@@ -900,32 +900,22 @@ wmousectl(Window *w)
 {
        int but;
 
-       if(w->mc.buttons == 1)
-               but = 1;
-       else if(w->mc.buttons == 2)
-               but = 2;
-       else if(w->mc.buttons == 4)
-               but = 3;
-       else{
-               if(w->mc.buttons == 8)
-                       wkeyctl(w, Kscrolloneup);
-               if(w->mc.buttons == 16)
-                       wkeyctl(w, Kscrollonedown);
-               return;
+       for(but=1;; but++){
+               if(but > 5)
+                       return;
+               if(w->mc.buttons == 1<<(but-1))
+                       break;
        }
 
        incref(w);              /* hold up window while we track */
-       if(w->i==nil)
-               goto Return;
-       if(ptinrect(w->mc.xy, w->scrollr)){
-               if(but)
+       if(w->i != nil){
+               if(shiftdown && but > 3)
+                       wkeyctl(w, but == 4 ? Kscrolloneup : Kscrollonedown);
+               else if(ptinrect(w->mc.xy, w->scrollr) || (but > 3))
                        wscroll(w, but);
-               goto Return;
+               else if(but == 1)
+                       wselect(w);
        }
-       if(but == 1)
-               wselect(w);
-       /* else all is handled by main process */
-   Return:
        wclose(w);
 }