Chromium Code Reviews| 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_BASE_EVENTS_EVENT_H_ | 5 #ifndef UI_BASE_EVENTS_EVENT_H_ |
| 6 #define UI_BASE_EVENTS_EVENT_H_ | 6 #define UI_BASE_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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/singleton.h" | |
| 12 #include "base/time.h" | 13 #include "base/time.h" |
| 13 #include "ui/base/dragdrop/os_exchange_data.h" | 14 #include "ui/base/dragdrop/os_exchange_data.h" |
| 14 #include "ui/base/events/event_constants.h" | 15 #include "ui/base/events/event_constants.h" |
| 15 #include "ui/base/gestures/gesture_types.h" | 16 #include "ui/base/gestures/gesture_types.h" |
| 16 #include "ui/base/keycodes/keyboard_codes.h" | 17 #include "ui/base/keycodes/keyboard_codes.h" |
| 17 #include "ui/base/ui_export.h" | 18 #include "ui/base/ui_export.h" |
| 18 #include "ui/gfx/point.h" | 19 #include "ui/gfx/point.h" |
| 19 | 20 |
| 20 namespace gfx { | 21 namespace gfx { |
| 21 class Transform; | 22 class Transform; |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 // The amount to scroll. This is in multiples of kWheelDelta. | 438 // The amount to scroll. This is in multiples of kWheelDelta. |
| 438 // Note: offset() > 0 means scroll up / left. | 439 // Note: offset() > 0 means scroll up / left. |
| 439 int offset() const { return offset_; } | 440 int offset() const { return offset_; } |
| 440 | 441 |
| 441 private: | 442 private: |
| 442 int offset_; | 443 int offset_; |
| 443 | 444 |
| 444 DISALLOW_COPY_AND_ASSIGN(MouseWheelEvent); | 445 DISALLOW_COPY_AND_ASSIGN(MouseWheelEvent); |
| 445 }; | 446 }; |
| 446 | 447 |
| 448 #if defined(USE_XI2_MT) | |
| 449 // A singleton, which reads touch event calibration parameters | |
| 450 // from the command line once - in constructor. | |
| 451 // These parameters are then used in Calibrate() to compensate | |
| 452 // for the bezels on the internal touchscreen. | |
| 453 class TouchCoordinatesCalibrator { | |
|
Ben Goodger (Google)
2013/03/15 03:36:35
can this and the calibrate function below move to
ynovikov
2013/03/15 18:34:33
Technically, they can, but I fail to see the advan
| |
| 454 public: | |
| 455 static TouchCoordinatesCalibrator* GetInstance(); | |
| 456 // Modify the location of the |event|, | |
| 457 // expanding it from |bounds| to (|bounds| + bezels). | |
| 458 // Required when touchscreen is bigger than screen (i.e. has bezels), | |
| 459 // because we receive events in touchscreen coordinates, | |
| 460 // which need to be expanded when converting to screen coordinates, | |
| 461 // so that location on bezels will be outside of screen area. | |
| 462 void Calibrate(TouchEvent* event, const gfx::Rect& bounds); | |
| 463 private: | |
| 464 TouchCoordinatesCalibrator(); | |
| 465 friend struct DefaultSingletonTraits<TouchCoordinatesCalibrator>; | |
| 466 | |
| 467 // The calibration values for the four border sides. | |
| 468 int left_; | |
| 469 int right_; | |
| 470 int top_; | |
| 471 int bottom_; | |
| 472 | |
| 473 DISALLOW_COPY_AND_ASSIGN(TouchCoordinatesCalibrator); | |
| 474 }; | |
| 475 #endif // defined(USE_XI2_MT) | |
| 476 | |
| 447 class UI_EXPORT TouchEvent : public LocatedEvent { | 477 class UI_EXPORT TouchEvent : public LocatedEvent { |
| 448 public: | 478 public: |
| 449 explicit TouchEvent(const base::NativeEvent& native_event); | 479 explicit TouchEvent(const base::NativeEvent& native_event); |
| 450 | 480 |
| 451 // Create a new TouchEvent which is identical to the provided model. | 481 // Create a new TouchEvent which is identical to the provided model. |
| 452 // If source / target windows are provided, the model location will be | 482 // If source / target windows are provided, the model location will be |
| 453 // converted from |source| coordinate system to |target| coordinate system. | 483 // converted from |source| coordinate system to |target| coordinate system. |
| 454 template <class T> | 484 template <class T> |
| 455 TouchEvent(const TouchEvent& model, T* source, T* target) | 485 TouchEvent(const TouchEvent& model, T* source, T* target) |
| 456 : LocatedEvent(model, source, target), | 486 : LocatedEvent(model, source, target), |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 482 float radius_x() const { return radius_x_; } | 512 float radius_x() const { return radius_x_; } |
| 483 float radius_y() const { return radius_y_; } | 513 float radius_y() const { return radius_y_; } |
| 484 float rotation_angle() const { return rotation_angle_; } | 514 float rotation_angle() const { return rotation_angle_; } |
| 485 float force() const { return force_; } | 515 float force() const { return force_; } |
| 486 | 516 |
| 487 // Relocate the touch-point to a new |origin|. | 517 // Relocate the touch-point to a new |origin|. |
| 488 // This is useful when touch event is in X Root Window coordinates, | 518 // This is useful when touch event is in X Root Window coordinates, |
| 489 // and it needs to be mapped into Aura Root Window coordinates. | 519 // and it needs to be mapped into Aura Root Window coordinates. |
| 490 void Relocate(const gfx::Point& origin); | 520 void Relocate(const gfx::Point& origin); |
| 491 | 521 |
| 522 #if defined(USE_XI2_MT) | |
| 523 // Apply bezels calibration, given |bounds| screen size, | |
| 524 // and bezel sizes previously read from command line. | |
| 525 void Calibrate(const gfx::Rect& bounds); | |
| 526 #endif // defined(USE_XI2_MT) | |
| 527 | |
| 492 // Used for unit tests. | 528 // Used for unit tests. |
| 493 void set_radius_x(const float r) { radius_x_ = r; } | 529 void set_radius_x(const float r) { radius_x_ = r; } |
| 494 void set_radius_y(const float r) { radius_y_ = r; } | 530 void set_radius_y(const float r) { radius_y_ = r; } |
| 495 | 531 |
| 496 // Overridden from LocatedEvent. | 532 // Overridden from LocatedEvent. |
| 497 virtual void UpdateForRootTransform( | 533 virtual void UpdateForRootTransform( |
| 498 const gfx::Transform& root_transform) OVERRIDE; | 534 const gfx::Transform& root_transform) OVERRIDE; |
| 499 | 535 |
| 500 protected: | 536 protected: |
| 501 void set_radius(float radius_x, float radius_y) { | 537 void set_radius(float radius_x, float radius_y) { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 // This value is stored as a bitfield because the number of touch ids varies, | 746 // This value is stored as a bitfield because the number of touch ids varies, |
| 711 // but we currently don't need more than 32 touches at a time. | 747 // but we currently don't need more than 32 touches at a time. |
| 712 const unsigned int touch_ids_bitfield_; | 748 const unsigned int touch_ids_bitfield_; |
| 713 | 749 |
| 714 DISALLOW_COPY_AND_ASSIGN(GestureEvent); | 750 DISALLOW_COPY_AND_ASSIGN(GestureEvent); |
| 715 }; | 751 }; |
| 716 | 752 |
| 717 } // namespace ui | 753 } // namespace ui |
| 718 | 754 |
| 719 #endif // UI_BASE_EVENTS_EVENT_H_ | 755 #endif // UI_BASE_EVENTS_EVENT_H_ |
| OLD | NEW |