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 #ifndef UI_EVENTS_EVENT_H_ | 5 #ifndef UI_EVENTS_EVENT_H_ |
6 #define UI_EVENTS_EVENT_H_ | 6 #define UI_EVENTS_EVENT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/event_types.h" | 10 #include "base/event_types.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // Returns true if the event has a valid |native_event_|. | 205 // Returns true if the event has a valid |native_event_|. |
206 bool HasNativeEvent() const; | 206 bool HasNativeEvent() const; |
207 | 207 |
208 // Immediately stops the propagation of the event. This must be called only | 208 // Immediately stops the propagation of the event. This must be called only |
209 // from an EventHandler during an event-dispatch. Any event handler that may | 209 // from an EventHandler during an event-dispatch. Any event handler that may |
210 // be in the list will not receive the event after this is called. | 210 // be in the list will not receive the event after this is called. |
211 // Note that StopPropagation() can be called only for cancelable events. | 211 // Note that StopPropagation() can be called only for cancelable events. |
212 void StopPropagation(); | 212 void StopPropagation(); |
213 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } | 213 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } |
214 | 214 |
215 | 215 // Marks the event as having been handled. A handled event does not reach the |
216 // next event phase. For example, if an event is handled during the pre-target | 216 // next event phase. For example, if an event is handled during the pre-target |
217 // phase, then the event is dispatched to all pre-target handlers, but not to | 217 // phase, then the event is dispatched to all pre-target handlers, but not to |
218 // the target or post-target handlers. | 218 // the target or post-target handlers. |
219 // Note that SetHandled() can be called only for cancelable events. | 219 // Note that SetHandled() can be called only for cancelable events. |
220 void SetHandled(); | 220 void SetHandled(); |
221 bool handled() const { return result_ != ER_UNHANDLED; } | 221 bool handled() const { return result_ != ER_UNHANDLED; } |
222 | 222 |
223 protected: | 223 protected: |
224 Event(EventType type, base::TimeDelta time_stamp, int flags); | 224 Event(EventType type, base::TimeDelta time_stamp, int flags); |
225 Event(const base::NativeEvent& native_event, EventType type, int flags); | 225 Event(const base::NativeEvent& native_event, EventType type, int flags); |
226 Event(const Event& copy); | 226 Event(const Event& copy); |
227 void SetType(EventType type); | 227 void SetType(EventType type); |
228 void set_delete_native_event(bool delete_native_event) { | |
229 delete_native_event_ = delete_native_event; | |
230 } | |
231 void set_cancelable(bool cancelable) { cancelable_ = cancelable; } | 228 void set_cancelable(bool cancelable) { cancelable_ = cancelable; } |
232 | 229 |
233 void set_time_stamp(const base::TimeDelta& time_stamp) { | 230 void set_time_stamp(const base::TimeDelta& time_stamp) { |
234 time_stamp_ = time_stamp; | 231 time_stamp_ = time_stamp; |
235 } | 232 } |
236 | 233 |
237 void set_name(const std::string& name) { name_ = name; } | 234 void set_name(const std::string& name) { name_ = name; } |
238 | 235 |
239 private: | 236 private: |
240 friend class EventTestApi; | 237 friend class EventTestApi; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 // converted from |source| coordinate system to |target| coordinate system. | 485 // converted from |source| coordinate system to |target| coordinate system. |
489 template <class T> | 486 template <class T> |
490 TouchEvent(const TouchEvent& model, T* source, T* target) | 487 TouchEvent(const TouchEvent& model, T* source, T* target) |
491 : LocatedEvent(model, source, target), | 488 : LocatedEvent(model, source, target), |
492 touch_id_(model.touch_id_), | 489 touch_id_(model.touch_id_), |
493 unique_event_id_(model.unique_event_id_), | 490 unique_event_id_(model.unique_event_id_), |
494 radius_x_(model.radius_x_), | 491 radius_x_(model.radius_x_), |
495 radius_y_(model.radius_y_), | 492 radius_y_(model.radius_y_), |
496 rotation_angle_(model.rotation_angle_), | 493 rotation_angle_(model.rotation_angle_), |
497 force_(model.force_), | 494 force_(model.force_), |
498 may_cause_scrolling_(model.may_cause_scrolling_) {} | 495 may_cause_scrolling_(model.may_cause_scrolling_), |
| 496 should_remove_native_touch_id_mapping_(false) {} |
499 | 497 |
500 TouchEvent(EventType type, | 498 TouchEvent(EventType type, |
501 const gfx::PointF& location, | 499 const gfx::PointF& location, |
502 int touch_id, | 500 int touch_id, |
503 base::TimeDelta time_stamp); | 501 base::TimeDelta time_stamp); |
504 | 502 |
505 TouchEvent(EventType type, | 503 TouchEvent(EventType type, |
506 const gfx::PointF& location, | 504 const gfx::PointF& location, |
507 int flags, | 505 int flags, |
508 int touch_id, | 506 int touch_id, |
(...skipping 16 matching lines...) Expand all Loading... |
525 float rotation_angle() const { return rotation_angle_; } | 523 float rotation_angle() const { return rotation_angle_; } |
526 float force() const { return force_; } | 524 float force() const { return force_; } |
527 | 525 |
528 void set_may_cause_scrolling(bool causes) { may_cause_scrolling_ = causes; } | 526 void set_may_cause_scrolling(bool causes) { may_cause_scrolling_ = causes; } |
529 bool may_cause_scrolling() const { return may_cause_scrolling_; } | 527 bool may_cause_scrolling() const { return may_cause_scrolling_; } |
530 | 528 |
531 // Used for unit tests. | 529 // Used for unit tests. |
532 void set_radius_x(const float r) { radius_x_ = r; } | 530 void set_radius_x(const float r) { radius_x_ = r; } |
533 void set_radius_y(const float r) { radius_y_ = r; } | 531 void set_radius_y(const float r) { radius_y_ = r; } |
534 | 532 |
| 533 void set_should_remove_native_touch_id_mapping( |
| 534 bool should_remove_native_touch_id_mapping) { |
| 535 should_remove_native_touch_id_mapping_ = |
| 536 should_remove_native_touch_id_mapping; |
| 537 } |
| 538 |
535 // Overridden from LocatedEvent. | 539 // Overridden from LocatedEvent. |
536 void UpdateForRootTransform( | 540 void UpdateForRootTransform( |
537 const gfx::Transform& inverted_root_transform) override; | 541 const gfx::Transform& inverted_root_transform) override; |
538 | 542 |
539 // Marks the event as not participating in synchronous gesture recognition. | 543 // Marks the event as not participating in synchronous gesture recognition. |
540 void DisableSynchronousHandling(); | 544 void DisableSynchronousHandling(); |
541 bool synchronous_handling_disabled() const { | 545 bool synchronous_handling_disabled() const { |
542 return !!(result() & ER_DISABLE_SYNC_HANDLING); | 546 return !!(result() & ER_DISABLE_SYNC_HANDLING); |
543 } | 547 } |
544 | 548 |
545 private: | 549 private: |
546 // Adjusts rotation_angle_ to within the acceptable range. | 550 // Adjusts rotation_angle_ to within the acceptable range. |
547 void fixRotationAngle(); | 551 void FixRotationAngle(); |
548 | 552 |
549 // The identity (typically finger) of the touch starting at 0 and incrementing | 553 // The identity (typically finger) of the touch starting at 0 and incrementing |
550 // for each separable additional touch that the hardware can detect. | 554 // for each separable additional touch that the hardware can detect. |
551 const int touch_id_; | 555 const int touch_id_; |
552 | 556 |
553 // A unique identifier for the touch event. | 557 // A unique identifier for the touch event. |
554 const uint64 unique_event_id_; | 558 const uint64 unique_event_id_; |
555 | 559 |
556 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. | 560 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. |
557 float radius_x_; | 561 float radius_x_; |
558 | 562 |
559 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. | 563 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. |
560 float radius_y_; | 564 float radius_y_; |
561 | 565 |
562 // Clockwise angle (in degrees) of the major axis from the X axis. Must be | 566 // Clockwise angle (in degrees) of the major axis from the X axis. Must be |
563 // less than 180 and non-negative. | 567 // less than 180 and non-negative. |
564 float rotation_angle_; | 568 float rotation_angle_; |
565 | 569 |
566 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. | 570 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. |
567 float force_; | 571 float force_; |
568 | 572 |
569 // Whether the (unhandled) touch event will produce a scroll event (e.g., a | 573 // Whether the (unhandled) touch event will produce a scroll event (e.g., a |
570 // touchmove that exceeds the platform slop region, or a touchend that | 574 // touchmove that exceeds the platform slop region, or a touchend that |
571 // causes a fling). Defaults to false. | 575 // causes a fling). Defaults to false. |
572 bool may_cause_scrolling_; | 576 bool may_cause_scrolling_; |
| 577 |
| 578 // True if this event should remove the mapping between the native |
| 579 // event id and the touch_id_. This should only be the case for |
| 580 // release and cancel events where the associated touch press event |
| 581 // created a mapping between the native id and the touch_id_. |
| 582 bool should_remove_native_touch_id_mapping_; |
573 }; | 583 }; |
574 | 584 |
575 // An interface that individual platforms can use to store additional data on | 585 // An interface that individual platforms can use to store additional data on |
576 // KeyEvent. | 586 // KeyEvent. |
577 // | 587 // |
578 // Currently only used in mojo. | 588 // Currently only used in mojo. |
579 class EVENTS_EXPORT ExtendedKeyEventData { | 589 class EVENTS_EXPORT ExtendedKeyEventData { |
580 public: | 590 public: |
581 virtual ~ExtendedKeyEventData() {} | 591 virtual ~ExtendedKeyEventData() {} |
582 | 592 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 | 875 |
866 const GestureEventDetails& details() const { return details_; } | 876 const GestureEventDetails& details() const { return details_; } |
867 | 877 |
868 private: | 878 private: |
869 GestureEventDetails details_; | 879 GestureEventDetails details_; |
870 }; | 880 }; |
871 | 881 |
872 } // namespace ui | 882 } // namespace ui |
873 | 883 |
874 #endif // UI_EVENTS_EVENT_H_ | 884 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |