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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 void set_flags(int flags) { flags_ = flags; } | 61 void set_flags(int flags) { flags_ = flags; } |
62 | 62 |
63 EventTarget* target() const { return target_; } | 63 EventTarget* target() const { return target_; } |
64 EventPhase phase() const { return phase_; } | 64 EventPhase phase() const { return phase_; } |
65 EventResult result() const { return result_; } | 65 EventResult result() const { return result_; } |
66 | 66 |
67 LatencyInfo* latency() { return &latency_; } | 67 LatencyInfo* latency() { return &latency_; } |
68 const LatencyInfo* latency() const { return &latency_; } | 68 const LatencyInfo* latency() const { return &latency_; } |
69 void set_latency(const LatencyInfo& latency) { latency_ = latency; } | 69 void set_latency(const LatencyInfo& latency) { latency_ = latency; } |
70 | 70 |
| 71 int source_device_id() const { return source_device_id_; } |
| 72 |
71 // By default, events are "cancelable", this means any default processing that | 73 // By default, events are "cancelable", this means any default processing that |
72 // the containing abstraction layer may perform can be prevented by calling | 74 // the containing abstraction layer may perform can be prevented by calling |
73 // SetHandled(). SetHandled() or StopPropagation() must not be called for | 75 // SetHandled(). SetHandled() or StopPropagation() must not be called for |
74 // events that are not cancelable. | 76 // events that are not cancelable. |
75 bool cancelable() const { return cancelable_; } | 77 bool cancelable() const { return cancelable_; } |
76 | 78 |
77 // The following methods return true if the respective keys were pressed at | 79 // The following methods return true if the respective keys were pressed at |
78 // the time the event was created. | 80 // the time the event was created. |
79 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } | 81 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } |
80 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } | 82 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 std::string name_; | 225 std::string name_; |
224 base::TimeDelta time_stamp_; | 226 base::TimeDelta time_stamp_; |
225 LatencyInfo latency_; | 227 LatencyInfo latency_; |
226 int flags_; | 228 int flags_; |
227 base::NativeEvent native_event_; | 229 base::NativeEvent native_event_; |
228 bool delete_native_event_; | 230 bool delete_native_event_; |
229 bool cancelable_; | 231 bool cancelable_; |
230 EventTarget* target_; | 232 EventTarget* target_; |
231 EventPhase phase_; | 233 EventPhase phase_; |
232 EventResult result_; | 234 EventResult result_; |
| 235 |
| 236 // The device id the event came from, or ED_UNKNOWN_DEVICE if the information |
| 237 // is not available. |
| 238 int source_device_id_; |
233 }; | 239 }; |
234 | 240 |
235 class EVENTS_EXPORT CancelModeEvent : public Event { | 241 class EVENTS_EXPORT CancelModeEvent : public Event { |
236 public: | 242 public: |
237 CancelModeEvent(); | 243 CancelModeEvent(); |
238 virtual ~CancelModeEvent(); | 244 virtual ~CancelModeEvent(); |
239 }; | 245 }; |
240 | 246 |
241 class EVENTS_EXPORT LocatedEvent : public Event { | 247 class EVENTS_EXPORT LocatedEvent : public Event { |
242 public: | 248 public: |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 | 387 |
382 // Set the click count for a mousedown message. Can be 1, 2 or 3. | 388 // Set the click count for a mousedown message. Can be 1, 2 or 3. |
383 void SetClickCount(int click_count); | 389 void SetClickCount(int click_count); |
384 | 390 |
385 // Identifies the button that changed. During a press this corresponds to the | 391 // Identifies the button that changed. During a press this corresponds to the |
386 // button that was pressed and during a release this corresponds to the button | 392 // button that was pressed and during a release this corresponds to the button |
387 // that was released. | 393 // that was released. |
388 // NOTE: during a press and release flags() contains the complete set of | 394 // NOTE: during a press and release flags() contains the complete set of |
389 // flags. Use this to determine the button that was pressed or released. | 395 // flags. Use this to determine the button that was pressed or released. |
390 int changed_button_flags() const { return changed_button_flags_; } | 396 int changed_button_flags() const { return changed_button_flags_; } |
| 397 void set_changed_button_flags(int flags) { changed_button_flags_ = flags; } |
391 | 398 |
392 private: | 399 private: |
393 // Returns the repeat count based on the previous mouse click, if it is | 400 // Returns the repeat count based on the previous mouse click, if it is |
394 // recent enough and within a small enough distance. | 401 // recent enough and within a small enough distance. |
395 static int GetRepeatCount(const MouseEvent& click_event); | 402 static int GetRepeatCount(const MouseEvent& click_event); |
396 | 403 |
397 // See description above getter for details. | 404 // See description above getter for details. |
398 int changed_button_flags_; | 405 int changed_button_flags_; |
399 | 406 |
400 static MouseEvent* last_click_event_; | 407 static MouseEvent* last_click_event_; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 // Create a new TouchEvent which is identical to the provided model. | 455 // Create a new TouchEvent which is identical to the provided model. |
449 // If source / target windows are provided, the model location will be | 456 // If source / target windows are provided, the model location will be |
450 // converted from |source| coordinate system to |target| coordinate system. | 457 // converted from |source| coordinate system to |target| coordinate system. |
451 template <class T> | 458 template <class T> |
452 TouchEvent(const TouchEvent& model, T* source, T* target) | 459 TouchEvent(const TouchEvent& model, T* source, T* target) |
453 : LocatedEvent(model, source, target), | 460 : LocatedEvent(model, source, target), |
454 touch_id_(model.touch_id_), | 461 touch_id_(model.touch_id_), |
455 radius_x_(model.radius_x_), | 462 radius_x_(model.radius_x_), |
456 radius_y_(model.radius_y_), | 463 radius_y_(model.radius_y_), |
457 rotation_angle_(model.rotation_angle_), | 464 rotation_angle_(model.rotation_angle_), |
458 force_(model.force_), | 465 force_(model.force_) { |
459 source_device_id_(model.source_device_id_) { | |
460 } | 466 } |
461 | 467 |
462 TouchEvent(EventType type, | 468 TouchEvent(EventType type, |
463 const gfx::PointF& location, | 469 const gfx::PointF& location, |
464 int touch_id, | 470 int touch_id, |
465 base::TimeDelta time_stamp); | 471 base::TimeDelta time_stamp); |
466 | 472 |
467 TouchEvent(EventType type, | 473 TouchEvent(EventType type, |
468 const gfx::PointF& location, | 474 const gfx::PointF& location, |
469 int flags, | 475 int flags, |
470 int touch_id, | 476 int touch_id, |
471 base::TimeDelta timestamp, | 477 base::TimeDelta timestamp, |
472 float radius_x, | 478 float radius_x, |
473 float radius_y, | 479 float radius_y, |
474 float angle, | 480 float angle, |
475 float force); | 481 float force); |
476 | 482 |
477 virtual ~TouchEvent(); | 483 virtual ~TouchEvent(); |
478 | 484 |
479 int touch_id() const { return touch_id_; } | 485 int touch_id() const { return touch_id_; } |
480 float radius_x() const { return radius_x_; } | 486 float radius_x() const { return radius_x_; } |
481 float radius_y() const { return radius_y_; } | 487 float radius_y() const { return radius_y_; } |
482 float rotation_angle() const { return rotation_angle_; } | 488 float rotation_angle() const { return rotation_angle_; } |
483 float force() const { return force_; } | 489 float force() const { return force_; } |
484 int source_device_id() const { return source_device_id_; } | |
485 | 490 |
486 // Used for unit tests. | 491 // Used for unit tests. |
487 void set_radius_x(const float r) { radius_x_ = r; } | 492 void set_radius_x(const float r) { radius_x_ = r; } |
488 void set_radius_y(const float r) { radius_y_ = r; } | 493 void set_radius_y(const float r) { radius_y_ = r; } |
489 void set_source_device_id(int source_device_id) { | |
490 source_device_id_ = source_device_id; | |
491 } | |
492 | 494 |
493 // Overridden from LocatedEvent. | 495 // Overridden from LocatedEvent. |
494 virtual void UpdateForRootTransform( | 496 virtual void UpdateForRootTransform( |
495 const gfx::Transform& inverted_root_transform) OVERRIDE; | 497 const gfx::Transform& inverted_root_transform) OVERRIDE; |
496 | 498 |
497 protected: | 499 protected: |
498 void set_radius(float radius_x, float radius_y) { | 500 void set_radius(float radius_x, float radius_y) { |
499 radius_x_ = radius_x; | 501 radius_x_ = radius_x; |
500 radius_y_ = radius_y; | 502 radius_y_ = radius_y; |
501 } | 503 } |
(...skipping 13 matching lines...) Expand all Loading... |
515 float radius_x_; | 517 float radius_x_; |
516 | 518 |
517 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. | 519 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. |
518 float radius_y_; | 520 float radius_y_; |
519 | 521 |
520 // Angle of the major axis away from the X axis. Default 0.0. | 522 // Angle of the major axis away from the X axis. Default 0.0. |
521 float rotation_angle_; | 523 float rotation_angle_; |
522 | 524 |
523 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. | 525 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. |
524 float force_; | 526 float force_; |
525 | |
526 // The device id of the screen the event came from. Default to be -1. | |
527 int source_device_id_; | |
528 }; | 527 }; |
529 | 528 |
530 class EVENTS_EXPORT KeyEvent : public Event { | 529 class EVENTS_EXPORT KeyEvent : public Event { |
531 public: | 530 public: |
532 KeyEvent(const base::NativeEvent& native_event, bool is_char); | 531 KeyEvent(const base::NativeEvent& native_event, bool is_char); |
533 | 532 |
534 // Used for synthetic events. | 533 // Used for synthetic events. |
535 KeyEvent(EventType type, KeyboardCode key_code, int flags, bool is_char); | 534 KeyEvent(EventType type, KeyboardCode key_code, int flags, bool is_char); |
536 | 535 |
537 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') | 536 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 // The set of indices of ones in the binary representation of | 691 // The set of indices of ones in the binary representation of |
693 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. | 692 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. |
694 // This value is stored as a bitfield because the number of touch ids varies, | 693 // This value is stored as a bitfield because the number of touch ids varies, |
695 // but we currently don't need more than 32 touches at a time. | 694 // but we currently don't need more than 32 touches at a time. |
696 const unsigned int touch_ids_bitfield_; | 695 const unsigned int touch_ids_bitfield_; |
697 }; | 696 }; |
698 | 697 |
699 } // namespace ui | 698 } // namespace ui |
700 | 699 |
701 #endif // UI_EVENTS_EVENT_H_ | 700 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |