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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 // Create a new TouchEvent which is identical to the provided model. | 430 // Create a new TouchEvent which is identical to the provided model. |
431 // If source / target windows are provided, the model location will be | 431 // If source / target windows are provided, the model location will be |
432 // converted from |source| coordinate system to |target| coordinate system. | 432 // converted from |source| coordinate system to |target| coordinate system. |
433 template <class T> | 433 template <class T> |
434 TouchEvent(const TouchEvent& model, T* source, T* target) | 434 TouchEvent(const TouchEvent& model, T* source, T* target) |
435 : LocatedEvent(model, source, target), | 435 : LocatedEvent(model, source, target), |
436 touch_id_(model.touch_id_), | 436 touch_id_(model.touch_id_), |
437 radius_x_(model.radius_x_), | 437 radius_x_(model.radius_x_), |
438 radius_y_(model.radius_y_), | 438 radius_y_(model.radius_y_), |
439 rotation_angle_(model.rotation_angle_), | 439 rotation_angle_(model.rotation_angle_), |
440 force_(model.force_) { | 440 force_(model.force_), |
| 441 source_device_id_(model.source_device_id_) { |
441 } | 442 } |
442 | 443 |
443 TouchEvent(EventType type, | 444 TouchEvent(EventType type, |
444 const gfx::Point& root_location, | 445 const gfx::Point& root_location, |
445 int touch_id, | 446 int touch_id, |
446 base::TimeDelta time_stamp); | 447 base::TimeDelta time_stamp); |
447 | 448 |
448 TouchEvent(EventType type, | 449 TouchEvent(EventType type, |
449 const gfx::Point& location, | 450 const gfx::Point& location, |
450 int flags, | 451 int flags, |
451 int touch_id, | 452 int touch_id, |
452 base::TimeDelta timestamp, | 453 base::TimeDelta timestamp, |
453 float radius_x, | 454 float radius_x, |
454 float radius_y, | 455 float radius_y, |
455 float angle, | 456 float angle, |
456 float force); | 457 float force); |
457 | 458 |
458 virtual ~TouchEvent(); | 459 virtual ~TouchEvent(); |
459 | 460 |
460 int touch_id() const { return touch_id_; } | 461 int touch_id() const { return touch_id_; } |
461 float radius_x() const { return radius_x_; } | 462 float radius_x() const { return radius_x_; } |
462 float radius_y() const { return radius_y_; } | 463 float radius_y() const { return radius_y_; } |
463 float rotation_angle() const { return rotation_angle_; } | 464 float rotation_angle() const { return rotation_angle_; } |
464 float force() const { return force_; } | 465 float force() const { return force_; } |
| 466 int source_device_id() const { return source_device_id_; } |
465 | 467 |
466 // Relocate the touch-point to a new |origin|. | 468 // Relocate the touch-point to a new |origin|. |
467 // This is useful when touch event is in X Root Window coordinates, | 469 // This is useful when touch event is in X Root Window coordinates, |
468 // and it needs to be mapped into Aura Root Window coordinates. | 470 // and it needs to be mapped into Aura Root Window coordinates. |
469 void Relocate(const gfx::Point& origin); | 471 void Relocate(const gfx::Point& origin); |
470 | 472 |
471 // Used for unit tests. | 473 // Used for unit tests. |
472 void set_radius_x(const float r) { radius_x_ = r; } | 474 void set_radius_x(const float r) { radius_x_ = r; } |
473 void set_radius_y(const float r) { radius_y_ = r; } | 475 void set_radius_y(const float r) { radius_y_ = r; } |
| 476 void set_source_device_id(int source_device_id) { |
| 477 source_device_id_ = source_device_id; |
| 478 } |
474 | 479 |
475 // Overridden from LocatedEvent. | 480 // Overridden from LocatedEvent. |
476 virtual void UpdateForRootTransform( | 481 virtual void UpdateForRootTransform( |
477 const gfx::Transform& inverted_root_transform) OVERRIDE; | 482 const gfx::Transform& inverted_root_transform) OVERRIDE; |
478 | 483 |
479 protected: | 484 protected: |
480 void set_radius(float radius_x, float radius_y) { | 485 void set_radius(float radius_x, float radius_y) { |
481 radius_x_ = radius_x; | 486 radius_x_ = radius_x; |
482 radius_y_ = radius_y; | 487 radius_y_ = radius_y; |
483 } | 488 } |
(...skipping 13 matching lines...) Expand all Loading... |
497 float radius_x_; | 502 float radius_x_; |
498 | 503 |
499 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. | 504 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. |
500 float radius_y_; | 505 float radius_y_; |
501 | 506 |
502 // Angle of the major axis away from the X axis. Default 0.0. | 507 // Angle of the major axis away from the X axis. Default 0.0. |
503 float rotation_angle_; | 508 float rotation_angle_; |
504 | 509 |
505 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. | 510 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. |
506 float force_; | 511 float force_; |
| 512 |
| 513 // The device id of the screen the event came from. Default to be -1. |
| 514 int source_device_id_; |
507 }; | 515 }; |
508 | 516 |
509 class EVENTS_EXPORT KeyEvent : public Event { | 517 class EVENTS_EXPORT KeyEvent : public Event { |
510 public: | 518 public: |
511 KeyEvent(const base::NativeEvent& native_event, bool is_char); | 519 KeyEvent(const base::NativeEvent& native_event, bool is_char); |
512 | 520 |
513 // Used for synthetic events. | 521 // Used for synthetic events. |
514 KeyEvent(EventType type, KeyboardCode key_code, int flags, bool is_char); | 522 KeyEvent(EventType type, KeyboardCode key_code, int flags, bool is_char); |
515 | 523 |
516 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') | 524 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 // The set of indices of ones in the binary representation of | 674 // The set of indices of ones in the binary representation of |
667 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. | 675 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. |
668 // This value is stored as a bitfield because the number of touch ids varies, | 676 // This value is stored as a bitfield because the number of touch ids varies, |
669 // but we currently don't need more than 32 touches at a time. | 677 // but we currently don't need more than 32 touches at a time. |
670 const unsigned int touch_ids_bitfield_; | 678 const unsigned int touch_ids_bitfield_; |
671 }; | 679 }; |
672 | 680 |
673 } // namespace ui | 681 } // namespace ui |
674 | 682 |
675 #endif // UI_EVENTS_EVENT_H_ | 683 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |