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