Commit 98a4770f authored by noamsml@google.com's avatar noamsml@google.com

Revert 243974 "Target touches to the correct display."

> Target touches to the correct display.
> 
> ui::TouchEvents now know the id of their source device.
> 
> The target of a touch can't be effected by a touch on another display.
> 
> BUG=315651
> TEST=GestureRecognizerTest.GestureEventTouchLockIgnoresOtherScreens
> 
> Review URL: https://codereview.chromium.org/103173004

TBR=tdresser@chromium.org

Review URL: https://codereview.chromium.org/132363004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244020 0039d316-1c4b-4281-b951-d872f2087c98
parent 0f258ce7
...@@ -2169,13 +2169,13 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { ...@@ -2169,13 +2169,13 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
// Touches should now be associated with the closest touch within // Touches should now be associated with the closest touch within
// ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels
target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11), -1); target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11));
EXPECT_EQ("0", WindowIDAsString(target)); EXPECT_EQ("0", WindowIDAsString(target));
target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11), -1); target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11));
EXPECT_EQ("1", WindowIDAsString(target)); EXPECT_EQ("1", WindowIDAsString(target));
target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 511), -1); target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 511));
EXPECT_EQ("2", WindowIDAsString(target)); EXPECT_EQ("2", WindowIDAsString(target));
target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 511), -1); target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 511));
EXPECT_EQ("3", WindowIDAsString(target)); EXPECT_EQ("3", WindowIDAsString(target));
// Add a touch in the middle associated with windows[2] // Add a touch in the middle associated with windows[2]
...@@ -2186,20 +2186,20 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { ...@@ -2186,20 +2186,20 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
kNumWindows, tes.Now()); kNumWindows, tes.Now());
dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move); dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
target = gesture_recognizer->GetTargetForLocation(gfx::Point(250, 250), -1); target = gesture_recognizer->GetTargetForLocation(gfx::Point(250, 250));
EXPECT_EQ("2", WindowIDAsString(target)); EXPECT_EQ("2", WindowIDAsString(target));
// Make sure that ties are broken by distance to a current touch // Make sure that ties are broken by distance to a current touch
// Closer to the point in the bottom right. // Closer to the point in the bottom right.
target = gesture_recognizer->GetTargetForLocation(gfx::Point(380, 380), -1); target = gesture_recognizer->GetTargetForLocation(gfx::Point(380, 380));
EXPECT_EQ("3", WindowIDAsString(target)); EXPECT_EQ("3", WindowIDAsString(target));
// This touch is closer to the point in the middle // This touch is closer to the point in the middle
target = gesture_recognizer->GetTargetForLocation(gfx::Point(300, 300), -1); target = gesture_recognizer->GetTargetForLocation(gfx::Point(300, 300));
EXPECT_EQ("2", WindowIDAsString(target)); EXPECT_EQ("2", WindowIDAsString(target));
// A touch too far from other touches won't be locked to anything // A touch too far from other touches won't be locked to anything
target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000), -1); target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000));
EXPECT_TRUE(target == NULL); EXPECT_TRUE(target == NULL);
// Move a touch associated with windows[2] to 1000, 1000 // Move a touch associated with windows[2] to 1000, 1000
...@@ -2207,7 +2207,7 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { ...@@ -2207,7 +2207,7 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
kNumWindows, tes.Now()); kNumWindows, tes.Now());
dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2); dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move2);
target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000), -1); target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000));
EXPECT_EQ("2", WindowIDAsString(target)); EXPECT_EQ("2", WindowIDAsString(target));
for (int i = 0; i < kNumWindows; ++i) { for (int i = 0; i < kNumWindows; ++i) {
...@@ -2217,36 +2217,6 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { ...@@ -2217,36 +2217,6 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
} }
} }
// Check that a touch's target will not be effected by a touch on a different
// screen.
TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
gfx::Rect bounds(0, 0, 10, 10);
scoped_ptr<aura::Window> window(
CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window()));
const int kTouchId1 = 8;
const int kTouchId2 = 2;
TimedEvents tes;
ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(5, 5),
kTouchId1, tes.Now());
press1.set_source_device_id(1);
dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press1);
ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20),
kTouchId2, tes.Now());
press2.set_source_device_id(2);
dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
// The second press should not have been locked to the same target as the
// first, as they occured on different displays.
EXPECT_NE(
ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1),
ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2));
}
// Check that touch events outside the root window are still handled // Check that touch events outside the root window are still handled
// by the root window's gesture sequence. // by the root window's gesture sequence.
TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) { TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) {
......
...@@ -105,7 +105,6 @@ void AuraTestHelper::TearDown() { ...@@ -105,7 +105,6 @@ void AuraTestHelper::TearDown() {
focus_client_.reset(); focus_client_.reset();
client::SetFocusClient(root_window(), NULL); client::SetFocusClient(root_window(), NULL);
root_window_.reset(); root_window_.reset();
ui::GestureRecognizer::Reset();
test_screen_.reset(); test_screen_.reset();
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL);
......
...@@ -110,8 +110,7 @@ Window* WindowTargeter::FindTargetInRootWindow(Window* root_window, ...@@ -110,8 +110,7 @@ Window* WindowTargeter::FindTargetInRootWindow(Window* root_window,
if (consumer) if (consumer)
return static_cast<Window*>(consumer); return static_cast<Window*>(consumer);
consumer = consumer =
ui::GestureRecognizer::Get()->GetTargetForLocation( ui::GestureRecognizer::Get()->GetTargetForLocation(event.location());
event.location(), touch.source_device_id());
if (consumer) if (consumer)
return static_cast<Window*>(consumer); return static_cast<Window*>(consumer);
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "ui/events/event.h" #include "ui/events/event.h"
#if defined(USE_X11) #if defined(USE_X11)
#include <X11/extensions/XInput2.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#endif #endif
...@@ -438,8 +437,7 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event) ...@@ -438,8 +437,7 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event)
radius_x_(GetTouchRadiusX(native_event)), radius_x_(GetTouchRadiusX(native_event)),
radius_y_(GetTouchRadiusY(native_event)), radius_y_(GetTouchRadiusY(native_event)),
rotation_angle_(GetTouchAngle(native_event)), rotation_angle_(GetTouchAngle(native_event)),
force_(GetTouchForce(native_event)), force_(GetTouchForce(native_event)) {
source_device_id_(-1) {
latency()->AddLatencyNumberWithTimestamp( latency()->AddLatencyNumberWithTimestamp(
INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
0, 0,
...@@ -447,12 +445,6 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event) ...@@ -447,12 +445,6 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event)
base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()),
1, 1,
true); true);
#if defined(USE_X11)
XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(native_event->xcookie.data);
source_device_id_ = xiev->deviceid;
#endif
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
} }
...@@ -465,8 +457,7 @@ TouchEvent::TouchEvent(EventType type, ...@@ -465,8 +457,7 @@ TouchEvent::TouchEvent(EventType type,
radius_x_(0.0f), radius_x_(0.0f),
radius_y_(0.0f), radius_y_(0.0f),
rotation_angle_(0.0f), rotation_angle_(0.0f),
force_(0.0f), force_(0.0f) {
source_device_id_(-1) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
} }
...@@ -484,8 +475,7 @@ TouchEvent::TouchEvent(EventType type, ...@@ -484,8 +475,7 @@ TouchEvent::TouchEvent(EventType type,
radius_x_(radius_x), radius_x_(radius_x),
radius_y_(radius_y), radius_y_(radius_y),
rotation_angle_(angle), rotation_angle_(angle),
force_(force), force_(force) {
source_device_id_(-1) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
} }
......
...@@ -437,8 +437,7 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent { ...@@ -437,8 +437,7 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
radius_x_(model.radius_x_), radius_x_(model.radius_x_),
radius_y_(model.radius_y_), radius_y_(model.radius_y_),
rotation_angle_(model.rotation_angle_), rotation_angle_(model.rotation_angle_),
force_(model.force_), force_(model.force_) {
source_device_id_(model.source_device_id_) {
} }
TouchEvent(EventType type, TouchEvent(EventType type,
...@@ -463,7 +462,6 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent { ...@@ -463,7 +462,6 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
float radius_y() const { return radius_y_; } float radius_y() const { return radius_y_; }
float rotation_angle() const { return rotation_angle_; } float rotation_angle() const { return rotation_angle_; }
float force() const { return force_; } float force() const { return force_; }
int source_device_id() const { return source_device_id_; }
// Relocate the touch-point to a new |origin|. // Relocate the touch-point to a new |origin|.
// This is useful when touch event is in X Root Window coordinates, // This is useful when touch event is in X Root Window coordinates,
...@@ -473,9 +471,6 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent { ...@@ -473,9 +471,6 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
// Used for unit tests. // Used for unit tests.
void set_radius_x(const float r) { radius_x_ = r; } void set_radius_x(const float r) { radius_x_ = r; }
void set_radius_y(const float r) { radius_y_ = r; } void set_radius_y(const float r) { radius_y_ = r; }
void set_source_device_id(int source_device_id) {
source_device_id_ = source_device_id;
}
// Overridden from LocatedEvent. // Overridden from LocatedEvent.
virtual void UpdateForRootTransform( virtual void UpdateForRootTransform(
...@@ -509,9 +504,6 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent { ...@@ -509,9 +504,6 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
// Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0.
float force_; float force_;
// The device id of the screen the event came from. Default to be -1.
int source_device_id_;
}; };
class EVENTS_EXPORT KeyEvent : public Event { class EVENTS_EXPORT KeyEvent : public Event {
......
...@@ -24,8 +24,7 @@ GesturePoint::GesturePoint() ...@@ -24,8 +24,7 @@ GesturePoint::GesturePoint()
velocity_calculator_( velocity_calculator_(
GestureConfiguration::points_buffered_for_velocity()), GestureConfiguration::points_buffered_for_velocity()),
point_id_(-1), point_id_(-1),
touch_id_(-1), touch_id_(-1) {
source_device_id_(-1) {
} }
GesturePoint::~GesturePoint() {} GesturePoint::~GesturePoint() {}
...@@ -35,7 +34,6 @@ void GesturePoint::Reset() { ...@@ -35,7 +34,6 @@ void GesturePoint::Reset() {
ResetVelocity(); ResetVelocity();
point_id_ = -1; point_id_ = -1;
clear_enclosing_rectangle(); clear_enclosing_rectangle();
source_device_id_ = -1;
} }
void GesturePoint::ResetVelocity() { void GesturePoint::ResetVelocity() {
......
...@@ -79,11 +79,6 @@ class GesturePoint { ...@@ -79,11 +79,6 @@ class GesturePoint {
const gfx::Rect& enclosing_rectangle() const { return enclosing_rect_; } const gfx::Rect& enclosing_rectangle() const { return enclosing_rect_; }
void set_source_device_id(int source_device_id) {
source_device_id_ = source_device_id;
}
int source_device_id() const { return source_device_id_; }
private: private:
// Various statistical functions to manipulate gestures. // Various statistical functions to manipulate gestures.
...@@ -136,8 +131,6 @@ class GesturePoint { ...@@ -136,8 +131,6 @@ class GesturePoint {
// Count of the number of events with same direction. // Count of the number of events with same direction.
gfx::Vector2d same_direction_count_; gfx::Vector2d same_direction_count_;
int source_device_id_;
DISALLOW_COPY_AND_ASSIGN(GesturePoint); DISALLOW_COPY_AND_ASSIGN(GesturePoint);
}; };
......
...@@ -19,7 +19,6 @@ class EVENTS_EXPORT GestureRecognizer { ...@@ -19,7 +19,6 @@ class EVENTS_EXPORT GestureRecognizer {
public: public:
static GestureRecognizer* Create(); static GestureRecognizer* Create();
static GestureRecognizer* Get(); static GestureRecognizer* Get();
static void Reset();
// List of GestureEvent*. // List of GestureEvent*.
typedef ScopedVector<GestureEvent> Gestures; typedef ScopedVector<GestureEvent> Gestures;
...@@ -47,12 +46,10 @@ class EVENTS_EXPORT GestureRecognizer { ...@@ -47,12 +46,10 @@ class EVENTS_EXPORT GestureRecognizer {
virtual GestureConsumer* GetTargetForGestureEvent( virtual GestureConsumer* GetTargetForGestureEvent(
const GestureEvent& event) = 0; const GestureEvent& event) = 0;
// Returns the target of the nearest active touch with source device of // If there is an active touch within
// |source_device_id|, within // GestureConfiguration::max_separation_for_gesture_touches_in_pixels,
// GestureConfiguration::max_separation_for_gesture_touches_in_pixels of // of |location|, returns the target of the nearest active touch.
// |location|, or NULL if no such point exists. virtual GestureConsumer* GetTargetForLocation(const gfx::Point& location) = 0;
virtual GestureConsumer* GetTargetForLocation(
const gfx::Point& location, int source_device_id) = 0;
// Makes |new_consumer| the target for events previously targeting // Makes |new_consumer| the target for events previously targeting
// |current_consumer|. All other targets are canceled. // |current_consumer|. All other targets are canceled.
......
...@@ -78,17 +78,15 @@ GestureConsumer* GestureRecognizerImpl::GetTargetForGestureEvent( ...@@ -78,17 +78,15 @@ GestureConsumer* GestureRecognizerImpl::GetTargetForGestureEvent(
} }
GestureConsumer* GestureRecognizerImpl::GetTargetForLocation( GestureConsumer* GestureRecognizerImpl::GetTargetForLocation(
const gfx::Point& location, int source_device_id) { const gfx::Point& location) {
const GesturePoint* closest_point = NULL; const GesturePoint* closest_point = NULL;
int64 closest_distance_squared = 0; int64 closest_distance_squared = 0;
std::map<GestureConsumer*, GestureSequence*>::iterator i; std::map<GestureConsumer*, GestureSequence*>::iterator i;
for (i = consumer_sequence_.begin(); i != consumer_sequence_.end(); ++i) { for (i = consumer_sequence_.begin(); i != consumer_sequence_.end(); ++i) {
const GesturePoint* points = i->second->points(); const GesturePoint* points = i->second->points();
for (int j = 0; j < GestureSequence::kMaxGesturePoints; ++j) { for (int j = 0; j < GestureSequence::kMaxGesturePoints; ++j) {
if (!points[j].in_use() || if (!points[j].in_use())
source_device_id != points[j].source_device_id()) {
continue; continue;
}
gfx::Vector2d delta = points[j].last_touch_position() - location; gfx::Vector2d delta = points[j].last_touch_position() - location;
// Relative distance is all we need here, so LengthSquared() is // Relative distance is all we need here, so LengthSquared() is
// appropriate, and cheaper than Length(). // appropriate, and cheaper than Length().
...@@ -273,11 +271,6 @@ GestureRecognizer* GestureRecognizer::Get() { ...@@ -273,11 +271,6 @@ GestureRecognizer* GestureRecognizer::Get() {
return g_gesture_recognizer_instance; return g_gesture_recognizer_instance;
} }
// GestureRecognizer, static
void GestureRecognizer::Reset() {
g_gesture_recognizer_instance = NULL;
}
void SetGestureRecognizerForTesting(GestureRecognizer* gesture_recognizer) { void SetGestureRecognizerForTesting(GestureRecognizer* gesture_recognizer) {
// Transfer helpers to the new GR. // Transfer helpers to the new GR.
std::vector<GestureEventHelper*>& helpers = std::vector<GestureEventHelper*>& helpers =
......
...@@ -39,7 +39,7 @@ class EVENTS_EXPORT GestureRecognizerImpl : public GestureRecognizer, ...@@ -39,7 +39,7 @@ class EVENTS_EXPORT GestureRecognizerImpl : public GestureRecognizer,
virtual GestureConsumer* GetTargetForGestureEvent( virtual GestureConsumer* GetTargetForGestureEvent(
const GestureEvent& event) OVERRIDE; const GestureEvent& event) OVERRIDE;
virtual GestureConsumer* GetTargetForLocation( virtual GestureConsumer* GetTargetForLocation(
const gfx::Point& location, int source_device_id) OVERRIDE; const gfx::Point& location) OVERRIDE;
virtual void TransferEventsTo(GestureConsumer* current_consumer, virtual void TransferEventsTo(GestureConsumer* current_consumer,
GestureConsumer* new_consumer) OVERRIDE; GestureConsumer* new_consumer) OVERRIDE;
virtual bool GetLastTouchPointForTarget(GestureConsumer* consumer, virtual bool GetLastTouchPointForTarget(GestureConsumer* consumer,
......
...@@ -520,7 +520,6 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture( ...@@ -520,7 +520,6 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture(
} }
new_point->set_point_id(point_count_++); new_point->set_point_id(point_count_++);
new_point->set_touch_id(event.touch_id()); new_point->set_touch_id(event.touch_id());
new_point->set_source_device_id(event.source_device_id());
} }
GestureState last_state = state_; GestureState last_state = state_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment