Chromium Code Reviews| Index: views/events/event_x.cc |
| diff --git a/views/events/event_x.cc b/views/events/event_x.cc |
| index 1f54303e6b30ca1533e295e2336fc2fee3361d31..31300551fad4ff6fc7e14c160bc09b8983ebfccf 100644 |
| --- a/views/events/event_x.cc |
| +++ b/views/events/event_x.cc |
| @@ -77,6 +77,19 @@ int GetButtonMaskForX2Event(XIDeviceEvent* xievent) { |
| } |
| ui::EventType GetTouchEventType(XEvent* xev) { |
| +#if defined(USE_XI2_MT) |
| + XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); |
| + switch(event->evtype) { |
| + case XI_TouchBegin: |
| + return ui::ET_TOUCH_PRESSED; |
| + case XI_TouchUpdate: |
| + return ui::ET_TOUCH_MOVED; |
| + case XI_TouchEnd: |
| + return ui::ET_TOUCH_RELEASED; |
| + } |
| + |
| + return ui::ET_UNKNOWN; |
| +#else |
| XGenericEventCookie* cookie = &xev->xcookie; |
| DCHECK_EQ(cookie->evtype, XI_Motion); |
| @@ -105,14 +118,22 @@ ui::EventType GetTouchEventType(XEvent* xev) { |
| } |
| return ui::ET_TOUCH_MOVED; |
| +#endif |
|
sadrul
2011/09/19 15:58:08
#endif // defined(USE_XI2_MT)
ningxin.hu
2011/09/20 14:28:59
Will add. Thanks.
|
| } |
| int GetTouchIDFromXEvent(XEvent* xev) { |
| - float slot = 0; |
| + float id = 0; |
| +#if defined(USE_XI2_MT) |
| + // TODO(ningxin.hu@gmail.com): Make the id always start from 0 for a new |
| + // touch-sequence when TRACKING_ID is used to extract the touch id. |
| + TouchFactory::TouchParam tp = TouchFactory::TP_TRACKING_ID; |
| +#else |
| + TouchFactory::TouchParam tp = TouchFactory::TP_SLOT_ID; |
| +#endif |
| if (!TouchFactory::GetInstance()->ExtractTouchParam( |
| - *xev, TouchFactory::TP_SLOT_ID, &slot)) |
| - LOG(ERROR) << "Could not get the slot ID for the event. Using 0."; |
| - return slot; |
| + *xev, tp, &id)) |
| + LOG(ERROR) << "Could not get the touch ID for the event. Using 0."; |
| + return id; |
| } |
| ui::EventType EventTypeFromNative(NativeEvent2 native_event) { |
| @@ -403,6 +424,7 @@ TouchEvent::TouchEvent(NativeEvent2 native_event_2, |
| TouchFactory::TP_ORIENTATION, |
| 0.0)), |
| force_(GetTouchForceFromXEvent(native_event_2)) { |
| +#if !defined(USE_XI2_MT) |
| if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) { |
| TouchFactory* factory = TouchFactory::GetInstance(); |
| float slot; |
| @@ -411,6 +433,7 @@ TouchEvent::TouchEvent(NativeEvent2 native_event_2, |
| factory->SetSlotUsed(slot, type() == ui::ET_TOUCH_PRESSED); |
| } |
| } |
| +#endif |
| } |
| } // namespace views |