[PATCH 10/42] Xi: process raw touch events
Peter Hutterer
peter.hutterer at who-t.net
Fri Dec 16 03:14:38 PST 2011
On 16/12/11 21:03 , walter harms wrote:
>
>
> Am 15.12.2011 04:01, schrieb Peter Hutterer:
>> No-one can generated them yet, but if they could, we'd be processing them
>> like there was no tomorrow.
>>
>> Signed-off-by: Peter Hutterer<peter.hutterer at who-t.net>
>> ---
>> Xi/exevents.c | 3 +++
>> Xi/extinit.c | 3 +++
>> Xi/xiselectev.c | 5 ++++-
>> dix/eventconvert.c | 12 ++++++++++++
>> dix/events.c | 3 +++
>> dix/getevents.c | 11 ++++++++++-
>> include/eventstr.h | 3 +++
>> mi/mieq.c | 3 +++
>> 8 files changed, 41 insertions(+), 2 deletions(-)
>>
>> diff --git a/Xi/exevents.c b/Xi/exevents.c
>> index b05cf2c..2db6053 100644
>> --- a/Xi/exevents.c
>> +++ b/Xi/exevents.c
>> @@ -1063,6 +1063,9 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
>> case ET_RawButtonPress:
>> case ET_RawButtonRelease:
>> case ET_RawMotion:
>> + case ET_RawTouchBegin:
>> + case ET_RawTouchUpdate:
>> + case ET_RawTouchEnd:
>> DeliverRawEvent(&ev->raw_event, device);
>> break;
>> default:
>> diff --git a/Xi/extinit.c b/Xi/extinit.c
>> index 87f7933..0b7bc34 100644
>> --- a/Xi/extinit.c
>> +++ b/Xi/extinit.c
>> @@ -868,6 +868,9 @@ XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
>> case XI_RawKeyRelease:
>> case XI_RawButtonPress:
>> case XI_RawButtonRelease:
>> + case XI_RawTouchBegin:
>> + case XI_RawTouchUpdate:
>> + case XI_RawTouchEnd:
>> SRawEvent((xXIRawEvent*)from, (xXIRawEvent*)to);
>> break;
>> default:
>> diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
>> index ee14edb..815a34f 100644
>> --- a/Xi/xiselectev.c
>> +++ b/Xi/xiselectev.c
>> @@ -145,7 +145,10 @@ ProcXISelectEvents(ClientPtr client)
>> BitIsOn(bits, XI_RawKeyRelease) ||
>> BitIsOn(bits, XI_RawButtonPress) ||
>> BitIsOn(bits, XI_RawButtonRelease) ||
>> - BitIsOn(bits, XI_RawMotion))
>> + BitIsOn(bits, XI_RawMotion) ||
>> + BitIsOn(bits, XI_RawTouchBegin) ||
>> + BitIsOn(bits, XI_RawTouchUpdate) ||
>> + BitIsOn(bits, XI_RawTouchEnd))
>> {
>> client->errorValue = XI_RawKeyPress;
>> return BadValue;
>> diff --git a/dix/eventconvert.c b/dix/eventconvert.c
>> index 3802ea1..582769a 100644
>> --- a/dix/eventconvert.c
>> +++ b/dix/eventconvert.c
>> @@ -158,6 +158,9 @@ EventToCore(InternalEvent *event, xEvent **core_out, int *count_out)
>> case ET_RawButtonPress:
>> case ET_RawButtonRelease:
>> case ET_RawMotion:
>> + case ET_RawTouchBegin:
>> + case ET_RawTouchUpdate:
>> + case ET_RawTouchEnd:
>> case ET_TouchBegin:
>> case ET_TouchUpdate:
>> case ET_TouchEnd:
>> @@ -211,6 +214,9 @@ EventToXI(InternalEvent *ev, xEvent **xi, int *count)
>> case ET_RawButtonPress:
>> case ET_RawButtonRelease:
>> case ET_RawMotion:
>> + case ET_RawTouchBegin:
>> + case ET_RawTouchUpdate:
>> + case ET_RawTouchEnd:
>> case ET_TouchBegin:
>> case ET_TouchUpdate:
>> case ET_TouchEnd:
>> @@ -270,6 +276,9 @@ EventToXI2(InternalEvent *ev, xEvent **xi)
>> case ET_RawButtonPress:
>> case ET_RawButtonRelease:
>> case ET_RawMotion:
>> + case ET_RawTouchBegin:
>> + case ET_RawTouchUpdate:
>> + case ET_RawTouchEnd:
>> return eventToRawEvent(&ev->raw_event, xi);
>> default:
>> break;
>> @@ -827,6 +836,9 @@ GetXI2Type(enum EventType type)
>> case ET_RawButtonPress: xi2type = XI_RawButtonPress; break;
>> case ET_RawButtonRelease: xi2type = XI_RawButtonRelease; break;
>> case ET_RawMotion: xi2type = XI_RawMotion; break;
>> + case ET_RawTouchBegin: xi2type = XI_RawTouchBegin; break;
>> + case ET_RawTouchUpdate: xi2type = XI_RawTouchUpdate; break;
>> + case ET_RawTouchEnd: xi2type = XI_RawTouchEnd; break;
>> case ET_FocusIn: xi2type = XI_FocusIn; break;
>> case ET_FocusOut: xi2type = XI_FocusOut; break;
>> case ET_TouchBegin: xi2type = XI_TouchBegin; break;
>> diff --git a/dix/events.c b/dix/events.c
>> index 2b54969..f80b8fd 100644
>> --- a/dix/events.c
>> +++ b/dix/events.c
>> @@ -2463,6 +2463,9 @@ FixUpEventFromWindow(
>> case XI_RawButtonPress:
>> case XI_RawButtonRelease:
>> case XI_RawMotion:
>> + case XI_RawTouchBegin:
>> + case XI_RawTouchUpdate:
>> + case XI_RawTouchEnd:
>> case XI_DeviceChanged:
>> case XI_HierarchyChanged:
>> case XI_PropertyEvent:
>> diff --git a/dix/getevents.c b/dix/getevents.c
>> index 3b7b626..5bf6658 100644
>> --- a/dix/getevents.c
>> +++ b/dix/getevents.c
>> @@ -161,7 +161,16 @@ init_raw(DeviceIntPtr dev, RawDeviceEvent *event, Time ms, int type, int detail)
>> memset(event, 0, sizeof(RawDeviceEvent));
>> event->header = ET_Internal;
>> event->length = sizeof(RawDeviceEvent);
>> - event->type = ET_RawKeyPress - ET_KeyPress + type;
>> + switch(type) {
>> + case MotionNotify: event->type = ET_RawMotion; break;
>> + case ButtonPress: event->type = ET_RawButtonPress; break;
>> + case ButtonRelease: event->type = ET_RawButtonRelease; break;
>> + case KeyPress: event->type = ET_RawKeyPress; break;
>> + case KeyRelease: event->type = ET_RawKeyRelease; break;
>> + case XI_TouchBegin: event->type = ET_RawTouchBegin; break;
>> + case XI_TouchUpdate: event->type = ET_RawTouchUpdate; break;
>> + case XI_TouchEnd: event->type = ET_RawTouchEnd; break;
>> + }
>
> event->type was
> ET_RawKeyPress - ET_KeyPress + type
> I do not see this in the switch..case , is that intentional ?
> Would it hurt to set it to default ? that would no change the current behavier
> but make sure that you have a proper event->type in case a new type comes up.
it'd be better to have a default: BUG_WARN() statement for that case. I
can add that.
The switch statement replaced the previous calculation because it forced
the ET_* events to be in a specific order. Something that wasn't the
case during development and bit us more than once. This one is much more
explicit.
>
> re,
> wh
>
>
>> event->time = ms;
>> event->deviceid = dev->id;
>> event->sourceid = dev->id;
>> diff --git a/include/eventstr.h b/include/eventstr.h
>> index 9626076..3323073 100644
>> --- a/include/eventstr.h
>> +++ b/include/eventstr.h
>> @@ -67,6 +67,9 @@ enum EventType {
>> ET_RawButtonPress,
>> ET_RawButtonRelease,
>> ET_RawMotion,
>> + ET_RawTouchBegin,
>> + ET_RawTouchUpdate,
>> + ET_RawTouchEnd,
>> ET_XQuartz,
>> ET_Internal = 0xFF /* First byte */
>> };
>> diff --git a/mi/mieq.c b/mi/mieq.c
>> index 06c3d8e..8335289 100644
>> --- a/mi/mieq.c
>> +++ b/mi/mieq.c
>> @@ -384,6 +384,9 @@ ChangeDeviceID(DeviceIntPtr dev, InternalEvent* event)
>> case ET_RawButtonPress:
>> case ET_RawButtonRelease:
>> case ET_RawMotion:
>> + case ET_RawTouchBegin:
>> + case ET_RawTouchEnd:
>> + case ET_RawTouchUpdate:
>> event->raw_event.deviceid = dev->id;
>> break;
>> default:
More information about the xorg-devel
mailing list