OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 5 #ifndef UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
6 #define UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 6 #define UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/time/tick_clock.h" | 9 #include "base/time/tick_clock.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 aura::Window* root_window, | 172 aura::Window* root_window, |
173 ui::TouchExplorationControllerDelegate* delegate); | 173 ui::TouchExplorationControllerDelegate* delegate); |
174 ~TouchExplorationController() override; | 174 ~TouchExplorationController() override; |
175 | 175 |
176 private: | 176 private: |
177 friend class TouchExplorationControllerTestApi; | 177 friend class TouchExplorationControllerTestApi; |
178 | 178 |
179 // Overridden from ui::EventRewriter | 179 // Overridden from ui::EventRewriter |
180 ui::EventRewriteStatus RewriteEvent( | 180 ui::EventRewriteStatus RewriteEvent( |
181 const ui::Event& event, | 181 const ui::Event& event, |
182 scoped_ptr<ui::Event>* rewritten_event) override; | 182 std::unique_ptr<ui::Event>* rewritten_event) override; |
183 ui::EventRewriteStatus NextDispatchEvent( | 183 ui::EventRewriteStatus NextDispatchEvent( |
184 const ui::Event& last_event, | 184 const ui::Event& last_event, |
185 scoped_ptr<ui::Event>* new_event) override; | 185 std::unique_ptr<ui::Event>* new_event) override; |
186 | 186 |
187 // Event handlers based on the current state - see State, below. | 187 // Event handlers based on the current state - see State, below. |
188 ui::EventRewriteStatus InNoFingersDown( | 188 ui::EventRewriteStatus InNoFingersDown( |
189 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 189 const ui::TouchEvent& event, |
| 190 std::unique_ptr<ui::Event>* rewritten_event); |
190 ui::EventRewriteStatus InSingleTapPressed( | 191 ui::EventRewriteStatus InSingleTapPressed( |
191 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 192 const ui::TouchEvent& event, |
| 193 std::unique_ptr<ui::Event>* rewritten_event); |
192 ui::EventRewriteStatus InSingleTapOrTouchExploreReleased( | 194 ui::EventRewriteStatus InSingleTapOrTouchExploreReleased( |
193 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 195 const ui::TouchEvent& event, |
| 196 std::unique_ptr<ui::Event>* rewritten_event); |
194 ui::EventRewriteStatus InDoubleTapPending( | 197 ui::EventRewriteStatus InDoubleTapPending( |
195 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 198 const ui::TouchEvent& event, |
| 199 std::unique_ptr<ui::Event>* rewritten_event); |
196 ui::EventRewriteStatus InTouchReleasePending( | 200 ui::EventRewriteStatus InTouchReleasePending( |
197 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 201 const ui::TouchEvent& event, |
| 202 std::unique_ptr<ui::Event>* rewritten_event); |
198 ui::EventRewriteStatus InTouchExploration( | 203 ui::EventRewriteStatus InTouchExploration( |
199 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 204 const ui::TouchEvent& event, |
| 205 std::unique_ptr<ui::Event>* rewritten_event); |
200 ui::EventRewriteStatus InCornerPassthrough( | 206 ui::EventRewriteStatus InCornerPassthrough( |
201 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 207 const ui::TouchEvent& event, |
| 208 std::unique_ptr<ui::Event>* rewritten_event); |
202 ui::EventRewriteStatus InOneFingerPassthrough( | 209 ui::EventRewriteStatus InOneFingerPassthrough( |
203 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 210 const ui::TouchEvent& event, |
| 211 std::unique_ptr<ui::Event>* rewritten_event); |
204 ui::EventRewriteStatus InGestureInProgress( | 212 ui::EventRewriteStatus InGestureInProgress( |
205 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 213 const ui::TouchEvent& event, |
| 214 std::unique_ptr<ui::Event>* rewritten_event); |
206 ui::EventRewriteStatus InTouchExploreSecondPress( | 215 ui::EventRewriteStatus InTouchExploreSecondPress( |
207 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 216 const ui::TouchEvent& event, |
| 217 std::unique_ptr<ui::Event>* rewritten_event); |
208 ui::EventRewriteStatus InWaitForNoFingers( | 218 ui::EventRewriteStatus InWaitForNoFingers( |
209 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 219 const ui::TouchEvent& event, |
| 220 std::unique_ptr<ui::Event>* rewritten_event); |
210 ui::EventRewriteStatus InSlideGesture( | 221 ui::EventRewriteStatus InSlideGesture( |
211 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 222 const ui::TouchEvent& event, |
| 223 std::unique_ptr<ui::Event>* rewritten_event); |
212 ui::EventRewriteStatus InTwoFingerTap( | 224 ui::EventRewriteStatus InTwoFingerTap( |
213 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 225 const ui::TouchEvent& event, |
| 226 std::unique_ptr<ui::Event>* rewritten_event); |
214 | 227 |
215 // Returns the current time of the tick clock. | 228 // Returns the current time of the tick clock. |
216 base::TimeDelta Now(); | 229 base::TimeDelta Now(); |
217 | 230 |
218 // This timer is started every time we get the first press event, and | 231 // This timer is started every time we get the first press event, and |
219 // it fires after the double-click timeout elapses (300 ms by default). | 232 // it fires after the double-click timeout elapses (300 ms by default). |
220 // If the user taps and releases within 300 ms and doesn't press again, | 233 // If the user taps and releases within 300 ms and doesn't press again, |
221 // we treat that as a single mouse move (touch exploration) event. | 234 // we treat that as a single mouse move (touch exploration) event. |
222 void StartTapTimer(); | 235 void StartTapTimer(); |
223 void OnTapTimerFired(); | 236 void OnTapTimerFired(); |
(...skipping 30 matching lines...) Expand all Loading... |
254 | 267 |
255 // Binds DispatchShiftSearchKeyEvent to a specific third key. | 268 // Binds DispatchShiftSearchKeyEvent to a specific third key. |
256 base::Closure BindShiftSearchKeyEvent(const ui::KeyboardCode third_key); | 269 base::Closure BindShiftSearchKeyEvent(const ui::KeyboardCode third_key); |
257 | 270 |
258 // Dispatches a single key with the given flags. | 271 // Dispatches a single key with the given flags. |
259 void DispatchKeyWithFlags(const ui::KeyboardCode key, int flags); | 272 void DispatchKeyWithFlags(const ui::KeyboardCode key, int flags); |
260 | 273 |
261 // Binds DispatchKeyWithFlags to a specific key and flags. | 274 // Binds DispatchKeyWithFlags to a specific key and flags. |
262 base::Closure BindKeyEventWithFlags(const ui::KeyboardCode key, int flags); | 275 base::Closure BindKeyEventWithFlags(const ui::KeyboardCode key, int flags); |
263 | 276 |
264 scoped_ptr<ui::MouseEvent> CreateMouseMoveEvent(const gfx::PointF& location, | 277 std::unique_ptr<ui::MouseEvent> CreateMouseMoveEvent( |
265 int flags); | 278 const gfx::PointF& location, |
| 279 int flags); |
266 | 280 |
267 void EnterTouchToMouseMode(); | 281 void EnterTouchToMouseMode(); |
268 | 282 |
269 void PlaySoundForTimer(); | 283 void PlaySoundForTimer(); |
270 | 284 |
271 // Some constants used in touch_exploration_controller: | 285 // Some constants used in touch_exploration_controller: |
272 | 286 |
273 // Within this many dips of the screen edge, the release event generated will | 287 // Within this many dips of the screen edge, the release event generated will |
274 // reset the state to NoFingersDown. | 288 // reset the state to NoFingersDown. |
275 const float kLeavingScreenEdge = 6; | 289 const float kLeavingScreenEdge = 6; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 // A set of touch ids for fingers currently touching the screen. | 426 // A set of touch ids for fingers currently touching the screen. |
413 std::vector<int> current_touch_ids_; | 427 std::vector<int> current_touch_ids_; |
414 | 428 |
415 // Map of touch ids to their last known location. | 429 // Map of touch ids to their last known location. |
416 std::map<int, gfx::PointF> touch_locations_; | 430 std::map<int, gfx::PointF> touch_locations_; |
417 | 431 |
418 // The current state. | 432 // The current state. |
419 State state_; | 433 State state_; |
420 | 434 |
421 // A copy of the event from the initial touch press. | 435 // A copy of the event from the initial touch press. |
422 scoped_ptr<ui::TouchEvent> initial_press_; | 436 std::unique_ptr<ui::TouchEvent> initial_press_; |
423 | 437 |
424 // Map of touch ids to where its initial press occurred relative to the | 438 // Map of touch ids to where its initial press occurred relative to the |
425 // screen. | 439 // screen. |
426 std::map<int, gfx::Point> initial_presses_; | 440 std::map<int, gfx::Point> initial_presses_; |
427 | 441 |
428 // In one finger passthrough, the touch is displaced relative to the | 442 // In one finger passthrough, the touch is displaced relative to the |
429 // last touch exploration location. | 443 // last touch exploration location. |
430 gfx::Vector2dF passthrough_offset_; | 444 gfx::Vector2dF passthrough_offset_; |
431 | 445 |
432 // Stores the most recent event from a finger that is currently not | 446 // Stores the most recent event from a finger that is currently not |
433 // sending events through, but might in the future (e.g. before a finger | 447 // sending events through, but might in the future (e.g. before a finger |
434 // enters double-tap-hold passthrough, we need to update its location.) | 448 // enters double-tap-hold passthrough, we need to update its location.) |
435 scoped_ptr<ui::TouchEvent> last_unused_finger_event_; | 449 std::unique_ptr<ui::TouchEvent> last_unused_finger_event_; |
436 | 450 |
437 // The last synthesized mouse move event. When the user double-taps, | 451 // The last synthesized mouse move event. When the user double-taps, |
438 // we send the passed-through tap to the location of this event. | 452 // we send the passed-through tap to the location of this event. |
439 scoped_ptr<ui::TouchEvent> last_touch_exploration_; | 453 std::unique_ptr<ui::TouchEvent> last_touch_exploration_; |
440 | 454 |
441 // A timer that fires after the double-tap delay. | 455 // A timer that fires after the double-tap delay. |
442 base::OneShotTimer tap_timer_; | 456 base::OneShotTimer tap_timer_; |
443 | 457 |
444 // A timer that fires to enter passthrough. | 458 // A timer that fires to enter passthrough. |
445 base::OneShotTimer passthrough_timer_; | 459 base::OneShotTimer passthrough_timer_; |
446 | 460 |
447 // A timer to fire an indicating sound when sliding to change volume. | 461 // A timer to fire an indicating sound when sliding to change volume. |
448 base::RepeatingTimer sound_timer_; | 462 base::RepeatingTimer sound_timer_; |
449 | 463 |
450 // A default gesture detector config, so we can share the same | 464 // A default gesture detector config, so we can share the same |
451 // timeout and pixel slop constants. | 465 // timeout and pixel slop constants. |
452 ui::GestureDetector::Config gesture_detector_config_; | 466 ui::GestureDetector::Config gesture_detector_config_; |
453 | 467 |
454 // Gesture Handler to interpret the touch events. | 468 // Gesture Handler to interpret the touch events. |
455 scoped_ptr<ui::GestureProviderAura> gesture_provider_; | 469 std::unique_ptr<ui::GestureProviderAura> gesture_provider_; |
456 | 470 |
457 // The previous state entered. | 471 // The previous state entered. |
458 State prev_state_; | 472 State prev_state_; |
459 | 473 |
460 // A copy of the previous event passed. | 474 // A copy of the previous event passed. |
461 scoped_ptr<ui::TouchEvent> prev_event_; | 475 std::unique_ptr<ui::TouchEvent> prev_event_; |
462 | 476 |
463 // This toggles whether VLOGS are turned on or not. | 477 // This toggles whether VLOGS are turned on or not. |
464 bool VLOG_on_; | 478 bool VLOG_on_; |
465 | 479 |
466 // When touch_exploration_controller gets time relative to real time during | 480 // When touch_exploration_controller gets time relative to real time during |
467 // testing, this clock is set to the simulated clock and used. | 481 // testing, this clock is set to the simulated clock and used. |
468 base::TickClock* tick_clock_; | 482 base::TickClock* tick_clock_; |
469 | 483 |
470 // Maps the number of fingers in a swipe to the resulting functions that | 484 // Maps the number of fingers in a swipe to the resulting functions that |
471 // dispatch key events. | 485 // dispatch key events. |
472 std::map<int, base::Closure> left_swipe_gestures_; | 486 std::map<int, base::Closure> left_swipe_gestures_; |
473 std::map<int, base::Closure> right_swipe_gestures_; | 487 std::map<int, base::Closure> right_swipe_gestures_; |
474 std::map<int, base::Closure> up_swipe_gestures_; | 488 std::map<int, base::Closure> up_swipe_gestures_; |
475 std::map<int, base::Closure> down_swipe_gestures_; | 489 std::map<int, base::Closure> down_swipe_gestures_; |
476 | 490 |
477 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); | 491 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); |
478 }; | 492 }; |
479 | 493 |
480 } // namespace ui | 494 } // namespace ui |
481 | 495 |
482 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 496 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
OLD | NEW |