diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-14 12:45:28 +1000 |
---|---|---|
committer | Chase Douglas <chase.douglas@canonical.com> | 2011-12-21 10:34:11 -0800 |
commit | 7d67527d480542c37e2e8879584f3e93efb19e6a (patch) | |
tree | 026f246ee7ebffc704c81d6b4c0e4706970d2623 | |
parent | 820bff7abb8accd29ea891a8ef7c619be11c8dc8 (diff) |
Hook up TouchBegin/Update/End events
The are the same as device events internally but require the touch ID
separately from the detail.button field (the protocol uses the detail field
for the touch id).
For simpler integration of pointer emulation we need to set the
detail.button field while keeping the touchid around.
Add the three new touch event types to the various places in the server
where they need to be handled. The actual handling of the events is somewhat
more complicated in most places.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | Xi/exevents.c | 15 | ||||
-rw-r--r-- | Xi/extinit.c | 3 | ||||
-rw-r--r-- | dix/eventconvert.c | 24 | ||||
-rw-r--r-- | dix/events.c | 3 | ||||
-rw-r--r-- | include/dix.h | 1 | ||||
-rw-r--r-- | include/eventstr.h | 7 | ||||
-rw-r--r-- | mi/mieq.c | 3 |
7 files changed, 53 insertions, 3 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 1e16b7400..b05cf2ce4 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -128,6 +128,21 @@ IsPointerEvent(InternalEvent* event) return FALSE; } +Bool +IsTouchEvent(InternalEvent* event) +{ + switch(event->any.type) + { + case ET_TouchBegin: + case ET_TouchUpdate: + case ET_TouchEnd: + return TRUE; + default: + break; + } + return FALSE; +} + /** * @return the device matching the deviceid of the device set in the event, or * NULL if the event is not an XInput event. diff --git a/Xi/extinit.c b/Xi/extinit.c index b43f9bbc0..87f793321 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -858,6 +858,9 @@ XI2EventSwap(xGenericEvent *from, xGenericEvent *to) case XI_KeyRelease: case XI_ButtonPress: case XI_ButtonRelease: + case XI_TouchBegin: + case XI_TouchUpdate: + case XI_TouchEnd: SDeviceEvent((xXIDeviceEvent*)from, (xXIDeviceEvent*)to); break; case XI_RawMotion: diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 67b420a63..3802ea142 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_TouchBegin: + case ET_TouchUpdate: + case ET_TouchEnd: ret = BadMatch; break; default: @@ -208,6 +211,9 @@ EventToXI(InternalEvent *ev, xEvent **xi, int *count) case ET_RawButtonPress: case ET_RawButtonRelease: case ET_RawMotion: + case ET_TouchBegin: + case ET_TouchUpdate: + case ET_TouchEnd: *count = 0; *xi = NULL; return BadMatch; @@ -249,6 +255,9 @@ EventToXI2(InternalEvent *ev, xEvent **xi) case ET_ButtonRelease: case ET_KeyPress: case ET_KeyRelease: + case ET_TouchBegin: + case ET_TouchUpdate: + case ET_TouchEnd: return eventToDeviceEvent(&ev->device_event, xi); case ET_ProximityIn: case ET_ProximityOut: @@ -650,7 +659,11 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi) xde->evtype = GetXI2Type(ev->type); xde->time = ev->time; xde->length = bytes_to_int32(len - sizeof(xEvent)); - xde->detail = ev->detail.button; + if (IsTouchEvent((InternalEvent*)ev)) + xde->detail = ev->touchid; + else + xde->detail = ev->detail.button; + xde->root = ev->root; xde->buttons_len = btlen; xde->valuators_len = vallen; @@ -659,7 +672,11 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi) xde->root_x = FP1616(ev->root_x, ev->root_x_frac); xde->root_y = FP1616(ev->root_y, ev->root_y_frac); - xde->flags = ev->flags; + if (ev->type == ET_TouchUpdate) + xde->flags |= (ev->flags & TOUCH_PENDING_END) ? XITouchPendingEnd : 0; + else + xde->flags = ev->flags; + if (ev->key_repeat) xde->flags |= XIKeyRepeat; @@ -812,6 +829,9 @@ GetXI2Type(enum EventType type) case ET_RawMotion: xi2type = XI_RawMotion; break; case ET_FocusIn: xi2type = XI_FocusIn; break; case ET_FocusOut: xi2type = XI_FocusOut; break; + case ET_TouchBegin: xi2type = XI_TouchBegin; break; + case ET_TouchEnd: xi2type = XI_TouchEnd; break; + case ET_TouchUpdate: xi2type = XI_TouchUpdate; break; default: break; } diff --git a/dix/events.c b/dix/events.c index eb7bd9296..1ebaf9f78 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2979,6 +2979,9 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev) case ET_ButtonPress: case ET_ButtonRelease: case ET_Motion: + case ET_TouchBegin: + case ET_TouchUpdate: + case ET_TouchEnd: break; default: /* all other events return FALSE */ diff --git a/include/dix.h b/include/dix.h index 272fd4161..60462ecde 100644 --- a/include/dix.h +++ b/include/dix.h @@ -582,6 +582,7 @@ extern Bool DevHasCursor(DeviceIntPtr pDev); extern _X_EXPORT Bool IsPointerDevice(DeviceIntPtr dev); extern _X_EXPORT Bool IsKeyboardDevice(DeviceIntPtr dev); extern Bool IsPointerEvent(InternalEvent *event); +extern Bool IsTouchEvent(InternalEvent *event); extern _X_EXPORT Bool IsMaster(DeviceIntPtr dev); extern _X_EXPORT Bool IsFloating(DeviceIntPtr dev); diff --git a/include/eventstr.h b/include/eventstr.h index 4d836fb14..96260760a 100644 --- a/include/eventstr.h +++ b/include/eventstr.h @@ -50,6 +50,9 @@ enum EventType { ET_ButtonPress, ET_ButtonRelease, ET_Motion, + ET_TouchBegin, + ET_TouchUpdate, + ET_TouchEnd, ET_Enter, ET_Leave, ET_FocusIn, @@ -84,9 +87,11 @@ struct _DeviceEvent int deviceid; /**< Device to post this event for */ int sourceid; /**< The physical source device */ union { - uint32_t button; /**< Button number */ + uint32_t button; /**< Button number (also used in pointer emulating + touch events) */ uint32_t key; /**< Key code */ } detail; + uint32_t touchid; /**< Touch ID (client_id) */ int16_t root_x; /**< Pos relative to root window in integral data */ float root_x_frac; /**< Pos relative to root window in frac part */ int16_t root_y; /**< Pos relative to root window in integral part */ @@ -370,6 +370,9 @@ ChangeDeviceID(DeviceIntPtr dev, InternalEvent* event) case ET_ProximityOut: case ET_Hierarchy: case ET_DeviceChanged: + case ET_TouchBegin: + case ET_TouchUpdate: + case ET_TouchEnd: event->device_event.deviceid = dev->id; break; #if XFreeXDGA |