| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_CONTRO
LLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_CONTRO
LLER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "ash/display/window_tree_host_manager.h" |
| 11 #include "base/time/time.h" |
| 12 #include "ui/display/display.h" |
| 13 #include "ui/display/manager/managed_display_info.h" |
| 14 #include "ui/events/event_handler.h" |
| 15 |
| 16 namespace ui { |
| 17 class KeyEvent; |
| 18 class TouchEvent; |
| 19 } |
| 20 |
| 21 namespace chromeos { |
| 22 |
| 23 class TouchCalibratorView; |
| 24 |
| 25 // TouchCalibratorController is responsible for collecting the touch calibration |
| 26 // associated data from the user. It instantiates TouchCalibratorView classes to |
| 27 // present an interface the user can interact with for calibration. |
| 28 // Touch calibration is restricted to calibrate only one display at a time. |
| 29 class TouchCalibratorController : public ui::EventHandler, |
| 30 public ash::WindowTreeHostManager::Observer { |
| 31 public: |
| 32 using CalibrationPointPairQuad = |
| 33 display::TouchCalibrationData::CalibrationPointPairQuad; |
| 34 |
| 35 static const base::TimeDelta kTouchIntervalThreshold; |
| 36 |
| 37 TouchCalibratorController(); |
| 38 ~TouchCalibratorController() override; |
| 39 |
| 40 // ui::EventHandler |
| 41 void OnKeyEvent(ui::KeyEvent* event) override; |
| 42 void OnTouchEvent(ui::TouchEvent* event) override; |
| 43 |
| 44 // WindowTreeHostManager::Observer |
| 45 void OnDisplayConfigurationChanged() override; |
| 46 |
| 47 // Starts the calibration process for the given |target_display|. |
| 48 void StartCalibration(const display::Display& target_display); |
| 49 |
| 50 // Stops any ongoing calibration process. |
| 51 void StopCalibration(); |
| 52 |
| 53 bool is_calibrating() { return is_calibrating_; } |
| 54 |
| 55 private: |
| 56 friend class TouchCalibratorControllerTest; |
| 57 FRIEND_TEST_ALL_PREFIXES(TouchCalibratorControllerTest, StartCalibration); |
| 58 FRIEND_TEST_ALL_PREFIXES(TouchCalibratorControllerTest, KeyEventIntercept); |
| 59 FRIEND_TEST_ALL_PREFIXES(TouchCalibratorControllerTest, TouchThreshold); |
| 60 |
| 61 // A map for TouchCalibrator view with the key as display id of the display |
| 62 // it is present in. |
| 63 std::map<int64_t, std::unique_ptr<TouchCalibratorView>> |
| 64 touch_calibrator_views_; |
| 65 |
| 66 // The display which is being calibrated by the touch calibrator controller. |
| 67 // This is valid only if |is_calibrating| is set to true. |
| 68 display::Display target_display_; |
| 69 |
| 70 // During calibration this stores the timestamp when the previous touch event |
| 71 // was received. |
| 72 base::Time last_touch_timestamp_; |
| 73 |
| 74 // Is true if a touch calibration is already underprocess. |
| 75 bool is_calibrating_ = false; |
| 76 |
| 77 // An array of Calibration point pairs. This stores all the 4 display and |
| 78 // touch input point pairs that will be used for calibration. |
| 79 CalibrationPointPairQuad touch_point_quad_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(TouchCalibratorController); |
| 82 }; |
| 83 |
| 84 } // namespace chromeos |
| 85 #endif // CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_CON
TROLLER_H_ |
| OLD | NEW |