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

Side by Side Diff: views/events/event_x.cc

Issue 7927001: touchui: Convert XI2 MT tracking id to slot id for gesture recognizer (Closed) Base URL: nhu@powerbuilder.sh.intel.com:/home/www-data/git-repos/chromium/chromium.git@trunk
Patch Set: Update the patch set according to comment #2. 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 unified diff | Download patch
« no previous file with comments | « no previous file | views/touchui/touch_factory.h » ('j') | views/touchui/touch_factory.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/events/event.h" 5 #include "views/events/event.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkx.h> 8 #include <gdk/gdkx.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (tracking == 0l) { 115 if (tracking == 0l) {
116 // The touch point has been released. 116 // The touch point has been released.
117 return ui::ET_TOUCH_RELEASED; 117 return ui::ET_TOUCH_RELEASED;
118 } 118 }
119 119
120 return ui::ET_TOUCH_MOVED; 120 return ui::ET_TOUCH_MOVED;
121 #endif // defined(USE_XI2_MT) 121 #endif // defined(USE_XI2_MT)
122 } 122 }
123 123
124 int GetTouchIDFromXEvent(XEvent* xev) { 124 int GetTouchIDFromXEvent(XEvent* xev) {
125 float id = 0; 125 float slot = 0;
Daniel Kurtz 2011/09/24 01:53:36 id is a better name, since it is used for both tou
sadrul 2011/09/24 03:06:31 I think 'slot' is fine. Right now, 'slot id' is es
126 #if defined(USE_XI2_MT) 126 #if defined(USE_XI2_MT)
127 // TODO(ningxin.hu@gmail.com): Make the id always start from 0 for a new 127 float tracking_id;
128 // touch-sequence when TRACKING_ID is used to extract the touch id. 128 TouchFactory* factory = TouchFactory::GetInstance();
Daniel Kurtz 2011/09/24 01:53:36 Pull "TouchFactory*" and "return slot" out of the
ningxin.hu 2011/09/25 16:35:39 Thanks. I will follow up.
129 TouchFactory::TouchParam tp = TouchFactory::TP_TRACKING_ID; 129 if (factory->ExtractTouchParam(
130 *xev, TouchFactory::TP_TRACKING_ID, &tracking_id))
131 slot = factory->GetSlotForTrackingID(tracking_id);
132 else
133 LOG(ERROR) << "Could not get the touch ID for the event. Using 0.";
134 return slot;
130 #else 135 #else
131 TouchFactory::TouchParam tp = TouchFactory::TP_SLOT_ID; 136 if (!TouchFactory::GetInstance()->ExtractTouchParam(
137 *xev, TouchFactory::TP_SLOT_ID, &slot))
138 LOG(ERROR) << "Could not get the touch ID for the event. Using 0.";
Daniel Kurtz 2011/09/24 01:53:36 Could not get the slot ID ...
sadrul 2011/09/24 03:06:31 Ditto.
ningxin.hu 2011/09/25 16:35:39 Thanks. Will correct.
139 return slot;
132 #endif 140 #endif
133 if (!TouchFactory::GetInstance()->ExtractTouchParam(
134 *xev, tp, &id))
135 LOG(ERROR) << "Could not get the touch ID for the event. Using 0.";
136 return id;
137 } 141 }
138 142
139 ui::EventType EventTypeFromNative(NativeEvent2 native_event) { 143 ui::EventType EventTypeFromNative(NativeEvent2 native_event) {
140 switch (native_event->type) { 144 switch (native_event->type) {
141 case KeyPress: 145 case KeyPress:
142 return ui::ET_KEY_PRESSED; 146 return ui::ET_KEY_PRESSED;
143 case KeyRelease: 147 case KeyRelease:
144 return ui::ET_KEY_RELEASED; 148 return ui::ET_KEY_RELEASED;
145 case ButtonPress: 149 case ButtonPress:
146 if (native_event->xbutton.button == 4 || 150 if (native_event->xbutton.button == 4 ||
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 radius_x_(GetTouchParamFromXEvent(native_event_2, 421 radius_x_(GetTouchParamFromXEvent(native_event_2,
418 TouchFactory::TP_TOUCH_MAJOR, 422 TouchFactory::TP_TOUCH_MAJOR,
419 2.0) / 2.0), 423 2.0) / 2.0),
420 radius_y_(GetTouchParamFromXEvent(native_event_2, 424 radius_y_(GetTouchParamFromXEvent(native_event_2,
421 TouchFactory::TP_TOUCH_MINOR, 425 TouchFactory::TP_TOUCH_MINOR,
422 2.0) / 2.0), 426 2.0) / 2.0),
423 rotation_angle_(GetTouchParamFromXEvent(native_event_2, 427 rotation_angle_(GetTouchParamFromXEvent(native_event_2,
424 TouchFactory::TP_ORIENTATION, 428 TouchFactory::TP_ORIENTATION,
425 0.0)), 429 0.0)),
426 force_(GetTouchForceFromXEvent(native_event_2)) { 430 force_(GetTouchForceFromXEvent(native_event_2)) {
427 #if !defined(USE_XI2_MT) 431 #if defined(USE_XI2_MT)
432 if (type() == ui::ET_TOUCH_RELEASED) {
433 // NOTE: The slot is allocated by TouchFactory for each XI_TouchBegin
434 // event, which carries a new tracking ID to identify a new touch
435 // sequence.
436 TouchFactory* factory = TouchFactory::GetInstance();
437 float tracking_id;
438 if (factory->ExtractTouchParam(*native_event_2,
439 TouchFactory::TP_TRACKING_ID,
440 &tracking_id)) {
441 factory->ReleaseSlotForTrackingID(tracking_id);
442 }
443 }
444 #else
428 if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) { 445 if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) {
429 TouchFactory* factory = TouchFactory::GetInstance(); 446 TouchFactory* factory = TouchFactory::GetInstance();
430 float slot; 447 float slot;
431 if (factory->ExtractTouchParam(*native_event_2, 448 if (factory->ExtractTouchParam(*native_event_2,
432 TouchFactory::TP_SLOT_ID, &slot)) { 449 TouchFactory::TP_SLOT_ID, &slot)) {
433 factory->SetSlotUsed(slot, type() == ui::ET_TOUCH_PRESSED); 450 factory->SetSlotUsed(slot, type() == ui::ET_TOUCH_PRESSED);
434 } 451 }
435 } 452 }
436 #endif 453 #endif
437 } 454 }
438 455
439 } // namespace views 456 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | views/touchui/touch_factory.h » ('j') | views/touchui/touch_factory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698