Chromium Code Reviews| 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/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "ui/chromeos/ui_chromeos_export.h" | 10 #include "ui/chromeos/ui_chromeos_export.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 // ** Short version ** | 29 // ** Short version ** |
| 30 // | 30 // |
| 31 // At a high-level, single-finger events are used for accessibility - | 31 // At a high-level, single-finger events are used for accessibility - |
| 32 // exploring the screen gets turned into mouse moves (which can then be | 32 // exploring the screen gets turned into mouse moves (which can then be |
| 33 // spoken by an accessibility service running), a double-tap simulates a | 33 // spoken by an accessibility service running), a double-tap simulates a |
| 34 // click, and gestures can be used to send high-level accessibility commands. | 34 // click, and gestures can be used to send high-level accessibility commands. |
| 35 // When two or more fingers are pressed initially, from then on the events | 35 // When two or more fingers are pressed initially, from then on the events |
| 36 // are passed through, but with the initial finger removed - so if you swipe | 36 // are passed through, but with the initial finger removed - so if you swipe |
| 37 // down with two fingers, the running app will see a one-finger swipe. | 37 // down with two fingers, the running app will see a one-finger swipe. |
| 38 // | 38 // |
| 39 // ** Long version ** | 39 // ** Long version ** |
|
dmazzoni
2014/06/16 18:21:19
You should update the description in the header fi
evy
2014/06/16 20:34:20
Done.
| |
| 40 // | 40 // |
| 41 // Here are the details of the implementation: | 41 // Here are the details of the implementation: |
| 42 // | 42 // |
| 43 // When the first touch is pressed, a 300 ms grace period timer starts. | 43 // When the first touch is pressed, a 300 ms grace period timer starts. |
| 44 // | 44 // |
| 45 // If the user keeps their finger down for more than 300 ms and doesn't | 45 // If the user keeps their finger down for more than 300 ms and doesn't |
| 46 // perform a supported accessibility gesture in that time (e.g. swipe right), | 46 // perform a supported accessibility gesture in that time (e.g. swipe right), |
| 47 // they enter touch exploration mode, and all movements are translated into | 47 // they enter touch exploration mode, and all movements are translated into |
| 48 // synthesized mouse move events. | 48 // synthesized mouse move events. |
| 49 // | 49 // |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 ui::EventRewriteStatus InSingleTapPressed( | 98 ui::EventRewriteStatus InSingleTapPressed( |
| 99 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 99 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 100 ui::EventRewriteStatus InSingleTapReleased( | 100 ui::EventRewriteStatus InSingleTapReleased( |
| 101 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 101 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 102 ui::EventRewriteStatus InDoubleTapPressed( | 102 ui::EventRewriteStatus InDoubleTapPressed( |
| 103 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 103 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 104 ui::EventRewriteStatus InTouchExploration( | 104 ui::EventRewriteStatus InTouchExploration( |
| 105 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 105 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 106 ui::EventRewriteStatus InPassthroughMinusOne( | 106 ui::EventRewriteStatus InPassthroughMinusOne( |
| 107 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 107 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 108 | 108 ui::EventRewriteStatus InTouchExplSecondPress( |
| 109 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | |
| 109 // This timer is started every time we get the first press event, and | 110 // This timer is started every time we get the first press event, and |
| 110 // it fires after the double-click timeout elapses (300 ms by default). | 111 // it fires after the double-click timeout elapses (300 ms by default). |
| 111 // If the user taps and releases within 300 ms and doesn't press again, | 112 // If the user taps and releases within 300 ms and doesn't press again, |
| 112 // we treat that as a single mouse move (touch exploration) event. | 113 // we treat that as a single mouse move (touch exploration) event. |
| 113 void OnTapTimerFired(); | 114 void OnTapTimerFired(); |
| 114 | 115 |
| 115 // Dispatch a new event outside of the event rewriting flow. | 116 // Dispatch a new event outside of the event rewriting flow. |
| 116 void DispatchEvent(ui::Event* event); | 117 void DispatchEvent(ui::Event* event); |
| 117 | 118 |
| 118 scoped_ptr<ui::Event> CreateMouseMoveEvent(const gfx::PointF& location, | 119 scoped_ptr<ui::Event> CreateMouseMoveEvent(const gfx::PointF& location, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 | 153 |
| 153 // The user placed two or more fingers down within the grace period. | 154 // The user placed two or more fingers down within the grace period. |
| 154 // We're now in passthrough mode until all fingers are lifted. Initially | 155 // We're now in passthrough mode until all fingers are lifted. Initially |
| 155 // the first finger is ignored and other fingers are passed through | 156 // the first finger is ignored and other fingers are passed through |
| 156 // as-is. If a finger other than the initial one is the first to be | 157 // as-is. If a finger other than the initial one is the first to be |
| 157 // released, we rewrite the first finger with the touch id of the finger | 158 // released, we rewrite the first finger with the touch id of the finger |
| 158 // that was released, from now on. The motivation for this is that if | 159 // that was released, from now on. The motivation for this is that if |
| 159 // the user starts a scroll with 2 fingers, they can release either one | 160 // the user starts a scroll with 2 fingers, they can release either one |
| 160 // and continue the scrolling. | 161 // and continue the scrolling. |
| 161 PASSTHROUGH_MINUS_ONE, | 162 PASSTHROUGH_MINUS_ONE, |
| 163 | |
| 164 // The user was in touch exploration, but has placed down another finger. | |
| 165 // If the user releases the second finger, a touch press and release | |
| 166 // will go through at the last touch explore location. If the user | |
| 167 // releases the touch explore finger, the other finger will continue with | |
| 168 // touch explore. Any fingers pressed past the first two are ignored. | |
| 169 TE_SECOND_PRESS, | |
|
dmazzoni
2014/06/16 18:21:19
I'd prefer TOUCH_EXPL_SECOND_PRESS or something li
evy
2014/06/16 20:34:20
Done. I think I'll stick with TOUCH_EXPL_SECOND_PR
| |
| 162 }; | 170 }; |
| 163 | 171 |
| 164 void VLOGState(int line_number); | 172 void VLOGState(int line_number); |
| 165 | 173 |
| 166 void VLOGEvent(const ui::Event& event, int line_number); | 174 void VLOGEvent(const ui::Event& event, int line_number); |
| 167 | 175 |
| 168 // Gets enum name from integer value | 176 // Gets enum name from integer value |
| 169 const char* EnumStateToString(State state); | 177 const char* EnumStateToString(State state); |
| 170 | 178 |
| 171 const char* EnumEventTypeToString(ui::EventType type); | 179 const char* EnumEventTypeToString(ui::EventType type); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 185 int initial_touch_id_passthrough_mapping_; | 193 int initial_touch_id_passthrough_mapping_; |
| 186 | 194 |
| 187 // The current state. | 195 // The current state. |
| 188 State state_; | 196 State state_; |
| 189 | 197 |
| 190 // A copy of the event from the initial touch press. | 198 // A copy of the event from the initial touch press. |
| 191 scoped_ptr<ui::TouchEvent> initial_press_; | 199 scoped_ptr<ui::TouchEvent> initial_press_; |
| 192 | 200 |
| 193 // The last location where we synthesized a mouse move event. | 201 // The last location where we synthesized a mouse move event. |
| 194 // When the user double-taps, we send the passed-through tap here. | 202 // When the user double-taps, we send the passed-through tap here. |
| 195 gfx::PointF last_touch_exploration_location_; | 203 scoped_ptr<ui::TouchEvent> last_touch_exploration_; |
| 196 | 204 |
| 197 // A timer to fire the mouse move event after the double-tap delay. | 205 // A timer to fire the mouse move event after the double-tap delay. |
| 198 base::OneShotTimer<TouchExplorationController> tap_timer_; | 206 base::OneShotTimer<TouchExplorationController> tap_timer_; |
| 199 | 207 |
| 200 // For testing only, an event handler to use for generated events | 208 // For testing only, an event handler to use for generated events |
| 201 // outside of the normal event rewriting flow. | 209 // outside of the normal event rewriting flow. |
| 202 ui::EventHandler* event_handler_for_testing_; | 210 ui::EventHandler* event_handler_for_testing_; |
| 203 | 211 |
| 204 // A default gesture detector config, so we can share the same | 212 // A default gesture detector config, so we can share the same |
| 205 // timeout and pixel slop constants. | 213 // timeout and pixel slop constants. |
| 206 ui::GestureDetector::Config gesture_detector_config_; | 214 ui::GestureDetector::Config gesture_detector_config_; |
| 207 | 215 |
| 208 // The previous state entered | 216 // The previous state entered |
| 209 State prev_state_; | 217 State prev_state_; |
| 210 | 218 |
| 211 // The previous EventType | 219 // The previous EventType |
| 212 ui::EventType prev_event_; | 220 ui::EventType prev_event_; |
| 213 | 221 |
| 214 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); | 222 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); |
| 215 }; | 223 }; |
| 216 | 224 |
| 217 } // namespace ui | 225 } // namespace ui |
| 218 | 226 |
| 219 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 227 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
| OLD | NEW |