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

Side by Side Diff: ui/events/gestures/gesture_recognizer_impl.cc

Issue 103173004: Target touches to the correct display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 GestureConsumer* GestureRecognizerImpl::GetTargetForGestureEvent( 72 GestureConsumer* GestureRecognizerImpl::GetTargetForGestureEvent(
73 const GestureEvent& event) { 73 const GestureEvent& event) {
74 GestureConsumer* target = NULL; 74 GestureConsumer* target = NULL;
75 int touch_id = event.GetLowestTouchId(); 75 int touch_id = event.GetLowestTouchId();
76 target = touch_id_target_for_gestures_[touch_id]; 76 target = touch_id_target_for_gestures_[touch_id];
77 return target; 77 return target;
78 } 78 }
79 79
80 GestureConsumer* GestureRecognizerImpl::GetTargetForLocation( 80 GestureConsumer* GestureRecognizerImpl::GetTargetForLocation(
81 const gfx::Point& location) { 81 const gfx::Point& location, int source_device_id) {
82 const GesturePoint* closest_point = NULL; 82 const GesturePoint* closest_point = NULL;
83 int64 closest_distance_squared = 0; 83 int64 closest_distance_squared = 0;
84 std::map<GestureConsumer*, GestureSequence*>::iterator i; 84 std::map<GestureConsumer*, GestureSequence*>::iterator i;
85 for (i = consumer_sequence_.begin(); i != consumer_sequence_.end(); ++i) { 85 for (i = consumer_sequence_.begin(); i != consumer_sequence_.end(); ++i) {
86 const GesturePoint* points = i->second->points(); 86 const GesturePoint* points = i->second->points();
87 for (int j = 0; j < GestureSequence::kMaxGesturePoints; ++j) { 87 for (int j = 0; j < GestureSequence::kMaxGesturePoints; ++j) {
88 if (!points[j].in_use()) 88 if (!points[j].in_use() ||
89 source_device_id != points[j].source_device_id()) {
89 continue; 90 continue;
91 }
90 gfx::Vector2d delta = points[j].last_touch_position() - location; 92 gfx::Vector2d delta = points[j].last_touch_position() - location;
91 // Relative distance is all we need here, so LengthSquared() is 93 // Relative distance is all we need here, so LengthSquared() is
92 // appropriate, and cheaper than Length(). 94 // appropriate, and cheaper than Length().
93 int64 distance_squared = delta.LengthSquared(); 95 int64 distance_squared = delta.LengthSquared();
94 if (!closest_point || distance_squared < closest_distance_squared) { 96 if (!closest_point || distance_squared < closest_distance_squared) {
95 closest_point = &points[j]; 97 closest_point = &points[j];
96 closest_distance_squared = distance_squared; 98 closest_distance_squared = distance_squared;
97 } 99 }
98 } 100 }
99 } 101 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 std::vector<GestureEventHelper*>::iterator it; 280 std::vector<GestureEventHelper*>::iterator it;
279 for (it = helpers.begin(); it != helpers.end(); ++it) 281 for (it = helpers.begin(); it != helpers.end(); ++it)
280 gesture_recognizer->AddGestureEventHelper(*it); 282 gesture_recognizer->AddGestureEventHelper(*it);
281 283
282 helpers.clear(); 284 helpers.clear();
283 g_gesture_recognizer_instance = 285 g_gesture_recognizer_instance =
284 static_cast<GestureRecognizerImpl*>(gesture_recognizer); 286 static_cast<GestureRecognizerImpl*>(gesture_recognizer);
285 } 287 }
286 288
287 } // namespace ui 289 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698