OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include "ui/events/gestures/motion_event_aura.h" | 8 #include "ui/events/gestures/motion_event_aura.h" |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "ui/events/gestures/gesture_configuration.h" | 13 #include "ui/events/gestures/gesture_configuration.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 MotionEventAura::MotionEventAura() | 17 MotionEventAura::MotionEventAura() |
18 : pointer_count_(0), cached_action_index_(-1) { | 18 : pointer_count_(0), cached_action_index_(-1) { |
19 } | 19 } |
20 | 20 |
21 MotionEventAura::MotionEventAura( | 21 MotionEventAura::MotionEventAura( |
22 size_t pointer_count, | 22 size_t pointer_count, |
23 const base::TimeTicks& last_touch_time, | 23 const base::TimeTicks& last_touch_time, |
24 Action cached_action, | 24 Action cached_action, |
25 int cached_action_index, | 25 int cached_action_index, |
| 26 int flags, |
26 const PointData (&active_touches)[MotionEvent::MAX_TOUCH_POINT_COUNT]) | 27 const PointData (&active_touches)[MotionEvent::MAX_TOUCH_POINT_COUNT]) |
27 : pointer_count_(pointer_count), | 28 : pointer_count_(pointer_count), |
28 last_touch_time_(last_touch_time), | 29 last_touch_time_(last_touch_time), |
29 cached_action_(cached_action), | 30 cached_action_(cached_action), |
30 cached_action_index_(cached_action_index) { | 31 cached_action_index_(cached_action_index), |
| 32 flags_(flags) { |
31 DCHECK(pointer_count_); | 33 DCHECK(pointer_count_); |
32 for (size_t i = 0; i < pointer_count; ++i) | 34 for (size_t i = 0; i < pointer_count; ++i) |
33 active_touches_[i] = active_touches[i]; | 35 active_touches_[i] = active_touches[i]; |
34 } | 36 } |
35 | 37 |
36 MotionEventAura::~MotionEventAura() {} | 38 MotionEventAura::~MotionEventAura() {} |
37 | 39 |
38 MotionEventAura::PointData MotionEventAura::GetPointDataFromTouchEvent( | 40 MotionEventAura::PointData MotionEventAura::GetPointDataFromTouchEvent( |
39 const TouchEvent& touch) { | 41 const TouchEvent& touch) { |
40 PointData point_data; | 42 PointData point_data; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 break; | 92 break; |
91 case ET_TOUCH_MOVED: | 93 case ET_TOUCH_MOVED: |
92 UpdateTouch(touch); | 94 UpdateTouch(touch); |
93 break; | 95 break; |
94 default: | 96 default: |
95 NOTREACHED(); | 97 NOTREACHED(); |
96 break; | 98 break; |
97 } | 99 } |
98 | 100 |
99 UpdateCachedAction(touch); | 101 UpdateCachedAction(touch); |
| 102 flags_ = touch.flags(); |
100 last_touch_time_ = touch.time_stamp() + base::TimeTicks(); | 103 last_touch_time_ = touch.time_stamp() + base::TimeTicks(); |
101 } | 104 } |
102 | 105 |
103 int MotionEventAura::GetId() const { | 106 int MotionEventAura::GetId() const { |
104 return GetPointerId(0); | 107 return GetPointerId(0); |
105 } | 108 } |
106 | 109 |
107 MotionEvent::Action MotionEventAura::GetAction() const { | 110 MotionEvent::Action MotionEventAura::GetAction() const { |
108 return cached_action_; | 111 return cached_action_; |
109 } | 112 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // TODO(jdduke): Plumb tool type from the platform, crbug.com/404128. | 170 // TODO(jdduke): Plumb tool type from the platform, crbug.com/404128. |
168 DCHECK_LT(pointer_index, pointer_count_); | 171 DCHECK_LT(pointer_index, pointer_count_); |
169 return MotionEvent::TOOL_TYPE_UNKNOWN; | 172 return MotionEvent::TOOL_TYPE_UNKNOWN; |
170 } | 173 } |
171 | 174 |
172 int MotionEventAura::GetButtonState() const { | 175 int MotionEventAura::GetButtonState() const { |
173 NOTIMPLEMENTED(); | 176 NOTIMPLEMENTED(); |
174 return 0; | 177 return 0; |
175 } | 178 } |
176 | 179 |
| 180 int MotionEventAura::GetFlags() const { |
| 181 return flags_; |
| 182 } |
| 183 |
177 base::TimeTicks MotionEventAura::GetEventTime() const { | 184 base::TimeTicks MotionEventAura::GetEventTime() const { |
178 return last_touch_time_; | 185 return last_touch_time_; |
179 } | 186 } |
180 | 187 |
181 scoped_ptr<MotionEvent> MotionEventAura::Clone() const { | 188 scoped_ptr<MotionEvent> MotionEventAura::Clone() const { |
182 return scoped_ptr<MotionEvent>(new MotionEventAura(pointer_count_, | 189 return scoped_ptr<MotionEvent>(new MotionEventAura(pointer_count_, |
183 last_touch_time_, | 190 last_touch_time_, |
184 cached_action_, | 191 cached_action_, |
185 cached_action_index_, | 192 cached_action_index_, |
| 193 flags_, |
186 active_touches_)); | 194 active_touches_)); |
187 } | 195 } |
188 scoped_ptr<MotionEvent> MotionEventAura::Cancel() const { | 196 scoped_ptr<MotionEvent> MotionEventAura::Cancel() const { |
189 return scoped_ptr<MotionEvent>(new MotionEventAura( | 197 return scoped_ptr<MotionEvent>(new MotionEventAura( |
190 pointer_count_, last_touch_time_, ACTION_CANCEL, -1, active_touches_)); | 198 pointer_count_, last_touch_time_, ACTION_CANCEL, -1, 0, active_touches_)); |
191 } | 199 } |
192 | 200 |
193 void MotionEventAura::CleanupRemovedTouchPoints(const TouchEvent& event) { | 201 void MotionEventAura::CleanupRemovedTouchPoints(const TouchEvent& event) { |
194 if (event.type() != ET_TOUCH_RELEASED && | 202 if (event.type() != ET_TOUCH_RELEASED && |
195 event.type() != ET_TOUCH_CANCELLED) { | 203 event.type() != ET_TOUCH_CANCELLED) { |
196 return; | 204 return; |
197 } | 205 } |
198 | 206 |
199 int index_to_delete = static_cast<int>(GetIndexFromId(event.touch_id())); | 207 int index_to_delete = static_cast<int>(GetIndexFromId(event.touch_id())); |
200 pointer_count_--; | 208 pointer_count_--; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 size_t MotionEventAura::GetIndexFromId(int id) const { | 278 size_t MotionEventAura::GetIndexFromId(int id) const { |
271 for (size_t i = 0; i < pointer_count_; ++i) { | 279 for (size_t i = 0; i < pointer_count_; ++i) { |
272 if (active_touches_[i].touch_id == id) | 280 if (active_touches_[i].touch_id == id) |
273 return i; | 281 return i; |
274 } | 282 } |
275 NOTREACHED(); | 283 NOTREACHED(); |
276 return 0; | 284 return 0; |
277 } | 285 } |
278 | 286 |
279 } // namespace ui | 287 } // namespace ui |
OLD | NEW |