| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 DispatcherApi(); | 66 DispatcherApi(); |
| 67 Event* event_; | 67 Event* event_; |
| 68 | 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(DispatcherApi); | 69 DISALLOW_COPY_AND_ASSIGN(DispatcherApi); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 const base::NativeEvent& native_event() const { return native_event_; } | 72 const base::NativeEvent& native_event() const { return native_event_; } |
| 73 EventType type() const { return type_; } | 73 EventType type() const { return type_; } |
| 74 const std::string& name() const { return name_; } | 74 const std::string& name() const { return name_; } |
| 75 // time_stamp represents time since machine was booted. | 75 // time_stamp represents time since machine was booted. |
| 76 const base::TimeDelta& time_stamp() const { return time_stamp_; } | 76 const base::TimeTicks time_stamp() const { return time_stamp_; } |
| 77 int flags() const { return flags_; } | 77 int flags() const { return flags_; } |
| 78 | 78 |
| 79 // This is only intended to be used externally by classes that are modifying | 79 // This is only intended to be used externally by classes that are modifying |
| 80 // events in an EventRewriter. | 80 // events in an EventRewriter. |
| 81 void set_flags(int flags) { flags_ = flags; } | 81 void set_flags(int flags) { flags_ = flags; } |
| 82 | 82 |
| 83 EventTarget* target() const { return target_; } | 83 EventTarget* target() const { return target_; } |
| 84 EventPhase phase() const { return phase_; } | 84 EventPhase phase() const { return phase_; } |
| 85 EventResult result() const { return result_; } | 85 EventResult result() const { return result_; } |
| 86 | 86 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 // Marks the event as having been handled. A handled event does not reach the | 272 // Marks the event as having been handled. A handled event does not reach the |
| 273 // next event phase. For example, if an event is handled during the pre-target | 273 // next event phase. For example, if an event is handled during the pre-target |
| 274 // phase, then the event is dispatched to all pre-target handlers, but not to | 274 // phase, then the event is dispatched to all pre-target handlers, but not to |
| 275 // the target or post-target handlers. | 275 // the target or post-target handlers. |
| 276 // Note that SetHandled() can be called only for cancelable events. | 276 // Note that SetHandled() can be called only for cancelable events. |
| 277 void SetHandled(); | 277 void SetHandled(); |
| 278 bool handled() const { return result_ != ER_UNHANDLED; } | 278 bool handled() const { return result_ != ER_UNHANDLED; } |
| 279 | 279 |
| 280 protected: | 280 protected: |
| 281 Event(EventType type, base::TimeDelta time_stamp, int flags); | 281 Event(EventType type, base::TimeTicks time_stamp, int flags); |
| 282 Event(const base::NativeEvent& native_event, EventType type, int flags); | 282 Event(const base::NativeEvent& native_event, EventType type, int flags); |
| 283 Event(const Event& copy); | 283 Event(const Event& copy); |
| 284 void SetType(EventType type); | 284 void SetType(EventType type); |
| 285 void set_cancelable(bool cancelable) { cancelable_ = cancelable; } | 285 void set_cancelable(bool cancelable) { cancelable_ = cancelable; } |
| 286 | 286 |
| 287 void set_time_stamp(const base::TimeDelta& time_stamp) { | 287 void set_time_stamp(base::TimeTicks time_stamp) { |
| 288 time_stamp_ = time_stamp; | 288 time_stamp_ = time_stamp; |
| 289 } | 289 } |
| 290 | 290 |
| 291 void set_name(const std::string& name) { name_ = name; } | 291 void set_name(const std::string& name) { name_ = name; } |
| 292 | 292 |
| 293 private: | 293 private: |
| 294 friend class EventTestApi; | 294 friend class EventTestApi; |
| 295 | 295 |
| 296 EventType type_; | 296 EventType type_; |
| 297 std::string name_; | 297 std::string name_; |
| 298 base::TimeDelta time_stamp_; | 298 base::TimeTicks time_stamp_; |
| 299 LatencyInfo latency_; | 299 LatencyInfo latency_; |
| 300 int flags_; | 300 int flags_; |
| 301 base::NativeEvent native_event_; | 301 base::NativeEvent native_event_; |
| 302 bool delete_native_event_; | 302 bool delete_native_event_; |
| 303 bool cancelable_; | 303 bool cancelable_; |
| 304 EventTarget* target_; | 304 EventTarget* target_; |
| 305 EventPhase phase_; | 305 EventPhase phase_; |
| 306 EventResult result_; | 306 EventResult result_; |
| 307 | 307 |
| 308 // The device id the event came from, or ED_UNKNOWN_DEVICE if the information | 308 // The device id the event came from, or ED_UNKNOWN_DEVICE if the information |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 : Event(model), | 368 : Event(model), |
| 369 location_(model.location_), | 369 location_(model.location_), |
| 370 root_location_(model.root_location_) { | 370 root_location_(model.root_location_) { |
| 371 ConvertLocationToTarget(source, target); | 371 ConvertLocationToTarget(source, target); |
| 372 } | 372 } |
| 373 | 373 |
| 374 // Used for synthetic events in testing. | 374 // Used for synthetic events in testing. |
| 375 LocatedEvent(EventType type, | 375 LocatedEvent(EventType type, |
| 376 const gfx::PointF& location, | 376 const gfx::PointF& location, |
| 377 const gfx::PointF& root_location, | 377 const gfx::PointF& root_location, |
| 378 base::TimeDelta time_stamp, | 378 base::TimeTicks time_stamp, |
| 379 int flags); | 379 int flags); |
| 380 | 380 |
| 381 gfx::PointF location_; | 381 gfx::PointF location_; |
| 382 | 382 |
| 383 // |location_| multiplied by an optional transformation matrix for | 383 // |location_| multiplied by an optional transformation matrix for |
| 384 // rotations, animations and skews. | 384 // rotations, animations and skews. |
| 385 gfx::PointF root_location_; | 385 gfx::PointF root_location_; |
| 386 }; | 386 }; |
| 387 | 387 |
| 388 // Structure for handling common fields between touch and mouse to support | 388 // Structure for handling common fields between touch and mouse to support |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 changed_button_flags_(model.changed_button_flags_), | 465 changed_button_flags_(model.changed_button_flags_), |
| 466 pointer_details_(model.pointer_details_) { | 466 pointer_details_(model.pointer_details_) { |
| 467 SetType(type); | 467 SetType(type); |
| 468 set_flags(flags); | 468 set_flags(flags); |
| 469 } | 469 } |
| 470 | 470 |
| 471 // Used for synthetic events in testing, gesture recognizer and Ozone | 471 // Used for synthetic events in testing, gesture recognizer and Ozone |
| 472 MouseEvent(EventType type, | 472 MouseEvent(EventType type, |
| 473 const gfx::Point& location, | 473 const gfx::Point& location, |
| 474 const gfx::Point& root_location, | 474 const gfx::Point& root_location, |
| 475 base::TimeDelta time_stamp, | 475 base::TimeTicks time_stamp, |
| 476 int flags, | 476 int flags, |
| 477 int changed_button_flags); | 477 int changed_button_flags); |
| 478 | 478 |
| 479 // Conveniences to quickly test what button is down | 479 // Conveniences to quickly test what button is down |
| 480 bool IsOnlyLeftMouseButton() const { | 480 bool IsOnlyLeftMouseButton() const { |
| 481 return button_flags() == EF_LEFT_MOUSE_BUTTON; | 481 return button_flags() == EF_LEFT_MOUSE_BUTTON; |
| 482 } | 482 } |
| 483 | 483 |
| 484 bool IsLeftMouseButton() const { | 484 bool IsLeftMouseButton() const { |
| 485 return (flags() & EF_LEFT_MOUSE_BUTTON) != 0; | 485 return (flags() & EF_LEFT_MOUSE_BUTTON) != 0; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 T* source, | 582 T* source, |
| 583 T* target) | 583 T* target) |
| 584 : MouseEvent(model, source, target, model.type(), model.flags()), | 584 : MouseEvent(model, source, target, model.type(), model.flags()), |
| 585 offset_(model.x_offset(), model.y_offset()) { | 585 offset_(model.x_offset(), model.y_offset()) { |
| 586 } | 586 } |
| 587 | 587 |
| 588 // Used for synthetic events in testing and by the gesture recognizer. | 588 // Used for synthetic events in testing and by the gesture recognizer. |
| 589 MouseWheelEvent(const gfx::Vector2d& offset, | 589 MouseWheelEvent(const gfx::Vector2d& offset, |
| 590 const gfx::Point& location, | 590 const gfx::Point& location, |
| 591 const gfx::Point& root_location, | 591 const gfx::Point& root_location, |
| 592 base::TimeDelta time_stamp, | 592 base::TimeTicks time_stamp, |
| 593 int flags, | 593 int flags, |
| 594 int changed_button_flags); | 594 int changed_button_flags); |
| 595 | 595 |
| 596 // The amount to scroll. This is in multiples of kWheelDelta. | 596 // The amount to scroll. This is in multiples of kWheelDelta. |
| 597 // Note: x_offset() > 0/y_offset() > 0 means scroll left/up. | 597 // Note: x_offset() > 0/y_offset() > 0 means scroll left/up. |
| 598 int x_offset() const { return offset_.x(); } | 598 int x_offset() const { return offset_.x(); } |
| 599 int y_offset() const { return offset_.y(); } | 599 int y_offset() const { return offset_.y(); } |
| 600 const gfx::Vector2d& offset() const { return offset_; } | 600 const gfx::Vector2d& offset() const { return offset_; } |
| 601 | 601 |
| 602 private: | 602 private: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 619 touch_id_(model.touch_id_), | 619 touch_id_(model.touch_id_), |
| 620 unique_event_id_(model.unique_event_id_), | 620 unique_event_id_(model.unique_event_id_), |
| 621 rotation_angle_(model.rotation_angle_), | 621 rotation_angle_(model.rotation_angle_), |
| 622 may_cause_scrolling_(model.may_cause_scrolling_), | 622 may_cause_scrolling_(model.may_cause_scrolling_), |
| 623 should_remove_native_touch_id_mapping_(false), | 623 should_remove_native_touch_id_mapping_(false), |
| 624 pointer_details_(model.pointer_details_) {} | 624 pointer_details_(model.pointer_details_) {} |
| 625 | 625 |
| 626 TouchEvent(EventType type, | 626 TouchEvent(EventType type, |
| 627 const gfx::Point& location, | 627 const gfx::Point& location, |
| 628 int touch_id, | 628 int touch_id, |
| 629 base::TimeDelta time_stamp); | 629 base::TimeTicks time_stamp); |
| 630 | 630 |
| 631 TouchEvent(EventType type, | 631 TouchEvent(EventType type, |
| 632 const gfx::Point& location, | 632 const gfx::Point& location, |
| 633 int flags, | 633 int flags, |
| 634 int touch_id, | 634 int touch_id, |
| 635 base::TimeDelta timestamp, | 635 base::TimeTicks timestamp, |
| 636 float radius_x, | 636 float radius_x, |
| 637 float radius_y, | 637 float radius_y, |
| 638 float angle, | 638 float angle, |
| 639 float force); | 639 float force); |
| 640 | 640 |
| 641 TouchEvent(const TouchEvent& copy); | 641 TouchEvent(const TouchEvent& copy); |
| 642 | 642 |
| 643 ~TouchEvent() override; | 643 ~TouchEvent() override; |
| 644 | 644 |
| 645 // The id of the pointer this event modifies. | 645 // The id of the pointer this event modifies. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 PointerEvent(const PointerEvent& pointer_event); | 716 PointerEvent(const PointerEvent& pointer_event); |
| 717 explicit PointerEvent(const MouseEvent& mouse_event); | 717 explicit PointerEvent(const MouseEvent& mouse_event); |
| 718 explicit PointerEvent(const TouchEvent& touch_event); | 718 explicit PointerEvent(const TouchEvent& touch_event); |
| 719 | 719 |
| 720 PointerEvent(EventType type, | 720 PointerEvent(EventType type, |
| 721 const gfx::Point& location, | 721 const gfx::Point& location, |
| 722 const gfx::Point& root_location, | 722 const gfx::Point& root_location, |
| 723 int flags, | 723 int flags, |
| 724 int pointer_id, | 724 int pointer_id, |
| 725 const PointerDetails& pointer_details, | 725 const PointerDetails& pointer_details, |
| 726 base::TimeDelta time_stamp); | 726 base::TimeTicks time_stamp); |
| 727 | 727 |
| 728 int32_t pointer_id() const { return pointer_id_; } | 728 int32_t pointer_id() const { return pointer_id_; } |
| 729 const PointerDetails& pointer_details() const { return details_; } | 729 const PointerDetails& pointer_details() const { return details_; } |
| 730 | 730 |
| 731 private: | 731 private: |
| 732 int32_t pointer_id_; | 732 int32_t pointer_id_; |
| 733 PointerDetails details_; | 733 PointerDetails details_; |
| 734 }; | 734 }; |
| 735 | 735 |
| 736 // An interface that individual platforms can use to store additional data on | 736 // An interface that individual platforms can use to store additional data on |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 // Create a keystroke event from a legacy KeyboardCode. | 792 // Create a keystroke event from a legacy KeyboardCode. |
| 793 // This should not be used in new code. | 793 // This should not be used in new code. |
| 794 KeyEvent(EventType type, KeyboardCode key_code, int flags); | 794 KeyEvent(EventType type, KeyboardCode key_code, int flags); |
| 795 | 795 |
| 796 // Create a fully defined keystroke event. | 796 // Create a fully defined keystroke event. |
| 797 KeyEvent(EventType type, | 797 KeyEvent(EventType type, |
| 798 KeyboardCode key_code, | 798 KeyboardCode key_code, |
| 799 DomCode code, | 799 DomCode code, |
| 800 int flags, | 800 int flags, |
| 801 DomKey key, | 801 DomKey key, |
| 802 base::TimeDelta time_stamp); | 802 base::TimeTicks time_stamp); |
| 803 | 803 |
| 804 // Create a character event. | 804 // Create a character event. |
| 805 KeyEvent(base::char16 character, KeyboardCode key_code, int flags); | 805 KeyEvent(base::char16 character, KeyboardCode key_code, int flags); |
| 806 | 806 |
| 807 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') | 807 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') |
| 808 // See also: ui/events/keycodes/dom/dom_values.txt | 808 // See also: ui/events/keycodes/dom/dom_values.txt |
| 809 KeyEvent(EventType type, | 809 KeyEvent(EventType type, |
| 810 KeyboardCode key_code, | 810 KeyboardCode key_code, |
| 811 DomCode code, | 811 DomCode code, |
| 812 int flags); | 812 int flags); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 x_offset_(model.x_offset_), | 949 x_offset_(model.x_offset_), |
| 950 y_offset_(model.y_offset_), | 950 y_offset_(model.y_offset_), |
| 951 x_offset_ordinal_(model.x_offset_ordinal_), | 951 x_offset_ordinal_(model.x_offset_ordinal_), |
| 952 y_offset_ordinal_(model.y_offset_ordinal_), | 952 y_offset_ordinal_(model.y_offset_ordinal_), |
| 953 finger_count_(model.finger_count_){ | 953 finger_count_(model.finger_count_){ |
| 954 } | 954 } |
| 955 | 955 |
| 956 // Used for tests. | 956 // Used for tests. |
| 957 ScrollEvent(EventType type, | 957 ScrollEvent(EventType type, |
| 958 const gfx::Point& location, | 958 const gfx::Point& location, |
| 959 base::TimeDelta time_stamp, | 959 base::TimeTicks time_stamp, |
| 960 int flags, | 960 int flags, |
| 961 float x_offset, | 961 float x_offset, |
| 962 float y_offset, | 962 float y_offset, |
| 963 float x_offset_ordinal, | 963 float x_offset_ordinal, |
| 964 float y_offset_ordinal, | 964 float y_offset_ordinal, |
| 965 int finger_count); | 965 int finger_count); |
| 966 | 966 |
| 967 // Scale the scroll event's offset value. | 967 // Scale the scroll event's offset value. |
| 968 // This is useful in the multi-monitor setup where it needs to be scaled | 968 // This is useful in the multi-monitor setup where it needs to be scaled |
| 969 // to provide a consistent user experience. | 969 // to provide a consistent user experience. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 984 float y_offset_ordinal_; | 984 float y_offset_ordinal_; |
| 985 // Number of fingers on the pad. | 985 // Number of fingers on the pad. |
| 986 int finger_count_; | 986 int finger_count_; |
| 987 }; | 987 }; |
| 988 | 988 |
| 989 class EVENTS_EXPORT GestureEvent : public LocatedEvent { | 989 class EVENTS_EXPORT GestureEvent : public LocatedEvent { |
| 990 public: | 990 public: |
| 991 GestureEvent(float x, | 991 GestureEvent(float x, |
| 992 float y, | 992 float y, |
| 993 int flags, | 993 int flags, |
| 994 base::TimeDelta time_stamp, | 994 base::TimeTicks time_stamp, |
| 995 const GestureEventDetails& details); | 995 const GestureEventDetails& details); |
| 996 | 996 |
| 997 // Create a new GestureEvent which is identical to the provided model. | 997 // Create a new GestureEvent which is identical to the provided model. |
| 998 // If source / target windows are provided, the model location will be | 998 // If source / target windows are provided, the model location will be |
| 999 // converted from |source| coordinate system to |target| coordinate system. | 999 // converted from |source| coordinate system to |target| coordinate system. |
| 1000 template <typename T> | 1000 template <typename T> |
| 1001 GestureEvent(const GestureEvent& model, T* source, T* target) | 1001 GestureEvent(const GestureEvent& model, T* source, T* target) |
| 1002 : LocatedEvent(model, source, target), | 1002 : LocatedEvent(model, source, target), |
| 1003 details_(model.details_) { | 1003 details_(model.details_) { |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 ~GestureEvent() override; | 1006 ~GestureEvent() override; |
| 1007 | 1007 |
| 1008 const GestureEventDetails& details() const { return details_; } | 1008 const GestureEventDetails& details() const { return details_; } |
| 1009 | 1009 |
| 1010 private: | 1010 private: |
| 1011 GestureEventDetails details_; | 1011 GestureEventDetails details_; |
| 1012 }; | 1012 }; |
| 1013 | 1013 |
| 1014 } // namespace ui | 1014 } // namespace ui |
| 1015 | 1015 |
| 1016 #endif // UI_EVENTS_EVENT_H_ | 1016 #endif // UI_EVENTS_EVENT_H_ |
| OLD | NEW |