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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // (without performing a gesture), they enter touch exploration mode earlier | 99 // (without performing a gesture), they enter touch exploration mode earlier |
100 // than 300 ms. | 100 // than 300 ms. |
101 // | 101 // |
102 // If the user taps and releases their finger, after 300 ms from the initial | 102 // If the user taps and releases their finger, after 300 ms from the initial |
103 // touch, a single mouse move is fired. | 103 // touch, a single mouse move is fired. |
104 // | 104 // |
105 // While in touch exploration mode, the user can perform a single tap | 105 // While in touch exploration mode, the user can perform a single tap |
106 // if the user releases their finger and taps before 300 ms passes. | 106 // if the user releases their finger and taps before 300 ms passes. |
107 // This will result in a click on the last successful touch exploration | 107 // This will result in a click on the last successful touch exploration |
108 // location. This allows the user to perform a single tap | 108 // location. This allows the user to perform a single tap |
109 // anywhere to activate it. | 109 // anywhere to activate it. (See more information on simulated clicks |
| 110 // below.) |
110 // | 111 // |
111 // The user can perform swipe gestures in one of the four cardinal directions | 112 // The user can perform swipe gestures in one of the four cardinal directions |
112 // which will be interpreted and used to control the UI. All gestures will only | 113 // which will be interpreted and used to control the UI. All gestures will only |
113 // be registered if the fingers move outside the slop, and all fingers will only | 114 // be registered if the fingers move outside the slop, and all fingers will only |
114 // be registered if they are completed within the grace period. If a single | 115 // be registered if they are completed within the grace period. If a single |
115 // finger gesture fails to be completed within the grace period, the state | 116 // finger gesture fails to be completed within the grace period, the state |
116 // changes to touch exploration mode. If a multi finger gesture fails to be | 117 // changes to touch exploration mode. If a multi finger gesture fails to be |
117 // completed within the grace period, the user must lift all fingers before | 118 // completed within the grace period, the user must lift all fingers before |
118 // completing any more actions. | 119 // completing any more actions. |
119 // | 120 // |
120 // If the user double-taps, the second tap is passed through, allowing the | 121 // The user's initial tap sets the anchor point. Simulated events are |
121 // user to click - however, the double-tap location is changed to the location | 122 // positioned relative to the anchor point, so that after exploring to find |
122 // of the last successful touch exploration - that allows the user to explore | 123 // an object the user can double-tap anywhere on the screen to activate it. |
123 // anywhere on the screen, hear its description, then double-tap anywhere | 124 // The anchor point is also set by ChromeVox every time it highlights an |
124 // to activate it. | 125 // object on the screen. During touch exploration this ensures that |
| 126 // any simulated events go to the center of the most recently highlighted |
| 127 // object, rather than to the exact tap location (which could have drifted |
| 128 // off of the object). This also ensures that when the current ChromeVox |
| 129 // object changes due to a gesture or input focus changing, simulated |
| 130 // events go to that object and not the last location touched by a finger. |
125 // | 131 // |
126 // If the user double taps and holds, any event from that finger is passed | 132 // When the user double-taps, this is treated as a discrete gestures, and |
127 // through. These events are passed through with an offset such that the first | 133 // and event is sent to ChromeVox to activate the current object, whatever |
128 // touch is offset to be at the location of the last touch exploration | 134 // that is. However, when the user double-taps and holds, any event from that |
129 // location, and every following event is offset by the same amount. | 135 // finger is passed through, allowing the user to drag. These events are |
| 136 // passed through with a location that's relative to the anchor point. |
130 // | 137 // |
131 // If any other fingers are added or removed, they are ignored. Once the | 138 // If any other fingers are added or removed during a passthrough, they are |
132 // passthrough finger is released, passthrough stops and the user is reset | 139 // ignored. Once the passthrough finger is released, passthrough stops and |
133 // to no fingers down state. | 140 // the state is reset to the no fingers down state. |
134 // | 141 // |
135 // If the user enters touch exploration mode, they can click without lifting | 142 // If the user enters touch exploration mode, they can click without lifting |
136 // their touch exploration finger by tapping anywhere else on the screen with | 143 // their touch exploration finger by tapping anywhere else on the screen with |
137 // a second finger, while the touch exploration finger is still pressed. | 144 // a second finger, while the touch exploration finger is still pressed. |
138 // | 145 // |
139 // Once touch exploration mode has been activated, it remains in that mode until | 146 // Once touch exploration mode has been activated, it remains in that mode until |
140 // all fingers have been released. | 147 // all fingers have been released. |
141 // | 148 // |
142 // If the user places a finger on the edge of the screen and moves their finger | 149 // If the user places a finger on the edge of the screen and moves their finger |
143 // past slop, a slide gesture is performed. The user can then slide one finger | 150 // past slop, a slide gesture is performed. The user can then slide one finger |
(...skipping 27 matching lines...) Expand all Loading... |
171 class UI_CHROMEOS_EXPORT TouchExplorationController | 178 class UI_CHROMEOS_EXPORT TouchExplorationController |
172 : public ui::EventRewriter, | 179 : public ui::EventRewriter, |
173 public ui::GestureProviderAuraClient, | 180 public ui::GestureProviderAuraClient, |
174 public ui::GestureConsumer { | 181 public ui::GestureConsumer { |
175 public: | 182 public: |
176 explicit TouchExplorationController( | 183 explicit TouchExplorationController( |
177 aura::Window* root_window, | 184 aura::Window* root_window, |
178 ui::TouchExplorationControllerDelegate* delegate); | 185 ui::TouchExplorationControllerDelegate* delegate); |
179 ~TouchExplorationController() override; | 186 ~TouchExplorationController() override; |
180 | 187 |
| 188 // Make synthesized touch events are anchored at this point. This is |
| 189 // called when the object with accessibility focus is updated via something |
| 190 // other than touch exploration. |
| 191 void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point); |
| 192 |
181 private: | 193 private: |
182 friend class TouchExplorationControllerTestApi; | 194 friend class TouchExplorationControllerTestApi; |
183 | 195 |
184 // Overridden from ui::EventRewriter | 196 // Overridden from ui::EventRewriter |
185 ui::EventRewriteStatus RewriteEvent( | 197 ui::EventRewriteStatus RewriteEvent( |
186 const ui::Event& event, | 198 const ui::Event& event, |
187 std::unique_ptr<ui::Event>* rewritten_event) override; | 199 std::unique_ptr<ui::Event>* rewritten_event) override; |
188 ui::EventRewriteStatus NextDispatchEvent( | 200 ui::EventRewriteStatus NextDispatchEvent( |
189 const ui::Event& last_event, | 201 const ui::Event& last_event, |
190 std::unique_ptr<ui::Event>* new_event) override; | 202 std::unique_ptr<ui::Event>* new_event) override; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 base::Closure BindKeyEventWithFlags(const ui::KeyboardCode key, int flags); | 285 base::Closure BindKeyEventWithFlags(const ui::KeyboardCode key, int flags); |
274 | 286 |
275 std::unique_ptr<ui::MouseEvent> CreateMouseMoveEvent( | 287 std::unique_ptr<ui::MouseEvent> CreateMouseMoveEvent( |
276 const gfx::PointF& location, | 288 const gfx::PointF& location, |
277 int flags); | 289 int flags); |
278 | 290 |
279 void EnterTouchToMouseMode(); | 291 void EnterTouchToMouseMode(); |
280 | 292 |
281 void PlaySoundForTimer(); | 293 void PlaySoundForTimer(); |
282 | 294 |
| 295 void SendSimulatedClick(); |
| 296 |
283 // Some constants used in touch_exploration_controller: | 297 // Some constants used in touch_exploration_controller: |
284 | 298 |
285 // Within this many dips of the screen edge, the release event generated will | 299 // Within this many dips of the screen edge, the release event generated will |
286 // reset the state to NoFingersDown. | 300 // reset the state to NoFingersDown. |
287 const float kLeavingScreenEdge = 6; | 301 const float kLeavingScreenEdge = 6; |
288 | 302 |
289 // Swipe/scroll gestures within these bounds (in DIPs) will change preset | 303 // Swipe/scroll gestures within these bounds (in DIPs) will change preset |
290 // settings. | 304 // settings. |
291 const float kMaxDistanceFromEdge = 75; | 305 const float kMaxDistanceFromEdge = 75; |
292 | 306 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 // If the user is within the given bounds from an edge of the screen, not | 391 // If the user is within the given bounds from an edge of the screen, not |
378 // including corners, then the resulting movements will be interpreted as | 392 // including corners, then the resulting movements will be interpreted as |
379 // slide gestures. | 393 // slide gestures. |
380 SLIDE_GESTURE, | 394 SLIDE_GESTURE, |
381 | 395 |
382 // If the user taps the screen with two fingers and releases both fingers | 396 // If the user taps the screen with two fingers and releases both fingers |
383 // before the grace period has passed, spoken feedback will be silenced. | 397 // before the grace period has passed, spoken feedback will be silenced. |
384 TWO_FINGER_TAP, | 398 TWO_FINGER_TAP, |
385 }; | 399 }; |
386 | 400 |
| 401 enum AnchorPointState { |
| 402 ANCHOR_POINT_NONE, |
| 403 ANCHOR_POINT_FROM_TOUCH_EXPLORATION, |
| 404 ANCHOR_POINT_EXPLICITLY_SET |
| 405 }; |
| 406 |
387 enum ScreenLocation { | 407 enum ScreenLocation { |
388 // Hot "edges" of the screen are each represented by a respective bit. | 408 // Hot "edges" of the screen are each represented by a respective bit. |
389 NO_EDGE = 0, | 409 NO_EDGE = 0, |
390 RIGHT_EDGE = 1 << 0, | 410 RIGHT_EDGE = 1 << 0, |
391 TOP_EDGE = 1 << 1, | 411 TOP_EDGE = 1 << 1, |
392 LEFT_EDGE = 1 << 2, | 412 LEFT_EDGE = 1 << 2, |
393 BOTTOM_EDGE = 1 << 3, | 413 BOTTOM_EDGE = 1 << 3, |
394 BOTTOM_LEFT_CORNER = LEFT_EDGE | BOTTOM_EDGE, | 414 BOTTOM_LEFT_CORNER = LEFT_EDGE | BOTTOM_EDGE, |
395 BOTTOM_RIGHT_CORNER = RIGHT_EDGE | BOTTOM_EDGE, | 415 BOTTOM_RIGHT_CORNER = RIGHT_EDGE | BOTTOM_EDGE, |
396 }; | 416 }; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 455 |
436 // In one finger passthrough, the touch is displaced relative to the | 456 // In one finger passthrough, the touch is displaced relative to the |
437 // last touch exploration location. | 457 // last touch exploration location. |
438 gfx::Vector2dF passthrough_offset_; | 458 gfx::Vector2dF passthrough_offset_; |
439 | 459 |
440 // Stores the most recent event from a finger that is currently not | 460 // Stores the most recent event from a finger that is currently not |
441 // sending events through, but might in the future (e.g. before a finger | 461 // sending events through, but might in the future (e.g. before a finger |
442 // enters double-tap-hold passthrough, we need to update its location.) | 462 // enters double-tap-hold passthrough, we need to update its location.) |
443 std::unique_ptr<ui::TouchEvent> last_unused_finger_event_; | 463 std::unique_ptr<ui::TouchEvent> last_unused_finger_event_; |
444 | 464 |
445 // The last synthesized mouse move event. When the user double-taps, | 465 // The anchor point used as the location of a synthesized tap when the |
446 // we send the passed-through tap to the location of this event. | 466 // user double-taps anywhere on the screen, and similarly the initial |
| 467 // point used when the user double-taps, holds, and drags. This can be |
| 468 // set either via touch exploration, or by a call to |
| 469 // SetTouchAccessibilityAnchorPoint when focus moves due to something other |
| 470 // than touch exploration. |
| 471 gfx::PointF anchor_point_; |
| 472 |
| 473 // The current state of the anchor point. |
| 474 AnchorPointState anchor_point_state_; |
| 475 |
| 476 // The last touch exploration event. |
447 std::unique_ptr<ui::TouchEvent> last_touch_exploration_; | 477 std::unique_ptr<ui::TouchEvent> last_touch_exploration_; |
448 | 478 |
449 // A timer that fires after the double-tap delay. | 479 // A timer that fires after the double-tap delay. |
450 base::OneShotTimer tap_timer_; | 480 base::OneShotTimer tap_timer_; |
451 | 481 |
452 // A timer that fires to enter passthrough. | 482 // A timer that fires to enter passthrough. |
453 base::OneShotTimer passthrough_timer_; | 483 base::OneShotTimer passthrough_timer_; |
454 | 484 |
455 // A timer to fire an indicating sound when sliding to change volume. | 485 // A timer to fire an indicating sound when sliding to change volume. |
456 base::RepeatingTimer sound_timer_; | 486 base::RepeatingTimer sound_timer_; |
(...skipping 17 matching lines...) Expand all Loading... |
474 // When touch_exploration_controller gets time relative to real time during | 504 // When touch_exploration_controller gets time relative to real time during |
475 // testing, this clock is set to the simulated clock and used. | 505 // testing, this clock is set to the simulated clock and used. |
476 base::TickClock* tick_clock_; | 506 base::TickClock* tick_clock_; |
477 | 507 |
478 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); | 508 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); |
479 }; | 509 }; |
480 | 510 |
481 } // namespace ui | 511 } // namespace ui |
482 | 512 |
483 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 513 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
OLD | NEW |