Re: Mouse scroll wheel in wily

  • From: Sam Holden <sholden@xxxxxxxxxxxxxx>
  • To: wilyfans@xxxxxxxxxxxxx
  • Date: Fri, 09 Jul 2004 17:06:12 +1000

ozan s yigit writes:
>> I modified wily/libXg to recognize scroll mouse events and scroll the
>> view accordingly. Would anybody here be interested in a patch? The patch
>> itself is very simple, since all it does is add handling of Button4 and
>> Button5 mouse events returned by X windows.
>
>please send me the patch when you get a chance.
>thanks.

Did anything come of this? It's a patch I'm certainly interested in,
I whipped up my own implementation just now, but wily internals scare
me (it has gary's fingerprints after all :) and I probably introduced
a huge bug of some sort or another...

It's only 20 lines of touched code or so, so here's a diff of my
implementation, feel free to point out the defects that certainly exist.


diff -c -r wily-0.13.41/libXg/gwin.c wily-0.13.41-mod/libXg/gwin.c
*** wily-0.13.41/libXg/gwin.c   Tue Oct  1 14:57:48 1996
--- wily-0.13.41-mod/libXg/gwin.c       Fri Jul  9 16:24:15 2004
***************
*** 355,360 ****
--- 355,362 ----
                case 1: s |= Button1Mask; break;
                case 2: s |= Button2Mask; break;
                case 3: s |= Button3Mask; break;
+               case 4: s |= Button4Mask; break;
+               case 5: s |= Button5Mask; break;
                }
                break;
        case ButtonRelease:
***************
*** 367,372 ****
--- 369,376 ----
                case 1: s &= ~Button1Mask; break;
                case 2: s &= ~Button2Mask; break;
                case 3: s &= ~Button3Mask; break;
+               case 4: s &= ~Button4Mask; break;
+               case 5: s &= ~Button5Mask; break;
                }
                break;
        case MotionNotify:
***************
*** 383,388 ****
--- 387,394 ----
        if(s & Button1Mask) m.buttons |= 1;
        if(s & Button2Mask) m.buttons |= 2;
        if(s & Button3Mask) m.buttons |= 4;
+       if(s & Button4Mask) m.buttons |= 8;
+       if(s & Button5Mask) m.buttons |= 16;
        f = ((GwinWidget)w)->gwin.gotmouse;
        if(f)
                (*f)(&m);

diff -c -r wily-0.13.41/wily/const.h wily-0.13.41-mod/wily/const.h
*** wily-0.13.41/wily/const.h   Sat May  3 21:59:35 1997
--- wily-0.13.41-mod/wily/const.h       Fri Jul  9 16:42:16 2004
***************
*** 27,33 ****
        INSET = 4,
  
        /* mouse buttons */
!       LEFT =1, MIDDLE=2, RIGHT=4,     
  
        /* keys */
        Backspace =     0x7f,
--- 27,33 ----
        INSET = 4,
  
        /* mouse buttons */
!       LEFT =1, MIDDLE=2, RIGHT=4, UP=8, DOWN=16,
  
        /* keys */
        Backspace =     0x7f,

diff -c -r wily-0.13.41/wily/mouse.c wily-0.13.41-mod/wily/mouse.c
*** wily-0.13.41/wily/mouse.c   Wed Apr 29 16:55:35 1998
--- wily-0.13.41-mod/wily/mouse.c       Fri Jul  9 16:54:47 2004
***************
*** 149,154 ****
--- 149,166 ----
                } else {
                        b2(v,r,false);
                }
+       } else if (oldbuttons & UP) {
+               if (m->buttons) /* cancelled an UP */
+                       while (m->buttons)
+                               *m = emouse();
+               else
+                       view_linesdown(v,1,false);
+       } else if (oldbuttons & DOWN) {
+               if (m->buttons) /* cancelled a DOWN */
+                       while (m->buttons)
+                               *m = emouse();
+               else
+                       view_linesdown(v,1,true);
        } else {
                assert((oldbuttons&RIGHT));
                if(m->buttons)  /* cancelled a b3 */
-- 
Sam



Other related posts: