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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 DispatcherApi(); | 70 DispatcherApi(); |
71 Event* event_; | 71 Event* event_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(DispatcherApi); | 73 DISALLOW_COPY_AND_ASSIGN(DispatcherApi); |
74 }; | 74 }; |
75 | 75 |
76 const base::NativeEvent& native_event() const { return native_event_; } | 76 const base::NativeEvent& native_event() const { return native_event_; } |
77 EventType type() const { return type_; } | 77 EventType type() const { return type_; } |
78 const std::string& name() const { return name_; } | 78 const std::string& name() const { return name_; } |
79 // time_stamp represents time since machine was booted. | 79 // time_stamp represents time since machine was booted. |
80 const base::TimeDelta& time_stamp() const { return time_stamp_; } | 80 const base::TimeTicks time_stamp() const { return time_stamp_; } |
81 int flags() const { return flags_; } | 81 int flags() const { return flags_; } |
82 | 82 |
83 // This is only intended to be used externally by classes that are modifying | 83 // This is only intended to be used externally by classes that are modifying |
84 // events in an EventRewriter. | 84 // events in an EventRewriter. |
85 void set_flags(int flags) { flags_ = flags; } | 85 void set_flags(int flags) { flags_ = flags; } |
86 | 86 |
87 EventTarget* target() const { return target_; } | 87 EventTarget* target() const { return target_; } |
88 EventPhase phase() const { return phase_; } | 88 EventPhase phase() const { return phase_; } |
89 EventResult result() const { return result_; } | 89 EventResult result() const { return result_; } |
90 | 90 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 // Marks the event as having been handled. A handled event does not reach the | 276 // Marks the event as having been handled. A handled event does not reach the |
277 // next event phase. For example, if an event is handled during the pre-target | 277 // next event phase. For example, if an event is handled during the pre-target |
278 // phase, then the event is dispatched to all pre-target handlers, but not to | 278 // phase, then the event is dispatched to all pre-target handlers, but not to |
279 // the target or post-target handlers. | 279 // the target or post-target handlers. |
280 // Note that SetHandled() can be called only for cancelable events. | 280 // Note that SetHandled() can be called only for cancelable events. |
281 void SetHandled(); | 281 void SetHandled(); |
282 bool handled() const { return result_ != ER_UNHANDLED; } | 282 bool handled() const { return result_ != ER_UNHANDLED; } |
283 | 283 |
284 protected: | 284 protected: |
285 Event(EventType type, base::TimeDelta time_stamp, int flags); | 285 Event(EventType type, base::TimeTicks time_stamp, int flags); |
286 Event(const base::NativeEvent& native_event, EventType type, int flags); | 286 Event(const base::NativeEvent& native_event, EventType type, int flags); |
287 Event(const Event& copy); | 287 Event(const Event& copy); |
288 void SetType(EventType type); | 288 void SetType(EventType type); |
289 void set_cancelable(bool cancelable) { cancelable_ = cancelable; } | 289 void set_cancelable(bool cancelable) { cancelable_ = cancelable; } |
290 | 290 |
291 void set_time_stamp(const base::TimeDelta& time_stamp) { | 291 void set_time_stamp(base::TimeTicks time_stamp) { |
292 time_stamp_ = time_stamp; | 292 time_stamp_ = time_stamp; |
293 } | 293 } |
294 | 294 |
295 void set_name(const std::string& name) { name_ = name; } | 295 void set_name(const std::string& name) { name_ = name; } |
296 | 296 |
297 private: | 297 private: |
298 friend class EventTestApi; | 298 friend class EventTestApi; |
299 | 299 |
300 // For (de)serialization. | 300 // For (de)serialization. |
301 friend struct IPC::ParamTraits<ui::ScopedEvent>; | 301 friend struct IPC::ParamTraits<ui::ScopedEvent>; |
302 | 302 |
303 EventType type_; | 303 EventType type_; |
304 std::string name_; | 304 std::string name_; |
305 base::TimeDelta time_stamp_; | 305 base::TimeTicks time_stamp_; |
306 LatencyInfo latency_; | 306 LatencyInfo latency_; |
307 int flags_; | 307 int flags_; |
308 base::NativeEvent native_event_; | 308 base::NativeEvent native_event_; |
309 bool delete_native_event_; | 309 bool delete_native_event_; |
310 bool cancelable_; | 310 bool cancelable_; |
311 EventTarget* target_; | 311 EventTarget* target_; |
312 EventPhase phase_; | 312 EventPhase phase_; |
313 EventResult result_; | 313 EventResult result_; |
314 | 314 |
315 // The device id the event came from, or ED_UNKNOWN_DEVICE if the information | 315 // The device id the event came from, or ED_UNKNOWN_DEVICE if the information |
316 // is not available. | 316 // is not available. |
317 int source_device_id_; | 317 int source_device_id_; |
318 }; | 318 }; |
319 | 319 |
320 class EVENTS_EXPORT CancelModeEvent : public Event { | 320 class EVENTS_EXPORT CancelModeEvent : public Event { |
321 public: | 321 public: |
322 CancelModeEvent(); | 322 CancelModeEvent(); |
323 ~CancelModeEvent() override; | 323 ~CancelModeEvent() override; |
324 | 324 |
325 private: | 325 private: |
326 // For (de)serialization. | 326 // For (de)serialization. |
327 CancelModeEvent(EventType type, base::TimeDelta time_stamp, int flags) | 327 CancelModeEvent(EventType type, base::TimeTicks time_stamp, int flags) |
328 : Event(type, time_stamp, flags) {} | 328 : Event(type, time_stamp, flags) {} |
329 friend struct IPC::ParamTraits<ui::ScopedEvent>; | 329 friend struct IPC::ParamTraits<ui::ScopedEvent>; |
330 friend struct IPC::ParamTraits<ui::CancelModeEvent>; | 330 friend struct IPC::ParamTraits<ui::CancelModeEvent>; |
331 }; | 331 }; |
332 | 332 |
333 class EVENTS_EXPORT LocatedEvent : public Event { | 333 class EVENTS_EXPORT LocatedEvent : public Event { |
334 public: | 334 public: |
335 ~LocatedEvent() override; | 335 ~LocatedEvent() override; |
336 | 336 |
337 float x() const { return location_.x(); } | 337 float x() const { return location_.x(); } |
(...skipping 28 matching lines...) Expand all Loading... |
366 gfx::Point offset = gfx::ToFlooredPoint(location_); | 366 gfx::Point offset = gfx::ToFlooredPoint(location_); |
367 T::ConvertPointToTarget(source, target, &offset); | 367 T::ConvertPointToTarget(source, target, &offset); |
368 gfx::Vector2d diff = gfx::ToFlooredPoint(location_) - offset; | 368 gfx::Vector2d diff = gfx::ToFlooredPoint(location_) - offset; |
369 location_= location_ - diff; | 369 location_= location_ - diff; |
370 } | 370 } |
371 | 371 |
372 protected: | 372 protected: |
373 friend class LocatedEventTestApi; | 373 friend class LocatedEventTestApi; |
374 | 374 |
375 // For (de)serialization. | 375 // For (de)serialization. |
376 LocatedEvent(EventType type, base::TimeDelta time_stamp, int flags) | 376 LocatedEvent(EventType type, base::TimeTicks time_stamp, int flags) |
377 : Event(type, time_stamp, flags) {} | 377 : Event(type, time_stamp, flags) {} |
378 friend struct IPC::ParamTraits<ui::ScopedEvent>; | 378 friend struct IPC::ParamTraits<ui::ScopedEvent>; |
379 friend struct IPC::ParamTraits<ui::LocatedEvent>; | 379 friend struct IPC::ParamTraits<ui::LocatedEvent>; |
380 | 380 |
381 explicit LocatedEvent(const base::NativeEvent& native_event); | 381 explicit LocatedEvent(const base::NativeEvent& native_event); |
382 | 382 |
383 // Create a new LocatedEvent which is identical to the provided model. | 383 // Create a new LocatedEvent which is identical to the provided model. |
384 // If source / target windows are provided, the model location will be | 384 // If source / target windows are provided, the model location will be |
385 // converted from |source| coordinate system to |target| coordinate system. | 385 // converted from |source| coordinate system to |target| coordinate system. |
386 template <class T> | 386 template <class T> |
387 LocatedEvent(const LocatedEvent& model, T* source, T* target) | 387 LocatedEvent(const LocatedEvent& model, T* source, T* target) |
388 : Event(model), | 388 : Event(model), |
389 location_(model.location_), | 389 location_(model.location_), |
390 root_location_(model.root_location_) { | 390 root_location_(model.root_location_) { |
391 ConvertLocationToTarget(source, target); | 391 ConvertLocationToTarget(source, target); |
392 } | 392 } |
393 | 393 |
394 // Used for synthetic events in testing. | 394 // Used for synthetic events in testing. |
395 LocatedEvent(EventType type, | 395 LocatedEvent(EventType type, |
396 const gfx::PointF& location, | 396 const gfx::PointF& location, |
397 const gfx::PointF& root_location, | 397 const gfx::PointF& root_location, |
398 base::TimeDelta time_stamp, | 398 base::TimeTicks time_stamp, |
399 int flags); | 399 int flags); |
400 | 400 |
401 gfx::PointF location_; | 401 gfx::PointF location_; |
402 | 402 |
403 // |location_| multiplied by an optional transformation matrix for | 403 // |location_| multiplied by an optional transformation matrix for |
404 // rotations, animations and skews. | 404 // rotations, animations and skews. |
405 gfx::PointF root_location_; | 405 gfx::PointF root_location_; |
406 }; | 406 }; |
407 | 407 |
408 // Structure for handling common fields between touch and mouse to support | 408 // Structure for handling common fields between touch and mouse to support |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 changed_button_flags_(model.changed_button_flags_), | 485 changed_button_flags_(model.changed_button_flags_), |
486 pointer_details_(model.pointer_details_) { | 486 pointer_details_(model.pointer_details_) { |
487 SetType(type); | 487 SetType(type); |
488 set_flags(flags); | 488 set_flags(flags); |
489 } | 489 } |
490 | 490 |
491 // Used for synthetic events in testing, gesture recognizer and Ozone | 491 // Used for synthetic events in testing, gesture recognizer and Ozone |
492 MouseEvent(EventType type, | 492 MouseEvent(EventType type, |
493 const gfx::Point& location, | 493 const gfx::Point& location, |
494 const gfx::Point& root_location, | 494 const gfx::Point& root_location, |
495 base::TimeDelta time_stamp, | 495 base::TimeTicks time_stamp, |
496 int flags, | 496 int flags, |
497 int changed_button_flags); | 497 int changed_button_flags); |
498 | 498 |
499 // Conveniences to quickly test what button is down | 499 // Conveniences to quickly test what button is down |
500 bool IsOnlyLeftMouseButton() const { | 500 bool IsOnlyLeftMouseButton() const { |
501 return button_flags() == EF_LEFT_MOUSE_BUTTON; | 501 return button_flags() == EF_LEFT_MOUSE_BUTTON; |
502 } | 502 } |
503 | 503 |
504 bool IsLeftMouseButton() const { | 504 bool IsLeftMouseButton() const { |
505 return (flags() & EF_LEFT_MOUSE_BUTTON) != 0; | 505 return (flags() & EF_LEFT_MOUSE_BUTTON) != 0; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; } | 555 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; } |
556 | 556 |
557 // Event details common to MouseEvent and TouchEvent. | 557 // Event details common to MouseEvent and TouchEvent. |
558 const PointerDetails& pointer_details() const { return pointer_details_; } | 558 const PointerDetails& pointer_details() const { return pointer_details_; } |
559 void set_pointer_details(const PointerDetails& details) { | 559 void set_pointer_details(const PointerDetails& details) { |
560 pointer_details_ = details; | 560 pointer_details_ = details; |
561 } | 561 } |
562 | 562 |
563 protected: | 563 protected: |
564 // For (de)serialization. | 564 // For (de)serialization. |
565 MouseEvent(EventType type, base::TimeDelta time_stamp, int flags) | 565 MouseEvent(EventType type, base::TimeTicks time_stamp, int flags) |
566 : LocatedEvent(type, time_stamp, flags) {} | 566 : LocatedEvent(type, time_stamp, flags) {} |
567 friend struct IPC::ParamTraits<ui::ScopedEvent>; | 567 friend struct IPC::ParamTraits<ui::ScopedEvent>; |
568 friend struct IPC::ParamTraits<ui::MouseEvent>; | 568 friend struct IPC::ParamTraits<ui::MouseEvent>; |
569 | 569 |
570 private: | 570 private: |
571 FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease); | 571 FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease); |
572 FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft); | 572 FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft); |
573 | 573 |
574 // Returns the repeat count based on the previous mouse click, if it is | 574 // Returns the repeat count based on the previous mouse click, if it is |
575 // recent enough and within a small enough distance. | 575 // recent enough and within a small enough distance. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 T* source, | 609 T* source, |
610 T* target) | 610 T* target) |
611 : MouseEvent(model, source, target, model.type(), model.flags()), | 611 : MouseEvent(model, source, target, model.type(), model.flags()), |
612 offset_(model.x_offset(), model.y_offset()) { | 612 offset_(model.x_offset(), model.y_offset()) { |
613 } | 613 } |
614 | 614 |
615 // Used for synthetic events in testing and by the gesture recognizer. | 615 // Used for synthetic events in testing and by the gesture recognizer. |
616 MouseWheelEvent(const gfx::Vector2d& offset, | 616 MouseWheelEvent(const gfx::Vector2d& offset, |
617 const gfx::Point& location, | 617 const gfx::Point& location, |
618 const gfx::Point& root_location, | 618 const gfx::Point& root_location, |
619 base::TimeDelta time_stamp, | 619 base::TimeTicks time_stamp, |
620 int flags, | 620 int flags, |
621 int changed_button_flags); | 621 int changed_button_flags); |
622 | 622 |
623 // The amount to scroll. This is in multiples of kWheelDelta. | 623 // The amount to scroll. This is in multiples of kWheelDelta. |
624 // Note: x_offset() > 0/y_offset() > 0 means scroll left/up. | 624 // Note: x_offset() > 0/y_offset() > 0 means scroll left/up. |
625 int x_offset() const { return offset_.x(); } | 625 int x_offset() const { return offset_.x(); } |
626 int y_offset() const { return offset_.y(); } | 626 int y_offset() const { return offset_.y(); } |
627 const gfx::Vector2d& offset() const { return offset_; } | 627 const gfx::Vector2d& offset() const { return offset_; } |
628 | 628 |
629 private: | 629 private: |
630 // For (de)serialization. | 630 // For (de)serialization. |
631 MouseWheelEvent(EventType type, base::TimeDelta time_stamp, int flags) | 631 MouseWheelEvent(EventType type, base::TimeTicks time_stamp, int flags) |
632 : MouseEvent(type, time_stamp, flags) {} | 632 : MouseEvent(type, time_stamp, flags) {} |
633 friend struct IPC::ParamTraits<ui::ScopedEvent>; | 633 friend struct IPC::ParamTraits<ui::ScopedEvent>; |
634 friend struct IPC::ParamTraits<ui::MouseWheelEvent>; | 634 friend struct IPC::ParamTraits<ui::MouseWheelEvent>; |
635 | 635 |
636 gfx::Vector2d offset_; | 636 gfx::Vector2d offset_; |
637 }; | 637 }; |
638 | 638 |
639 class EVENTS_EXPORT TouchEvent : public LocatedEvent { | 639 class EVENTS_EXPORT TouchEvent : public LocatedEvent { |
640 public: | 640 public: |
641 explicit TouchEvent(const base::NativeEvent& native_event); | 641 explicit TouchEvent(const base::NativeEvent& native_event); |
642 | 642 |
643 // Create a new TouchEvent which is identical to the provided model. | 643 // Create a new TouchEvent which is identical to the provided model. |
644 // If source / target windows are provided, the model location will be | 644 // If source / target windows are provided, the model location will be |
645 // converted from |source| coordinate system to |target| coordinate system. | 645 // converted from |source| coordinate system to |target| coordinate system. |
646 template <class T> | 646 template <class T> |
647 TouchEvent(const TouchEvent& model, T* source, T* target) | 647 TouchEvent(const TouchEvent& model, T* source, T* target) |
648 : LocatedEvent(model, source, target), | 648 : LocatedEvent(model, source, target), |
649 touch_id_(model.touch_id_), | 649 touch_id_(model.touch_id_), |
650 unique_event_id_(model.unique_event_id_), | 650 unique_event_id_(model.unique_event_id_), |
651 rotation_angle_(model.rotation_angle_), | 651 rotation_angle_(model.rotation_angle_), |
652 may_cause_scrolling_(model.may_cause_scrolling_), | 652 may_cause_scrolling_(model.may_cause_scrolling_), |
653 should_remove_native_touch_id_mapping_(false), | 653 should_remove_native_touch_id_mapping_(false), |
654 pointer_details_(model.pointer_details_) {} | 654 pointer_details_(model.pointer_details_) {} |
655 | 655 |
656 TouchEvent(EventType type, | 656 TouchEvent(EventType type, |
657 const gfx::Point& location, | 657 const gfx::Point& location, |
658 int touch_id, | 658 int touch_id, |
659 base::TimeDelta time_stamp); | 659 base::TimeTicks time_stamp); |
660 | 660 |
661 TouchEvent(EventType type, | 661 TouchEvent(EventType type, |
662 const gfx::Point& location, | 662 const gfx::Point& location, |
663 int flags, | 663 int flags, |
664 int touch_id, | 664 int touch_id, |
665 base::TimeDelta timestamp, | 665 base::TimeTicks timestamp, |
666 float radius_x, | 666 float radius_x, |
667 float radius_y, | 667 float radius_y, |
668 float angle, | 668 float angle, |
669 float force); | 669 float force); |
670 | 670 |
671 TouchEvent(const TouchEvent& copy); | 671 TouchEvent(const TouchEvent& copy); |
672 | 672 |
673 ~TouchEvent() override; | 673 ~TouchEvent() override; |
674 | 674 |
675 // The id of the pointer this event modifies. | 675 // The id of the pointer this event modifies. |
(...skipping 23 matching lines...) Expand all Loading... |
699 } | 699 } |
700 | 700 |
701 // Event details common to MouseEvent and TouchEvent. | 701 // Event details common to MouseEvent and TouchEvent. |
702 const PointerDetails& pointer_details() const { return pointer_details_; } | 702 const PointerDetails& pointer_details() const { return pointer_details_; } |
703 void set_pointer_details(const PointerDetails& pointer_details) { | 703 void set_pointer_details(const PointerDetails& pointer_details) { |
704 pointer_details_ = pointer_details; | 704 pointer_details_ = pointer_details; |
705 } | 705 } |
706 | 706 |
707 private: | 707 private: |
708 // For (de)serialization. | 708 // For (de)serialization. |
709 TouchEvent(EventType type, base::TimeDelta time_stamp, int flags) | 709 TouchEvent(EventType type, base::TimeTicks time_stamp, int flags) |
710 : LocatedEvent(type, time_stamp, flags), | 710 : LocatedEvent(type, time_stamp, flags), |
711 should_remove_native_touch_id_mapping_(false) {} | 711 should_remove_native_touch_id_mapping_(false) {} |
712 friend struct IPC::ParamTraits<ui::ScopedEvent>; | 712 friend struct IPC::ParamTraits<ui::ScopedEvent>; |
713 friend struct IPC::ParamTraits<ui::TouchEvent>; | 713 friend struct IPC::ParamTraits<ui::TouchEvent>; |
714 | 714 |
715 // Adjusts rotation_angle_ to within the acceptable range. | 715 // Adjusts rotation_angle_ to within the acceptable range. |
716 void FixRotationAngle(); | 716 void FixRotationAngle(); |
717 | 717 |
718 // The identity (typically finger) of the touch starting at 0 and incrementing | 718 // The identity (typically finger) of the touch starting at 0 and incrementing |
719 // for each separable additional touch that the hardware can detect. | 719 // for each separable additional touch that the hardware can detect. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 PointerEvent(const PointerEvent& pointer_event); | 753 PointerEvent(const PointerEvent& pointer_event); |
754 explicit PointerEvent(const MouseEvent& mouse_event); | 754 explicit PointerEvent(const MouseEvent& mouse_event); |
755 explicit PointerEvent(const TouchEvent& touch_event); | 755 explicit PointerEvent(const TouchEvent& touch_event); |
756 | 756 |
757 PointerEvent(EventType type, | 757 PointerEvent(EventType type, |
758 EventPointerType pointer_type, | 758 EventPointerType pointer_type, |
759 const gfx::Point& location, | 759 const gfx::Point& location, |
760 const gfx::Point& root_location, | 760 const gfx::Point& root_location, |
761 int flags, | 761 int flags, |
762 int pointer_id, | 762 int pointer_id, |
763 base::TimeDelta time_stamp); | 763 base::TimeTicks time_stamp); |
764 | 764 |
765 int32_t pointer_id() const { return pointer_id_; } | 765 int32_t pointer_id() const { return pointer_id_; } |
766 const PointerDetails& pointer_details() const { return details_; } | 766 const PointerDetails& pointer_details() const { return details_; } |
767 | 767 |
768 protected: | 768 protected: |
769 // For (de)serialization. | 769 // For (de)serialization. |
770 PointerEvent(EventType type, base::TimeDelta time_stamp, int flags) | 770 PointerEvent(EventType type, base::TimeTicks time_stamp, int flags) |
771 : LocatedEvent(type, time_stamp, flags) {} | 771 : LocatedEvent(type, time_stamp, flags) {} |
772 friend struct IPC::ParamTraits<ui::ScopedEvent>; | 772 friend struct IPC::ParamTraits<ui::ScopedEvent>; |
773 friend struct IPC::ParamTraits<ui::PointerEvent>; | 773 friend struct IPC::ParamTraits<ui::PointerEvent>; |
774 | 774 |
775 private: | 775 private: |
776 int32_t pointer_id_; | 776 int32_t pointer_id_; |
777 PointerDetails details_; | 777 PointerDetails details_; |
778 }; | 778 }; |
779 | 779 |
780 // An interface that individual platforms can use to store additional data on | 780 // 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... |
836 // Create a keystroke event from a legacy KeyboardCode. | 836 // Create a keystroke event from a legacy KeyboardCode. |
837 // This should not be used in new code. | 837 // This should not be used in new code. |
838 KeyEvent(EventType type, KeyboardCode key_code, int flags); | 838 KeyEvent(EventType type, KeyboardCode key_code, int flags); |
839 | 839 |
840 // Create a fully defined keystroke event. | 840 // Create a fully defined keystroke event. |
841 KeyEvent(EventType type, | 841 KeyEvent(EventType type, |
842 KeyboardCode key_code, | 842 KeyboardCode key_code, |
843 DomCode code, | 843 DomCode code, |
844 int flags, | 844 int flags, |
845 DomKey key, | 845 DomKey key, |
846 base::TimeDelta time_stamp); | 846 base::TimeTicks time_stamp); |
847 | 847 |
848 // Create a character event. | 848 // Create a character event. |
849 KeyEvent(base::char16 character, KeyboardCode key_code, int flags); | 849 KeyEvent(base::char16 character, KeyboardCode key_code, int flags); |
850 | 850 |
851 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') | 851 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') |
852 // See also: ui/events/keycodes/dom/dom_values.txt | 852 // See also: ui/events/keycodes/dom/dom_values.txt |
853 KeyEvent(EventType type, | 853 KeyEvent(EventType type, |
854 KeyboardCode key_code, | 854 KeyboardCode key_code, |
855 DomCode code, | 855 DomCode code, |
856 int flags); | 856 int flags); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 void NormalizeFlags(); | 936 void NormalizeFlags(); |
937 | 937 |
938 protected: | 938 protected: |
939 friend class KeyEventTestApi; | 939 friend class KeyEventTestApi; |
940 | 940 |
941 // This allows a subclass TranslatedKeyEvent to be a non character event. | 941 // This allows a subclass TranslatedKeyEvent to be a non character event. |
942 void set_is_char(bool is_char) { is_char_ = is_char; } | 942 void set_is_char(bool is_char) { is_char_ = is_char; } |
943 | 943 |
944 private: | 944 private: |
945 // For (de)serialization. | 945 // For (de)serialization. |
946 KeyEvent(EventType type, base::TimeDelta time_stamp, int flags); | 946 KeyEvent(EventType type, base::TimeTicks time_stamp, int flags); |
947 friend struct IPC::ParamTraits<ui::ScopedEvent>; | 947 friend struct IPC::ParamTraits<ui::ScopedEvent>; |
948 friend struct IPC::ParamTraits<ui::KeyEvent>; | 948 friend struct IPC::ParamTraits<ui::KeyEvent>; |
949 | 949 |
950 // Determine key_ on a keystroke event from code_ and flags(). | 950 // Determine key_ on a keystroke event from code_ and flags(). |
951 void ApplyLayout() const; | 951 void ApplyLayout() const; |
952 | 952 |
953 KeyboardCode key_code_; | 953 KeyboardCode key_code_; |
954 | 954 |
955 // DOM KeyboardEvent |code| (e.g. DomCode::US_A, DomCode::SPACE). | 955 // DOM KeyboardEvent |code| (e.g. DomCode::US_A, DomCode::SPACE). |
956 // http://www.w3.org/TR/DOM-Level-3-Events-code/ | 956 // http://www.w3.org/TR/DOM-Level-3-Events-code/ |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 x_offset_(model.x_offset_), | 998 x_offset_(model.x_offset_), |
999 y_offset_(model.y_offset_), | 999 y_offset_(model.y_offset_), |
1000 x_offset_ordinal_(model.x_offset_ordinal_), | 1000 x_offset_ordinal_(model.x_offset_ordinal_), |
1001 y_offset_ordinal_(model.y_offset_ordinal_), | 1001 y_offset_ordinal_(model.y_offset_ordinal_), |
1002 finger_count_(model.finger_count_){ | 1002 finger_count_(model.finger_count_){ |
1003 } | 1003 } |
1004 | 1004 |
1005 // Used for tests. | 1005 // Used for tests. |
1006 ScrollEvent(EventType type, | 1006 ScrollEvent(EventType type, |
1007 const gfx::Point& location, | 1007 const gfx::Point& location, |
1008 base::TimeDelta time_stamp, | 1008 base::TimeTicks time_stamp, |
1009 int flags, | 1009 int flags, |
1010 float x_offset, | 1010 float x_offset, |
1011 float y_offset, | 1011 float y_offset, |
1012 float x_offset_ordinal, | 1012 float x_offset_ordinal, |
1013 float y_offset_ordinal, | 1013 float y_offset_ordinal, |
1014 int finger_count); | 1014 int finger_count); |
1015 | 1015 |
1016 // Scale the scroll event's offset value. | 1016 // Scale the scroll event's offset value. |
1017 // This is useful in the multi-monitor setup where it needs to be scaled | 1017 // This is useful in the multi-monitor setup where it needs to be scaled |
1018 // to provide a consistent user experience. | 1018 // to provide a consistent user experience. |
1019 void Scale(const float factor); | 1019 void Scale(const float factor); |
1020 | 1020 |
1021 float x_offset() const { return x_offset_; } | 1021 float x_offset() const { return x_offset_; } |
1022 float y_offset() const { return y_offset_; } | 1022 float y_offset() const { return y_offset_; } |
1023 float x_offset_ordinal() const { return x_offset_ordinal_; } | 1023 float x_offset_ordinal() const { return x_offset_ordinal_; } |
1024 float y_offset_ordinal() const { return y_offset_ordinal_; } | 1024 float y_offset_ordinal() const { return y_offset_ordinal_; } |
1025 int finger_count() const { return finger_count_; } | 1025 int finger_count() const { return finger_count_; } |
1026 | 1026 |
1027 private: | 1027 private: |
1028 // For (de)serialization. | 1028 // For (de)serialization. |
1029 ScrollEvent(EventType type, base::TimeDelta time_stamp, int flags) | 1029 ScrollEvent(EventType type, base::TimeTicks time_stamp, int flags) |
1030 : MouseEvent(type, time_stamp, flags) {} | 1030 : MouseEvent(type, time_stamp, flags) {} |
1031 friend struct IPC::ParamTraits<ui::ScopedEvent>; | 1031 friend struct IPC::ParamTraits<ui::ScopedEvent>; |
1032 friend struct IPC::ParamTraits<ui::ScrollEvent>; | 1032 friend struct IPC::ParamTraits<ui::ScrollEvent>; |
1033 | 1033 |
1034 // Potential accelerated offsets. | 1034 // Potential accelerated offsets. |
1035 float x_offset_; | 1035 float x_offset_; |
1036 float y_offset_; | 1036 float y_offset_; |
1037 // Unaccelerated offsets. | 1037 // Unaccelerated offsets. |
1038 float x_offset_ordinal_; | 1038 float x_offset_ordinal_; |
1039 float y_offset_ordinal_; | 1039 float y_offset_ordinal_; |
1040 // Number of fingers on the pad. | 1040 // Number of fingers on the pad. |
1041 int finger_count_; | 1041 int finger_count_; |
1042 }; | 1042 }; |
1043 | 1043 |
1044 class EVENTS_EXPORT GestureEvent : public LocatedEvent { | 1044 class EVENTS_EXPORT GestureEvent : public LocatedEvent { |
1045 public: | 1045 public: |
1046 GestureEvent(float x, | 1046 GestureEvent(float x, |
1047 float y, | 1047 float y, |
1048 int flags, | 1048 int flags, |
1049 base::TimeDelta time_stamp, | 1049 base::TimeTicks time_stamp, |
1050 const GestureEventDetails& details); | 1050 const GestureEventDetails& details); |
1051 | 1051 |
1052 // Create a new GestureEvent which is identical to the provided model. | 1052 // Create a new GestureEvent which is identical to the provided model. |
1053 // If source / target windows are provided, the model location will be | 1053 // If source / target windows are provided, the model location will be |
1054 // converted from |source| coordinate system to |target| coordinate system. | 1054 // converted from |source| coordinate system to |target| coordinate system. |
1055 template <typename T> | 1055 template <typename T> |
1056 GestureEvent(const GestureEvent& model, T* source, T* target) | 1056 GestureEvent(const GestureEvent& model, T* source, T* target) |
1057 : LocatedEvent(model, source, target), | 1057 : LocatedEvent(model, source, target), |
1058 details_(model.details_) { | 1058 details_(model.details_) { |
1059 } | 1059 } |
1060 | 1060 |
1061 ~GestureEvent() override; | 1061 ~GestureEvent() override; |
1062 | 1062 |
1063 const GestureEventDetails& details() const { return details_; } | 1063 const GestureEventDetails& details() const { return details_; } |
1064 | 1064 |
1065 private: | 1065 private: |
1066 // For (de)serialization. | 1066 // For (de)serialization. |
1067 GestureEvent(EventType type, base::TimeDelta time_stamp, int flags) | 1067 GestureEvent(EventType type, base::TimeTicks time_stamp, int flags) |
1068 : LocatedEvent(type, time_stamp, flags) {} | 1068 : LocatedEvent(type, time_stamp, flags) {} |
1069 friend struct IPC::ParamTraits<ui::ScopedEvent>; | 1069 friend struct IPC::ParamTraits<ui::ScopedEvent>; |
1070 friend struct IPC::ParamTraits<ui::GestureEvent>; | 1070 friend struct IPC::ParamTraits<ui::GestureEvent>; |
1071 | 1071 |
1072 GestureEventDetails details_; | 1072 GestureEventDetails details_; |
1073 }; | 1073 }; |
1074 | 1074 |
1075 } // namespace ui | 1075 } // namespace ui |
1076 | 1076 |
1077 #endif // UI_EVENTS_EVENT_H_ | 1077 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |