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..2e5fe9753c07582c3c59b81343a8dbfd05ddbe3f 100644 |
| --- a/views/events/event_x.cc |
| +++ b/views/events/event_x.cc |
| @@ -76,43 +76,30 @@ int GetButtonMaskForX2Event(XIDeviceEvent* xievent) { |
| return buttonflags; |
| } |
| -ui::EventType GetTouchEventType(XEvent* xev) { |
| - XGenericEventCookie* cookie = &xev->xcookie; |
| - DCHECK_EQ(cookie->evtype, XI_Motion); |
| +int GetTouchIDFromXEvent(XEvent* xev) { |
| + float id = 0; |
| + if (!TouchFactory::GetInstance()->ExtractTouchParam( |
| + *xev, TouchFactory::TP_TRACKING_ID, &id)) |
|
sadrul
2011/09/06 14:35:21
Are TRACKING_ID's recycled by XInput2.1? As far as
ningxin.hu
2011/09/07 08:49:58
With XI2.1, TRACKING_ID is increased for each new
|
| + LOG(ERROR) << "Could not get the touch ID for the event. Using 0."; |
| + return id; |
| +} |
| +ui::EventType GetTouchEventType(XEvent* xev) { |
| + XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); |
| // Note: We will not generate a _STATIONARY event here. It will be created, |
| // when necessary, by a RWHVV. |
| // TODO(sad): When should _CANCELLED be generated? |
| - TouchFactory* factory = TouchFactory::GetInstance(); |
| - float slot; |
| - if (!factory->ExtractTouchParam(*xev, TouchFactory::TP_SLOT_ID, &slot)) |
| - return ui::ET_UNKNOWN; |
| - |
| - if (!factory->IsSlotUsed(slot)) { |
| - // This is a new touch point. |
| - return ui::ET_TOUCH_PRESSED; |
| - } |
| - |
| - float tracking; |
| - if (!factory->ExtractTouchParam(*xev, TouchFactory::TP_TRACKING_ID, |
| - &tracking)) |
| - return ui::ET_UNKNOWN; |
| - |
| - if (tracking == 0l) { |
| - // The touch point has been released. |
| - return ui::ET_TOUCH_RELEASED; |
| + 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_TOUCH_MOVED; |
| -} |
| - |
| -int GetTouchIDFromXEvent(XEvent* xev) { |
| - float slot = 0; |
| - 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; |
| + return ui::ET_UNKNOWN; |
| } |
| ui::EventType EventTypeFromNative(NativeEvent2 native_event) { |
| @@ -403,14 +390,6 @@ TouchEvent::TouchEvent(NativeEvent2 native_event_2, |
| TouchFactory::TP_ORIENTATION, |
| 0.0)), |
| force_(GetTouchForceFromXEvent(native_event_2)) { |
| - if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) { |
| - TouchFactory* factory = TouchFactory::GetInstance(); |
| - float slot; |
| - if (factory->ExtractTouchParam(*native_event_2, |
| - TouchFactory::TP_SLOT_ID, &slot)) { |
| - factory->SetSlotUsed(slot, type() == ui::ET_TOUCH_PRESSED); |
| - } |
| - } |
| } |
| } // namespace views |