On 04/06/2011 07:10 PM, Jeremy Huddleston wrote: > why do we no longer need to check the valuators.mask? It looks like (from > just the src changes here) that the !absolute (relative) case would still > need to be handled. > > if (BitIsOn(ev->valuators.mask, xv->first_valuator + j)) > valuators[j] = ev->valuators.data[xv->first_valuator + j]; > else > valuators[j] = 0;
This patch just shifts the logic to the internal event creation time instead of the XI 1.x event conversion time. Each internal event is memset in init_event() (called by GetPointerEvents and friends functions). This takes care of the relative valuator handling where values should be 0. Then we have to ensure that the old absolute valuator values are copied into the XI 1.x events. We do this in set_valuators() by setting the old valuator values in the internal event if the valuator wasn't changed. By the time we reach getValuatorEvents, all the valuator data is as it should be in the XI 1.x event, and the valuator range is still calculated using the internal event valuator mask. For XI 2 events, the old valuator values aren't sent because the valuators are fully masked in the events. Core events still don't have valuators. So I'm hoping this will kill the bug dead once and for all :). Thanks, -- Chase > On Apr 6, 2011, at 11:51, Chase Douglas wrote: > >> Set the valuator values for unset masked absolute valuators in the >> internal device event. This ensures the values will always be correct in >> getValuatorEvents even if the device has been removed. >> >> Signed-off-by: Chase Douglas <[email protected]> >> --- >> dix/eventconvert.c | 14 +++++--------- >> dix/getevents.c | 4 ++++ >> 2 files changed, 9 insertions(+), 9 deletions(-) >> >> diff --git a/dix/eventconvert.c b/dix/eventconvert.c >> index a5fe0a9..14731f4 100644 >> --- a/dix/eventconvert.c >> +++ b/dix/eventconvert.c >> @@ -383,12 +383,12 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv) >> int i; >> int state = 0; >> int first_valuator, num_valuators; >> - DeviceIntPtr dev = NULL; >> >> >> num_valuators = countValuators(ev, &first_valuator); >> if (num_valuators > 0) >> { >> + DeviceIntPtr dev = NULL; >> dixLookupDevice(&dev, ev->deviceid, serverClient, DixUseAccess); >> /* State needs to be assembled BEFORE the device is updated. */ >> state = (dev && dev->key) ? >> XkbStateFieldFromRec(&dev->key->xkbInfo->state) : 0; >> @@ -405,14 +405,10 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv) >> xv->deviceid = ev->deviceid; >> xv->device_state = state; >> >> - for (j = 0; j < xv->num_valuators; j++) { >> - if (BitIsOn(ev->valuators.mask, xv->first_valuator + j)) >> - valuators[j] = ev->valuators.data[xv->first_valuator + j]; >> - else if (dev->valuator->axes[xv->first_valuator + j].mode == >> Absolute) >> - valuators[j] = dev->valuator->axisVal[xv->first_valuator + >> j]; >> - else >> - valuators[j] = 0; >> - } >> + /* Unset valuators in masked valuator events have the proper data >> values >> + * in the case of an absolute axis in between two set valuators. */ >> + for (j = 0; j < xv->num_valuators; j++) >> + valuators[j] = ev->valuators.data[xv->first_valuator + j]; >> >> if (i + 6 < num_valuators) >> xv->deviceid |= MORE_EVENTS; >> diff --git a/dix/getevents.c b/dix/getevents.c >> index c3b7ced..644b388 100644 >> --- a/dix/getevents.c >> +++ b/dix/getevents.c >> @@ -205,6 +205,8 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, >> ValuatorMask *mask) >> { >> int i; >> >> + /* Set the data to the previous value for unset absolute axes. The >> values >> + * may be used when sent as part of an XI 1.x valuator event. */ >> for (i = 0; i < valuator_mask_size(mask); i++) >> { >> if (valuator_mask_isset(mask, i)) >> @@ -216,6 +218,8 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, >> ValuatorMask *mask) >> event->valuators.data_frac[i] = >> dev->last.remainder[i] * (1 << 16) * (1 << 16); >> } >> + else if (valuator_get_mode(dev, i) == Absolute) >> + event->valuators.data[i] = dev->valuator->axisVal[i]; >> } >> } >> >> -- >> 1.7.4.1 >> > _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
