[Xorg] [PATCH] allow EmulateWheel to generate normal clicks too

Alex Deucher alexdeucher at gmail.com
Wed Aug 18 05:57:54 PDT 2004


On Wed, 18 Aug 2004 00:49:25 -0400, Andrew Pimlott <andrew at pimlott.net> wrote:
> On Mon, Aug 16, 2004 at 08:00:16PM +0200, Mathias Fröhlich wrote:
> > I never thought about an other solution to that problem since it works
> > sufficiently well for me.
> 
> Likewise, I just wrote the first way that occurred to me, and didn't
> think about a timeout until I saw your patch.
> 
> > My experience with that feature (and my hardware) is that my trackpoint on my
> > thinkpad sometimes slightly drifts away with a more or less little speed,
> > even if I do not touch the trackpoint at all.
> 
> Good point--I have seen this on multiple laptops.  On my current one, it
> is not bad, but I have seen a middle-click fail at least once with my
> patch because of the drifting trackpoint.
> 
> > IMO this could be better handled with the timeout approach since the decision
> > of emitting middle mouse button clicks does not depend on a funky mouse
> > hardware but only on your click speed ...
> 
> True; on the other hand, I'm not sure that users are very aware of how
> long they hold down the mouse for a click.  They may be more aware of
> whether or not they moved the mouse.  And maybe a threshold will remove
> the funky mouse issue.
> 
> > Is the movement threshold configurable?
> 
> I did not implement a threshold initially.  But it seems that it would
> be necessary for my approach, so I added it, hard-coded at 5 pixels for
> now.  (The distance for a scroll is 10 pixels.  BTW, the documentation
> is wrong about that and the code is inconsistent.)
> 
> > I don't think that we should overcomlicate that issue with different
> > approaches, much configuration options ....
> 
> right
> 
> > Could you provide me a mouse module with the movement approach?
> 
> The new patch is appended, and I can send you (and anyone else) the
> module in a separate message.  If you didn't catch the beginning of the
> thread, it's at
> http://freedesktop.org/pipermail/xorg/2004-August/002404.html

I love this feature (been using tpscroll forever), so as soon as we
decide on an approach I'll be happy to apply the resulting patch to
cvs (after the new release is out) assuming none of the other
developers have a problem with it.

Alex


> 
> > I will tell you in a few days if this does not work well with that drift in
> > hardware.
> 
> Likewise, I'll try out your patch soon.  What timeout do you suggest?
> 
> Andrew
> 
> --- hw/xfree86/os-support/xf86OSmouse.h.orig    2004-08-15 00:24:15.000000000 -0700
> +++ hw/xfree86/os-support/xf86OSmouse.h 2004-08-17 21:31:18.000000000 -0700
> @@ -150,6 +150,8 @@
>      Bool               emulateWheel;
>      int                        wheelInertia;
>      int                        wheelButtonMask;
> +    Bool               wheelButtonClick;
> +    int                wheelButtonMoved;
>      int                        negativeX;      /* Button values.  Unlike the Z and */
>      int                        positiveX;      /* W equivalents, these are button  */
>      int                        negativeY;      /* values rather than button masks. */
> --- hw/xfree86/input/mouse/mouse.c.orig 2004-08-15 00:07:41.000000000 -0700
> +++ hw/xfree86/input/mouse/mouse.c      2004-08-17 21:34:55.000000000 -0700
> @@ -185,6 +185,7 @@
>      OPTION_RESOLUTION,
>      OPTION_EMULATE_WHEEL,
>      OPTION_EMU_WHEEL_BUTTON,
> +    OPTION_EMU_WHEEL_CLICK,
>      OPTION_EMU_WHEEL_INERTIA,
>      OPTION_X_AXIS_MAPPING,
>      OPTION_Y_AXIS_MAPPING,
> @@ -222,6 +223,7 @@
>      { OPTION_RESOLUTION,       "Resolution",     OPTV_INTEGER, {0}, FALSE },
>      { OPTION_EMULATE_WHEEL,    "EmulateWheel",   OPTV_BOOLEAN, {0}, FALSE },
>      { OPTION_EMU_WHEEL_BUTTON, "EmulateWheelButton", OPTV_INTEGER, {0}, FALSE },
> +    { OPTION_EMU_WHEEL_CLICK,  "EmulateWheelClickToo", OPTV_BOOLEAN, {0}, FALSE },
>      { OPTION_EMU_WHEEL_INERTIA,        "EmulateWheelInertia", OPTV_INTEGER, {0}, FALSE },
>      { OPTION_X_AXIS_MAPPING,   "XAxisMapping",   OPTV_STRING,  {0}, FALSE },
>      { OPTION_Y_AXIS_MAPPING,   "YAxisMapping",   OPTV_STRING,  {0}, FALSE },
> @@ -619,6 +621,9 @@
>         }
>         pMse->wheelButtonMask = 1 << (wheelButton - 1);
> 
> +        pMse->wheelButtonClick = xf86SetBoolOption(pInfo->options,
> +                                        "EmulateWheelClickToo", FALSE);
> +
>         pMse->wheelInertia = xf86SetIntOption(pInfo->options,
>                                         "EmulateWheelInertia", 10);
>         if (pMse->wheelInertia <= 0) {
> @@ -689,8 +694,9 @@
>                     pInfo->name, pMse->negativeY, pMse->positiveY);
>         }
>         xf86Msg(X_CONFIG, "%s: EmulateWheel, EmulateWheelButton: %d, "
> -                         "EmulateWheelInertia: %d\n",
> -               pInfo->name, wheelButton, pMse->wheelInertia);
> +                         "EmulateWheelClickToo: %d, EmulateWheelInertia: %d\n",
> +               pInfo->name, wheelButton, pMse->wheelInertia,
> +                pMse->wheelButtonClick);
>      }
>      if (origButtons != pMse->buttons)
>         from = X_CONFIG;
> @@ -1992,6 +1998,8 @@
> 
>      /* Intercept wheel emulation. */
>      if (pMse->emulateWheel && (buttons & pMse->wheelButtonMask)) {
> +        pMse->wheelButtonMoved += abs(dx) + abs(dy);
> +
>         /* Y axis movement */
>         if (pMse->negativeY != MSE_NOAXISMAP) {
>             pMse->wheelYDistance += dy;
> @@ -2044,10 +2052,9 @@
>             }
>         }
> 
> -       /* Absorb the mouse movement and the wheel button press. */
> +       /* Absorb the mouse movement. */
>         dx = 0;
>         dy = 0;
> -       buttons &= ~pMse->wheelButtonMask;
>      }
> 
>      if (dx || dy)
> @@ -2060,6 +2067,31 @@
>         else
>             change = buttons ^ reverseBits(reverseMap, pMse->lastButtons);
> 
> +        /* We generally swallow wheelButtonMask events, except when a wheel
> +         * button is released, and we haven't moved the mouse since a wheel
> +         * button was pressed, and EmulateWheelClickToo is set. */
> +
> +        if (pMse->emulateWheel && change & pMse->wheelButtonMask) {
> +            int wheelChange = change & pMse->wheelButtonMask;
> +
> +            while (wheelChange) {
> +                id = ffs(wheelChange);
> +                wheelChange &= ~(1 << (id - 1));
> +                if (pMse->wheelButtonClick &&
> +                    ! (buttons & (1 << (id - 1))) &&  /* released */
> +                    pMse->wheelButtonMoved < 5) {
> 
> 
> +                        xf86PostButtonEvent(pInfo->dev, 0, id, 1, 0, 0);
> +                        xf86PostButtonEvent(pInfo->dev, 0, id, 0, 0, 0);
> +                }
> +            }
> +
> +            if (! (buttons & pMse->wheelButtonMask))
> +                pMse->wheelButtonMoved = 0;
> +
> +            buttons &= ~pMse->wheelButtonMask;
> +            change  &= ~pMse->wheelButtonMask;
> +        }
> +
>         /*
>          * adjust buttons state for drag locks!
>          * if there is drag locks
> --- hw/xfree86/input/mouse/mouse.man.orig       2004-08-15 01:04:07.000000000 -0700
> +++ hw/xfree86/input/mouse/mouse.man    2004-08-15 01:16:00.000000000 -0700
> @@ -112,6 +112,12 @@
>  .B YAxisMapping
>  settings.  Default: 4.
>  .TP 7
> +.BI "Option \*qEmulateWheelClickToo\*q \*q" boolean \*q
> +Causes
> +.B EmulateWheelButton
> +to generate normal clicks when the mouse isn't moved between press and
> +release.  Default: off
> +.TP 7
>  .BI "Option \*qEmulateWheelInertia\*q \*q" integer \*q
>  Specifies how far (in pixels) the pointer must move to generate button
>  press/release events in wheel emulation mode.  Default: 50.
> 
> _______________________________________________
> xorg mailing list
> xorg at freedesktop.org
> http://freedesktop.org/mailman/listinfo/xorg
>



More information about the xorg mailing list