diff options
author | Daniel Stone <daniel@fooishbar.org> | 2010-09-20 15:03:08 +1000 |
---|---|---|
committer | Chase Douglas <chase.douglas@ubuntu.com> | 2010-10-08 22:25:33 +0200 |
commit | e080d09ea9f4908b5802510f48b8453efb608b8d (patch) | |
tree | b48311e8f7bbf7f2c82b7f5b94b6b947f17236a3 /src/XExtInt.c | |
parent | ccbebb111fb2084716fce67cb44b5bd8b86adbbc (diff) |
Add support to libXi for all the Xi 2.1 additions to the spec:
TouchClass, TouchBegin, TouchEnd and TouchMotion, as well as touch grabs.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'src/XExtInt.c')
-rw-r--r-- | src/XExtInt.c | 136 |
1 files changed, 135 insertions, 1 deletions
diff --git a/src/XExtInt.c b/src/XExtInt.c index eed6637..8dff669 100644 --- a/src/XExtInt.c +++ b/src/XExtInt.c @@ -146,6 +146,10 @@ static int wireToEnterLeave(xXIEnterEvent *in, XGenericEventCookie *cookie); static int wireToPropertyEvent(xXIPropertyEvent *in, XGenericEventCookie *cookie); +static int +wireToTouchStateEvent(xXITouchStateEvent *in, XGenericEventCookie *cookie); +static int +wireToTouchMotionEvent(xXITouchMotionEvent*in, XGenericEventCookie *cookie); static /* const */ XEvent emptyevent; @@ -268,7 +272,8 @@ static XExtensionVersion versions[] = { {XI_Absent, 0, 0}, XI_Add_DevicePresenceNotify_Minor}, {XI_Present, XI_Add_DeviceProperties_Major, XI_Add_DeviceProperties_Minor}, -{XI_Present, XI_2_Major, XI_2_Minor} +{XI_Present, XI_2_Major, XI_2_Minor}, +{XI_Present, XI_2_Major, XI_2_1_Minor} }; /*********************************************************************** @@ -985,6 +990,25 @@ XInputWireToCookie( break; } return ENQUEUE_EVENT; + case XI_TouchBegin: + case XI_TouchEnd: + *cookie = *(XGenericEventCookie*)save; + if (!wireToTouchStateEvent((xXITouchStateEvent*)event, cookie)) + { + printf("XInputWireToCookie: CONVERSION FAILURE! evtype=%d\n", + ge->evtype); + break; + } + return ENQUEUE_EVENT; + case XI_TouchMotion: + *cookie = *(XGenericEventCookie*)save; + if (!wireToTouchMotionEvent((xXITouchMotionEvent*)event, cookie)) + { + printf("XInputWireToCookie: CONVERSION FAILURE! evtype=%d\n", + ge->evtype); + break; + } + return ENQUEUE_EVENT; default: printf("XInputWireToCookie: Unknown generic event. type %d\n", ge->evtype); @@ -1037,6 +1061,10 @@ sizeDeviceClassType(int type, int num_elements) case XIValuatorClass: l = sizeof(XIValuatorClassInfo); break; + case XITouchClass: + l = sizeof(XITouchClassInfo); + l += num_elements * sizeof(XITouchInfo); + break; default: printf("sizeDeviceClassType: unknown type %d\n", type); break; @@ -1426,6 +1454,9 @@ size_classes(xXIAnyInfo* from, int nclasses) case XIValuatorClass: l = sizeDeviceClassType(XIValuatorClass, 0); break; + case XITouchClass: + l = sizeDeviceClassType(XITouchClass, + ((xXITouchClassInfo*)any_wire)->num_touches); } len += l; @@ -1526,6 +1557,51 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int nclasses) } break; + case XITouchClass: + { + XITouchClassInfo *cls_lib; + xXITouchClassInfo *cls_wire; + XITouchInfo *tp_lib; + xXITouchInfo *tp_wire; + int j; + + cls_wire = (xXITouchClassInfo*)any_wire; + cls_lib = next_block(&ptr_lib, + sizeof(XITouchClassInfo) + + (cls_wire->num_touches * + sizeof(XITouchInfo))); + + cls_lib->mode = cls_wire->mode; + /* FIXME: fractional parts */ + cls_lib->min_x = cls_wire->min_x.integral; + cls_lib->max_x = cls_wire->max_x.integral; + cls_lib->min_y = cls_wire->min_y.integral; + cls_lib->max_y = cls_wire->max_y.integral; + cls_lib->min_touch_width = + cls_wire->min_touch_width.integral; + cls_lib->max_touch_width = + cls_wire->max_touch_width.integral; + cls_lib->max_touches = cls_wire->max_touches; + cls_lib->num_touches = cls_wire->num_touches; + cls_lib->touches = (XITouchInfo *) &cls_lib[1]; + + tp_lib = cls_lib->touches; + tp_wire = (xXITouchInfo *) &cls_wire[1]; + for (j = 0; j < cls_wire->num_touches; j++) { + tp_lib->touchid = tp_wire->touchid; + tp_lib->tool = tp_wire->tool; + tp_lib->x = tp_wire->x.integral; + tp_lib->y = tp_wire->y.integral; + tp_lib->touch_major = tp_wire->touch_major.integral; + tp_lib->touch_minor = tp_wire->touch_minor.integral; + tp_lib->tool_major = tp_wire->tool_major.integral; + tp_lib->tool_minor = tp_wire->tool_minor.integral; + tp_lib->orientation = tp_wire->orientation; + tp_lib++; + tp_wire++; + } + } + break; } len += any_wire->length * 4; ptr_wire += any_wire->length * 4; @@ -1711,3 +1787,61 @@ wireToPropertyEvent(xXIPropertyEvent *in, XGenericEventCookie *cookie) return 1; } + +static int +wireToTouchStateEvent(xXITouchStateEvent *in, XGenericEventCookie *cookie) +{ + XITouchStateEvent *out = malloc(sizeof(XITouchStateEvent)); + + cookie->data = out; + + out->type = in->type; + out->extension = in->extension; + out->evtype = in->evtype; + out->send_event = ((in->type & 0x80) != 0); + out->time = in->time; + out->deviceid = in->deviceid; + out->sourceid = in->sourceid; + out->root = in->root; + out->event = in->event; + out->child = in->child; + out->touchid = in->touchid; + out->tool = in->tool; + + return 1; +} + +static int +wireToTouchMotionEvent(xXITouchMotionEvent *in, XGenericEventCookie *cookie) +{ + XITouchMotionEvent *out = malloc(sizeof(XITouchMotionEvent)); + + cookie->data = out; + + out->type = in->type; + out->extension = in->extension; + out->evtype = in->evtype; + out->send_event = ((in->type & 0x80) != 0); + out->time = in->time; + out->deviceid = in->deviceid; + out->sourceid = in->sourceid; + out->mask = in->mask; + out->root = in->root; + out->event = in->event; + out->child = in->child; + out->touchid = in->touchid; + out->root_x = FP1616toDBL(in->root_x); + out->root_y = FP1616toDBL(in->root_y); + out->event_x = FP1616toDBL(in->event_x); + out->event_y = FP1616toDBL(in->event_y); + /* FIXME: fractional values */ + out->x = in->x.integral; + out->y = in->y.integral; + out->touch_width_major = in->touch_width_major.integral; + out->touch_width_minor = in->touch_width_minor.integral; + out->tool_width_major = in->tool_width_major.integral; + out->tool_width_minor = in->tool_width_minor.integral; + out->orientation = in->orientation; + + return 1; +} |