Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: views/events/event_x.cc

Issue 8070003: touchui: Convert XI2 MT tracking id to slot id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/touch/touch_factory.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/events/event_x.cc
diff --git a/views/events/event_x.cc b/views/events/event_x.cc
index cbbc477a83fff2227cbbac593eab6e107b867079..f5cfd43ddfe57c10648ea3a5a9765a12d23fe5e5 100644
--- a/views/events/event_x.cc
+++ b/views/events/event_x.cc
@@ -20,20 +20,28 @@ namespace views {
namespace {
int GetTouchIDFromXEvent(XEvent* xev) {
- float id = 0;
+ float slot = 0;
+ ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
+ XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
+ if (!factory->IsRealTouchDevice(xievent->sourceid)) {
+ // TODO(sad): Come up with a way to generate touch-ids for multi-touch
+ // events when touch-events are generated from a mouse.
+ return slot;
+ }
+
#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.
- ui::TouchFactory::TouchParam tp = ui::TouchFactory::TP_TRACKING_ID;
+ float tracking_id;
+ if (!factory->ExtractTouchParam(
+ *xev, ui::TouchFactory::TP_TRACKING_ID, &tracking_id))
+ LOG(ERROR) << "Could not get the slot ID for the event. Using 0.";
+ else
+ slot = factory->GetSlotForTrackingID(tracking_id);
#else
- ui::TouchFactory::TouchParam tp = ui::TouchFactory::TP_SLOT_ID;
+ if (!factory->ExtractTouchParam(
+ *xev, ui::TouchFactory::TP_SLOT_ID, &slot))
+ LOG(ERROR) << "Could not get the slot ID for the event. Using 0.";
#endif
- ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
- XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
- if (factory->IsRealTouchDevice(xievent->sourceid) &&
- !factory->ExtractTouchParam(*xev, tp, &id))
- LOG(ERROR) << "Could not get the touch ID for the event. Using 0.";
- return id;
+ return slot;
}
uint16 GetCharacterFromXKeyEvent(XKeyEvent* key) {
@@ -174,7 +182,20 @@ TouchEvent::TouchEvent(const ui::NativeEvent& native_event)
ui::TouchFactory::TP_ORIENTATION,
0.0)),
force_(GetTouchForceFromXEvent(native_event)) {
-#if !defined(USE_XI2_MT)
+#if defined(USE_XI2_MT)
+ if (type() == ui::ET_TOUCH_RELEASED) {
+ // NOTE: The slot is allocated by TouchFactory for each XI_TouchBegin
+ // event, which carries a new tracking ID to identify a new touch
+ // sequence.
+ ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
+ float tracking_id;
+ if (factory->ExtractTouchParam(*native_event,
+ ui::TouchFactory::TP_TRACKING_ID,
+ &tracking_id)) {
+ factory->ReleaseSlotForTrackingID(tracking_id);
+ }
+ }
+#else
if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) {
ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
float slot;
« no previous file with comments | « ui/base/touch/touch_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698