[PATCH] dix: mark motion events as emulated if we're scrolling from button press
Daniel Stone
daniel at fooishbar.org
Fri Oct 14 05:07:32 PDT 2011
Hmm, my original review got lost. It was along the lines of 'it's not
pretty, but ... Reviewed-by: Daniel Stone <daniel at fooishbar.org>'.
Cheers,
Daniel
On 14 October 2011 00:07, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> ping?
>
> On Wed, Oct 05, 2011 at 12:14:47PM +1000, Peter Hutterer wrote:
>> The protocol requires that the emulated event is marked as such. So if a
>> driver with smooth scrolling axis sends legacy button events, the motion
>> event must be marked as emulated.
>>
>> Pass the real type to emulate_scroll_button_events and create the events
>> accordingly. For real button press or relase events, only that event must be
>> generated since a release event will follow or a press event has already
>> occured, respectively. (This fixes a bug where we'd get two release events
>> for each legacy button event)
>>
>> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
>> ---
>> dix/getevents.c | 31 ++++++++++++++++++++++---------
>> 1 files changed, 22 insertions(+), 9 deletions(-)
>>
>> diff --git a/dix/getevents.c b/dix/getevents.c
>> index adf945f..c55e1a0 100644
>> --- a/dix/getevents.c
>> +++ b/dix/getevents.c
>> @@ -1294,6 +1294,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
>> *
>> * @param events The pointer to the event list to fill the events
>> * @param dev The device to generate the events for
>> + * @param type The real type of the event
>> * @param axis The axis number to generate events for
>> * @param mask State before this event in absolute coords
>> * @param[in,out] last Last scroll state posted in absolute coords (modified
>> @@ -1305,6 +1306,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
>> static int
>> emulate_scroll_button_events(InternalEvent *events,
>> DeviceIntPtr dev,
>> + int type,
>> int axis,
>> const ValuatorMask *mask,
>> ValuatorMask *last,
>> @@ -1317,6 +1319,7 @@ emulate_scroll_button_events(InternalEvent *events,
>> int num_events = 0;
>> double total;
>> int b;
>> + int flags = 0;
>>
>> if (dev->valuator->axes[axis].scroll.type == SCROLL_TYPE_NONE)
>> return 0;
>> @@ -1327,6 +1330,9 @@ emulate_scroll_button_events(InternalEvent *events,
>> ax = &dev->valuator->axes[axis];
>> incr = ax->scroll.increment;
>>
>> + if (type != ButtonPress && type != ButtonRelease)
>> + flags |= POINTER_EMULATED;
>> +
>> if (!valuator_mask_isset(last, axis))
>> valuator_mask_set_double(last, axis, 0);
>>
>> @@ -1354,14 +1360,19 @@ emulate_scroll_button_events(InternalEvent *events,
>> */
>> if (num_events + 4 < max_events)
>> {
>> - nev_tmp = fill_pointer_events(events, dev, ButtonPress, b, ms,
>> - POINTER_EMULATED, NULL);
>> - events += nev_tmp;
>> - num_events += nev_tmp;
>> - nev_tmp = fill_pointer_events(events, dev, ButtonRelease, b, ms,
>> - POINTER_EMULATED, NULL);
>> - events += nev_tmp;
>> - num_events += nev_tmp;
>> + if (type != ButtonRelease) {
>> + nev_tmp = fill_pointer_events(events, dev, ButtonPress, b, ms,
>> + flags, NULL);
>> + events += nev_tmp;
>> + num_events += nev_tmp;
>> + }
>> + if (type != ButtonPress)
>> + {
>> + nev_tmp = fill_pointer_events(events, dev, ButtonRelease, b, ms,
>> + flags, NULL);
>> + events += nev_tmp;
>> + num_events += nev_tmp;
>> + }
>> }
>> }
>>
>> @@ -1406,6 +1417,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
>> ValuatorMask mask;
>> ValuatorMask scroll;
>> int i;
>> + int realtype = type;
>>
>> /* refuse events from disabled devices */
>> if (!pDev->enabled)
>> @@ -1458,6 +1470,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
>> valuator_mask_set_double(&mask, axis, val);
>> type = MotionNotify;
>> buttons = 0;
>> + flags |= POINTER_EMULATED;
>> }
>> }
>>
>> @@ -1477,7 +1490,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
>>
>> valuator_mask_set_double(&scroll, i, pDev->last.valuators[i]);
>>
>> - nev_tmp = emulate_scroll_button_events(events, pDev, i, &scroll,
>> + nev_tmp = emulate_scroll_button_events(events, pDev, realtype, i, &scroll,
>> pDev->last.scroll, ms,
>> GetMaximumEventsNum() - num_events);
>> events += nev_tmp;
>> --
>> 1.7.6.4
>
More information about the xorg-devel
mailing list