[PATCH] dix: release all buttons and keys before reattaching a device (#34182)

Fernando Carrijo fcarrijo at freedesktop.org
Thu Feb 24 19:21:47 PST 2011


Peter Hutterer <peter.hutterer at who-t.net> wrote:

>  /**
> + * Generate release events for all keys/button currently down on this
> + * device.
> + */
> +static void
> +ReleaseButtonsAndKeys(DeviceIntPtr dev)
> +{
> +    EventListPtr        eventlist = InitEventList(GetMaximumEventsNum());

Out of curiosity, where in the call chain is eventlist being released?

> +    ButtonClassPtr      b = dev->button;
> +    KeyClassPtr         k = dev->key;
> +    int                 i, nevents;
> +
> +    if (!eventlist) /* no release events for you */
> +        return;
> +
> +    /* Release all buttons */
> +    for (i = 0; b && i < b->numButtons; i++)
> +    {
> +        if (BitIsOn(b->down, i))
> +        {
> +            nevents = GetPointerEvents(eventlist, dev, ButtonRelease, i, 0, NULL);
> +            for (i = 0; i < nevents; i++)

For the inner loop, don't we need another index variable instead of reusing i?

> +                mieqProcessDeviceEvent(dev, (InternalEvent*)(eventlist+i)->event, NULL);
> +        }
> +    }
> +
> +    /* Release all keys */
> +    for (i = 0; k && i < MAP_LENGTH; i++)
> +    {
> +        if (BitIsOn(k->down, i))
> +        {
> +            nevents = GetKeyboardEvents(eventlist, dev, KeyRelease, i);
> +            for (i = 0; i < nevents; i++)

Ditto.

> +                mieqProcessDeviceEvent(dev, (InternalEvent*)(eventlist+i)->event, NULL);
> +        }
> +    }
> +}



More information about the xorg-devel mailing list