| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/events/gestures/gesture_recognizer_impl.h" | 5 #include "ui/events/gestures/gesture_recognizer_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 GestureRecognizerImpl::GestureRecognizerImpl() { | 58 GestureRecognizerImpl::GestureRecognizerImpl() { |
| 59 } | 59 } |
| 60 | 60 |
| 61 GestureRecognizerImpl::~GestureRecognizerImpl() { | 61 GestureRecognizerImpl::~GestureRecognizerImpl() { |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Checks if this finger is already down, if so, returns the current target. | 64 // Checks if this finger is already down, if so, returns the current target. |
| 65 // Otherwise, returns NULL. | 65 // Otherwise, returns NULL. |
| 66 GestureConsumer* GestureRecognizerImpl::GetTouchLockedTarget( | 66 GestureConsumer* GestureRecognizerImpl::GetTouchLockedTarget( |
| 67 const TouchEvent& event) { | 67 const TouchEvent& event) { |
| 68 return touch_id_target_[event.touch_id()]; | 68 return touch_id_target_[event.pointer_details().id]; |
| 69 } | 69 } |
| 70 | 70 |
| 71 GestureConsumer* GestureRecognizerImpl::GetTargetForLocation( | 71 GestureConsumer* GestureRecognizerImpl::GetTargetForLocation( |
| 72 const gfx::PointF& location, int source_device_id) { | 72 const gfx::PointF& location, int source_device_id) { |
| 73 const float max_distance = | 73 const float max_distance = |
| 74 GestureConfiguration::GetInstance() | 74 GestureConfiguration::GetInstance() |
| 75 ->max_separation_for_gesture_touches_in_pixels(); | 75 ->max_separation_for_gesture_touches_in_pixels(); |
| 76 | 76 |
| 77 gfx::PointF closest_point; | 77 gfx::PointF closest_point; |
| 78 int closest_touch_id = 0; | 78 int closest_touch_id = 0; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // but has some pointers down which need cancelling. In order to ensure that | 160 // but has some pointers down which need cancelling. In order to ensure that |
| 161 // the GR sees a valid event stream, inform it of these pointers via | 161 // the GR sees a valid event stream, inform it of these pointers via |
| 162 // OnTouchEnter, and then synthesize a touch cancel per pointer. | 162 // OnTouchEnter, and then synthesize a touch cancel per pointer. |
| 163 if (should_cancel_touches == | 163 if (should_cancel_touches == |
| 164 GestureRecognizer::ShouldCancelTouches::Cancel && | 164 GestureRecognizer::ShouldCancelTouches::Cancel && |
| 165 helper) { | 165 helper) { |
| 166 GestureProviderAura* gesture_provider = | 166 GestureProviderAura* gesture_provider = |
| 167 GetGestureProviderForConsumer(current_consumer); | 167 GetGestureProviderForConsumer(current_consumer); |
| 168 | 168 |
| 169 for (std::unique_ptr<TouchEvent>& event : cancelling_touches) { | 169 for (std::unique_ptr<TouchEvent>& event : cancelling_touches) { |
| 170 gesture_provider->OnTouchEnter(event->touch_id(), event->x(), event->y()); | 170 gesture_provider->OnTouchEnter(event->pointer_details().id, event->x(), |
| 171 event->y()); |
| 171 helper->DispatchSyntheticTouchEvent(event.get()); | 172 helper->DispatchSyntheticTouchEvent(event.get()); |
| 172 } | 173 } |
| 173 } | 174 } |
| 174 | 175 |
| 175 for (int touch_id : touchids_targeted_at_current) | 176 for (int touch_id : touchids_targeted_at_current) |
| 176 touch_id_target_[touch_id] = new_consumer; | 177 touch_id_target_[touch_id] = new_consumer; |
| 177 } | 178 } |
| 178 | 179 |
| 179 bool GestureRecognizerImpl::GetLastTouchPointForTarget( | 180 bool GestureRecognizerImpl::GetLastTouchPointForTarget( |
| 180 GestureConsumer* consumer, | 181 GestureConsumer* consumer, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 gesture_provider = new GestureProviderAura(consumer, this); | 237 gesture_provider = new GestureProviderAura(consumer, this); |
| 237 consumer_gesture_provider_[consumer] = base::WrapUnique(gesture_provider); | 238 consumer_gesture_provider_[consumer] = base::WrapUnique(gesture_provider); |
| 238 } | 239 } |
| 239 return gesture_provider; | 240 return gesture_provider; |
| 240 } | 241 } |
| 241 | 242 |
| 242 void GestureRecognizerImpl::SetupTargets(const TouchEvent& event, | 243 void GestureRecognizerImpl::SetupTargets(const TouchEvent& event, |
| 243 GestureConsumer* target) { | 244 GestureConsumer* target) { |
| 244 if (event.type() == ui::ET_TOUCH_RELEASED || | 245 if (event.type() == ui::ET_TOUCH_RELEASED || |
| 245 event.type() == ui::ET_TOUCH_CANCELLED) { | 246 event.type() == ui::ET_TOUCH_CANCELLED) { |
| 246 touch_id_target_.erase(event.touch_id()); | 247 touch_id_target_.erase(event.pointer_details().id); |
| 247 } else if (event.type() == ui::ET_TOUCH_PRESSED) { | 248 } else if (event.type() == ui::ET_TOUCH_PRESSED) { |
| 248 touch_id_target_[event.touch_id()] = target; | 249 touch_id_target_[event.pointer_details().id] = target; |
| 249 } | 250 } |
| 250 } | 251 } |
| 251 | 252 |
| 252 void GestureRecognizerImpl::DispatchGestureEvent( | 253 void GestureRecognizerImpl::DispatchGestureEvent( |
| 253 GestureConsumer* raw_input_consumer, | 254 GestureConsumer* raw_input_consumer, |
| 254 GestureEvent* event) { | 255 GestureEvent* event) { |
| 255 if (raw_input_consumer) { | 256 if (raw_input_consumer) { |
| 256 GestureEventHelper* helper = | 257 GestureEventHelper* helper = |
| 257 FindDispatchHelperForConsumer(raw_input_consumer); | 258 FindDispatchHelperForConsumer(raw_input_consumer); |
| 258 if (helper) | 259 if (helper) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 std::vector<GestureEventHelper*>::iterator it; | 351 std::vector<GestureEventHelper*>::iterator it; |
| 351 for (it = helpers.begin(); it != helpers.end(); ++it) | 352 for (it = helpers.begin(); it != helpers.end(); ++it) |
| 352 gesture_recognizer->AddGestureEventHelper(*it); | 353 gesture_recognizer->AddGestureEventHelper(*it); |
| 353 | 354 |
| 354 helpers.clear(); | 355 helpers.clear(); |
| 355 g_gesture_recognizer_instance = | 356 g_gesture_recognizer_instance = |
| 356 static_cast<GestureRecognizerImpl*>(gesture_recognizer); | 357 static_cast<GestureRecognizerImpl*>(gesture_recognizer); |
| 357 } | 358 } |
| 358 | 359 |
| 359 } // namespace ui | 360 } // namespace ui |
| OLD | NEW |