[PATCH 3/5] Replace some input devPrivates with regular struct fields

Simon Thum simon.thum at gmx.de
Sun May 2 04:11:42 PDT 2010


Am 29.04.2010 21:24, schrieb Jamey Sharp:
> diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
> index c2f4378..100d6f8 100644
> --- a/dix/ptrveloc.c
> +++ b/dix/ptrveloc.c
> @@ -83,8 +83,6 @@ GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
>  /* some int which is not a profile number */
>  #define PROFILE_UNINITIALIZE (-100)
>  
> -/* number of properties for predictable acceleration */
> -#define NPROPS_PREDICTABLE_ACCEL 4
>  
>  /**
>   * Init struct so it should match the average case
> @@ -323,26 +321,18 @@ AccelInitScaleProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
>      return XIRegisterPropertyHandler(dev, AccelSetScaleProperty, NULL, NULL);
>  }
>  
> -static int AccelPropHandlerPrivateKeyIndex;
> -DevPrivateKey AccelPropHandlerPrivateKey = &AccelPropHandlerPrivateKeyIndex;
> -
>  BOOL
>  InitializePredictableAccelerationProperties(DeviceIntPtr dev)
>  {
>      DeviceVelocityPtr  vel = GetDevicePredictableAccelData(dev);
> -    long *prop_handlers;
>  
>      if(!vel)
>  	return FALSE;
> -    prop_handlers = xalloc(NPROPS_PREDICTABLE_ACCEL * sizeof(long));
> -
> -    prop_handlers[0] = AccelInitProfileProperty(dev, vel);
> -    prop_handlers[1] = AccelInitDecelProperty(dev, vel);
> -    prop_handlers[2] = AccelInitAdaptDecelProperty(dev, vel);
> -    prop_handlers[3] = AccelInitScaleProperty(dev, vel);
>  
> -    dixSetPrivate(&dev->devPrivates, AccelPropHandlerPrivateKey,
> -                  prop_handlers);
> +    vel->prop_handlers[0] = AccelInitProfileProperty(dev, vel);
> +    vel->prop_handlers[1] = AccelInitDecelProperty(dev, vel);
> +    vel->prop_handlers[2] = AccelInitAdaptDecelProperty(dev, vel);
> +    vel->prop_handlers[3] = AccelInitScaleProperty(dev, vel);
>  
>      return TRUE;
>  }
> @@ -350,8 +340,8 @@ InitializePredictableAccelerationProperties(DeviceIntPtr dev)
>  BOOL
>  DeletePredictableAccelerationProperties(DeviceIntPtr dev)
>  {
> +    DeviceVelocityPtr  vel;
>      Atom prop;
> -    long *prop_handlers;
>      int i;
>  
>      prop = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
> @@ -363,13 +353,10 @@ DeletePredictableAccelerationProperties(DeviceIntPtr dev)
>      prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
>      XIDeleteDeviceProperty(dev, prop, FALSE);
>  
> -    prop_handlers = dixLookupPrivate(&dev->devPrivates,
> -                                     AccelPropHandlerPrivateKey);
> -    dixSetPrivate(&dev->devPrivates, AccelPropHandlerPrivateKey, NULL);
> -
> -    for (i = 0; prop_handlers && i < NPROPS_PREDICTABLE_ACCEL; i++)
> -        XIUnregisterPropertyHandler(dev, prop_handlers[i]);
> -    xfree(prop_handlers);
> +    vel = GetDevicePredictableAccelData(dev);
> +    for (i = 0; vel && i < NPROPS_PREDICTABLE_ACCEL; i++)
> +	if (vel->prop_handlers[i])
> +	    XIUnregisterPropertyHandler(dev, vel->prop_handlers[i]);
>  

If your aim is getting rid of DevPrivate keys, I can probably live with
it. But conceptually, the DeviceVelocityPtr is independent of input
device properties and I'd like to keep it that way. The reason is that
in principle, there may be more than one acceleration context
(DeviceVelocityRec) per device. ATM we don't use it, but since work is
being underway to revamp the scroll wheel, this may become more useful,
so I'm not inclined to blur concepts (so far).

So IMO, a dev private is exactly what it takes. The props are tied to
the predictable _scheme_, which is indeed per-device. I'm happy to
provide a checked allocation patch, though.

Cheers,

Simon


More information about the xorg-devel mailing list