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

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: 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.h » ('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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 121 #endif
122 } 122 }
123 123
124 int GetTouchIDFromXEvent(XEvent* xev) { 124 int GetTouchIDFromXEvent(XEvent* xev) {
125 float id = 0; 125 float id = 0;
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();
129 TouchFactory::TouchParam tp = TouchFactory::TP_TRACKING_ID; 129 if (factory->ExtractTouchParam(
130 #else 130 *xev, TouchFactory::TP_TRACKING_ID, &tracking_id))
sadrul 2011/09/19 16:13:36 4-space indent here and in line 137
ningxin.hu 2011/09/20 16:08:49 Will fix. Thanks.
131 TouchFactory::TouchParam tp = TouchFactory::TP_SLOT_ID; 131 id = factory->AllocateSlotIdForTrackingId(tracking_id);
132 #endif 132 else
133 if (!TouchFactory::GetInstance()->ExtractTouchParam(
134 *xev, tp, &id))
135 LOG(ERROR) << "Could not get the touch ID for the event. Using 0."; 133 LOG(ERROR) << "Could not get the touch ID for the event. Using 0.";
136 return id; 134 return id;
135 #else
136 if (!TouchFactory::GetInstance()->ExtractTouchParam(
137 *xev, TouchFactory::TP_SLOT_ID, &id))
138 LOG(ERROR) << "Could not get the touch ID for the event. Using 0.";
139 return id;
140 #endif
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 TouchFactory* factory = TouchFactory::GetInstance();
sadrul 2011/09/19 16:13:36 Please add a NOTE here explaining that for PRESSED
ningxin.hu 2011/09/20 16:08:49 Will do that. Thanks.
434 float tracking_id;
435 if (factory->ExtractTouchParam(*native_event_2,
436 TouchFactory::TP_TRACKING_ID,
437 &tracking_id)) {
438 factory->ReleaseSlotIdForTrackingId(tracking_id);
439 }
440 }
441 #else
428 if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) { 442 if (type() == ui::ET_TOUCH_PRESSED || type() == ui::ET_TOUCH_RELEASED) {
429 TouchFactory* factory = TouchFactory::GetInstance(); 443 TouchFactory* factory = TouchFactory::GetInstance();
430 float slot; 444 float slot;
431 if (factory->ExtractTouchParam(*native_event_2, 445 if (factory->ExtractTouchParam(*native_event_2,
432 TouchFactory::TP_SLOT_ID, &slot)) { 446 TouchFactory::TP_SLOT_ID, &slot)) {
433 factory->SetSlotUsed(slot, type() == ui::ET_TOUCH_PRESSED); 447 factory->SetSlotUsed(slot, type() == ui::ET_TOUCH_PRESSED);
434 } 448 }
435 } 449 }
436 #endif 450 #endif
437 } 451 }
438 452
439 } // namespace views 453 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | views/touchui/touch_factory.h » ('j') | views/touchui/touch_factory.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698