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

Unified Diff: ui/events/event.cc

Issue 2655303004: Add id properties to PointerEvent (Closed)
Patch Set: pointer id Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/event.cc
diff --git a/ui/events/event.cc b/ui/events/event.cc
index 879f3e1e96647fb0447e0012c00bbef6195d0401..310a71e1c722aefccdae29c0954b562027cb7ee5 100644
--- a/ui/events/event.cc
+++ b/ui/events/event.cc
@@ -501,6 +501,45 @@ void LocatedEvent::UpdateForRootTransform(
}
////////////////////////////////////////////////////////////////////////////////
+// PointerDetails
+
+PointerDetails::PointerDetails() {}
+
+PointerDetails::PointerDetails(EventPointerType pointer_type, uint32_t id)
+ : pointer_type(pointer_type),
+ force(std::numeric_limits<float>::quiet_NaN()),
+ id(id) {}
+
+PointerDetails::PointerDetails(EventPointerType pointer_type,
+ float radius_x,
+ float radius_y,
+ float force,
+ float tilt_x,
+ float tilt_y,
+ float tangential_pressure,
+ int twist,
+ uint32_t id)
+ : pointer_type(pointer_type),
+ // If we aren't provided with a radius on one axis, use the
+ // information from the other axis.
+ radius_x(radius_x > 0 ? radius_x : radius_y),
+ radius_y(radius_y > 0 ? radius_y : radius_x),
+ force(force),
+ tilt_x(tilt_x),
+ tilt_y(tilt_y),
+ tangential_pressure(tangential_pressure),
+ twist(twist),
+ id(id) {}
+
+PointerDetails::PointerDetails(EventPointerType pointer_type,
+ const gfx::Vector2d& offset)
+ : pointer_type(pointer_type),
+ force(std::numeric_limits<float>::quiet_NaN()),
+ offset(offset) {}
+
+PointerDetails::PointerDetails(const PointerDetails& other) = default;
+
+////////////////////////////////////////////////////////////////////////////////
// MouseEvent
MouseEvent::MouseEvent(const base::NativeEvent& native_event)
@@ -573,7 +612,8 @@ MouseEvent::MouseEvent(EventType type,
time_stamp,
flags),
changed_button_flags_(changed_button_flags),
- pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE)) {
+ pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_MOUSE,
+ PointerEvent::kMousePointerId)) {
DCHECK_NE(ET_MOUSEWHEEL, type);
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
if (this->type() == ET_MOUSE_MOVED && IsAnyButton())
@@ -766,7 +806,6 @@ const int MouseWheelEvent::kWheelDelta = 53;
TouchEvent::TouchEvent(const base::NativeEvent& native_event)
: LocatedEvent(native_event),
- touch_id_(GetTouchId(native_event)),
unique_event_id_(ui::GetNextTouchEventId()),
rotation_angle_(GetTouchAngle(native_event)),
may_cause_scrolling_(false),
@@ -784,7 +823,6 @@ TouchEvent::TouchEvent(const base::NativeEvent& native_event)
TouchEvent::TouchEvent(const PointerEvent& pointer_event)
: LocatedEvent(pointer_event),
- touch_id_(pointer_event.pointer_id()),
unique_event_id_(ui::GetNextTouchEventId()),
rotation_angle_(0.0f),
may_cause_scrolling_(false),
@@ -815,26 +853,26 @@ TouchEvent::TouchEvent(const PointerEvent& pointer_event)
TouchEvent::TouchEvent(EventType type,
const gfx::Point& location,
- int touch_id,
+ uint32_t touch_id,
base::TimeTicks time_stamp)
: LocatedEvent(type,
gfx::PointF(location),
gfx::PointF(location),
time_stamp,
0),
- touch_id_(touch_id),
unique_event_id_(ui::GetNextTouchEventId()),
rotation_angle_(0.0f),
may_cause_scrolling_(false),
should_remove_native_touch_id_mapping_(false),
- pointer_details_(PointerDetails(EventPointerType::POINTER_TYPE_TOUCH)) {
+ pointer_details_(
+ PointerDetails(EventPointerType::POINTER_TYPE_TOUCH, touch_id)) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
}
TouchEvent::TouchEvent(EventType type,
const gfx::Point& location,
int flags,
- int touch_id,
+ uint32_t touch_id,
base::TimeTicks time_stamp,
float radius_x,
float radius_y,
@@ -845,7 +883,6 @@ TouchEvent::TouchEvent(EventType type,
gfx::PointF(location),
time_stamp,
flags),
- touch_id_(touch_id),
unique_event_id_(ui::GetNextTouchEventId()),
rotation_angle_(angle),
may_cause_scrolling_(false),
@@ -855,14 +892,16 @@ TouchEvent::TouchEvent(EventType type,
radius_y,
force,
/* tilt_x */ 0.0f,
- /* tilt_y */ 0.0f)) {
+ /* tilt_y */ 0.0f,
+ /* tangential_pressure */ 0.0f,
+ /* twist */ 0,
+ touch_id)) {
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
FixRotationAngle();
}
TouchEvent::TouchEvent(const TouchEvent& copy)
: LocatedEvent(copy),
- touch_id_(copy.touch_id_),
unique_event_id_(copy.unique_event_id_),
rotation_angle_(copy.rotation_angle_),
may_cause_scrolling_(copy.may_cause_scrolling_),
@@ -934,7 +973,6 @@ bool PointerEvent::CanConvertFrom(const Event& event) {
PointerEvent::PointerEvent(const PointerEvent& pointer_event)
: LocatedEvent(pointer_event),
- pointer_id_(pointer_event.pointer_id()),
changed_button_flags_(pointer_event.changed_button_flags()),
details_(pointer_event.pointer_details()) {
if (details_.pointer_type == EventPointerType::POINTER_TYPE_TOUCH)
@@ -947,7 +985,6 @@ PointerEvent::PointerEvent(const PointerEvent& pointer_event)
PointerEvent::PointerEvent(const MouseEvent& mouse_event)
: LocatedEvent(mouse_event),
- pointer_id_(kMousePointerId),
changed_button_flags_(mouse_event.changed_button_flags()),
details_(mouse_event.pointer_details()) {
DCHECK(CanConvertFrom(mouse_event));
@@ -992,11 +1029,11 @@ PointerEvent::PointerEvent(const MouseEvent& mouse_event)
default:
NOTREACHED();
}
+ details_.id = static_cast<uint32_t>(kMousePointerId);
sadrul 2017/02/07 05:40:42 Should not be necessary?
lanwei 2017/02/10 20:54:38 Done.
}
PointerEvent::PointerEvent(const TouchEvent& touch_event)
: LocatedEvent(touch_event),
- pointer_id_(touch_event.touch_id()),
changed_button_flags_(0),
details_(touch_event.pointer_details()) {
DCHECK(CanConvertFrom(touch_event));
@@ -1027,7 +1064,7 @@ PointerEvent::PointerEvent(EventType type,
const gfx::Point& location,
const gfx::Point& root_location,
int flags,
- int pointer_id,
+ uint32_t pointer_id,
int changed_button_flags,
const PointerDetails& pointer_details,
base::TimeTicks time_stamp)
@@ -1036,9 +1073,9 @@ PointerEvent::PointerEvent(EventType type,
gfx::PointF(root_location),
time_stamp,
flags),
- pointer_id_(pointer_id),
changed_button_flags_(changed_button_flags),
details_(pointer_details) {
+ details_.id = pointer_id;
if (details_.pointer_type == EventPointerType::POINTER_TYPE_TOUCH)
latency()->set_source_event_type(ui::SourceEventType::TOUCH);
else if (type == ET_POINTER_WHEEL_CHANGED)
@@ -1047,7 +1084,8 @@ PointerEvent::PointerEvent(EventType type,
latency()->set_source_event_type(ui::SourceEventType::OTHER);
}
-const int PointerEvent::kMousePointerId = std::numeric_limits<int32_t>::max();
+const uint32_t PointerEvent::kMousePointerId =
+ std::numeric_limits<int32_t>::max();
sadrul 2017/02/07 05:40:42 uint32_t
lanwei 2017/02/10 20:54:38 Done.
////////////////////////////////////////////////////////////////////////////////
// KeyEvent

Powered by Google App Engine
This is Rietveld 408576698