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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 // than 300 ms. | 52 // than 300 ms. |
| 53 // | 53 // |
| 54 // If the user taps and releases their finger, after 300 ms from the initial | 54 // If the user taps and releases their finger, after 300 ms from the initial |
| 55 // touch, a single mouse move is fired. | 55 // touch, a single mouse move is fired. |
| 56 // | 56 // |
| 57 // If the user double-taps, the second tap is passed through, allowing the | 57 // If the user double-taps, the second tap is passed through, allowing the |
| 58 // user to click - however, the double-tap location is changed to the location | 58 // user to click - however, the double-tap location is changed to the location |
| 59 // of the last successful touch exploration - that allows the user to explore | 59 // of the last successful touch exploration - that allows the user to explore |
| 60 // anywhere on the screen, hear its description, then double-tap anywhere | 60 // anywhere on the screen, hear its description, then double-tap anywhere |
| 61 // to activate it. | 61 // to activate it. |
| 62 //// If the user enters touch exploration mode, they can click without lifting | |
|
dmazzoni
2014/06/17 15:50:40
nit: I think there's a newline missing?
evy
2014/06/17 15:57:33
Done.
| |
| 63 // their touch exploration finger by tapping anywhere else on the screen with | |
| 64 // a second finger, while the touch exploration finger is still pressed. | |
| 62 // | 65 // |
| 63 // If the user adds a second finger during the grace period, they enter | 66 // If the user adds a second finger during the grace period, they enter |
| 64 // passthrough mode. In this mode, the first finger is ignored but all | 67 // passthrough mode. In this mode, the first finger is ignored but all |
| 65 // additional touch events are mostly passed through unmodified. So a | 68 // additional touch events are mostly passed through unmodified. So a |
| 66 // two-finger scroll gets passed through as a one-finger scroll. However, | 69 // two-finger scroll gets passed through as a one-finger scroll. However, |
| 67 // once in passthrough mode, if one finger is released, the remaining fingers | 70 // once in passthrough mode, if one finger is released, the remaining fingers |
| 68 // continue to pass through events, allowing the user to start a scroll | 71 // continue to pass through events, allowing the user to start a scroll |
| 69 // with two fingers but finish it with one. Sometimes this requires rewriting | 72 // with two fingers but finish it with one. Sometimes this requires rewriting |
| 70 // the touch ids. | 73 // the touch ids. |
| 71 // | 74 // |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 98 ui::EventRewriteStatus InSingleTapPressed( | 101 ui::EventRewriteStatus InSingleTapPressed( |
| 99 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 102 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 100 ui::EventRewriteStatus InSingleTapReleased( | 103 ui::EventRewriteStatus InSingleTapReleased( |
| 101 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 104 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 102 ui::EventRewriteStatus InDoubleTapPressed( | 105 ui::EventRewriteStatus InDoubleTapPressed( |
| 103 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 106 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 104 ui::EventRewriteStatus InTouchExploration( | 107 ui::EventRewriteStatus InTouchExploration( |
| 105 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 108 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 106 ui::EventRewriteStatus InPassthroughMinusOne( | 109 ui::EventRewriteStatus InPassthroughMinusOne( |
| 107 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 110 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 108 | 111 ui::EventRewriteStatus InTouchExplSecondPress( |
| 112 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | |
| 109 // This timer is started every time we get the first press event, and | 113 // 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). | 114 // 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, | 115 // 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. | 116 // we treat that as a single mouse move (touch exploration) event. |
| 113 void OnTapTimerFired(); | 117 void OnTapTimerFired(); |
| 114 | 118 |
| 115 // Dispatch a new event outside of the event rewriting flow. | 119 // Dispatch a new event outside of the event rewriting flow. |
| 116 void DispatchEvent(ui::Event* event); | 120 void DispatchEvent(ui::Event* event); |
| 117 | 121 |
| 118 scoped_ptr<ui::Event> CreateMouseMoveEvent(const gfx::PointF& location, | 122 scoped_ptr<ui::Event> CreateMouseMoveEvent(const gfx::PointF& location, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 | 156 |
| 153 // The user placed two or more fingers down within the grace period. | 157 // 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 | 158 // We're now in passthrough mode until all fingers are lifted. Initially |
| 155 // the first finger is ignored and other fingers are passed through | 159 // 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 | 160 // 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 | 161 // 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 | 162 // 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 | 163 // the user starts a scroll with 2 fingers, they can release either one |
| 160 // and continue the scrolling. | 164 // and continue the scrolling. |
| 161 PASSTHROUGH_MINUS_ONE, | 165 PASSTHROUGH_MINUS_ONE, |
| 166 | |
| 167 // The user was in touch exploration, but has placed down another finger. | |
| 168 // If the user releases the second finger, a touch press and release | |
| 169 // will go through at the last touch explore location. If the user | |
| 170 // releases the touch explore finger, the other finger will continue with | |
| 171 // touch explore. Any fingers pressed past the first two are ignored. | |
| 172 TOUCH_EXPL_SECOND_PRESS, | |
| 162 }; | 173 }; |
| 163 | 174 |
| 164 void VlogState(const char* function_name); | 175 void VlogState(const char* function_name); |
| 165 | 176 |
| 166 void VlogEvent(const ui::TouchEvent& event, const char* function_name); | 177 void VlogEvent(const ui::TouchEvent& event, const char* function_name); |
| 167 | 178 |
| 168 // Gets enum name from integer value. | 179 // Gets enum name from integer value. |
| 169 const char* EnumStateToString(State state); | 180 const char* EnumStateToString(State state); |
| 170 | 181 |
| 171 std::string EnumEventTypeToString(ui::EventType type); | 182 std::string EnumEventTypeToString(ui::EventType type); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 185 int initial_touch_id_passthrough_mapping_; | 196 int initial_touch_id_passthrough_mapping_; |
| 186 | 197 |
| 187 // The current state. | 198 // The current state. |
| 188 State state_; | 199 State state_; |
| 189 | 200 |
| 190 // A copy of the event from the initial touch press. | 201 // A copy of the event from the initial touch press. |
| 191 scoped_ptr<ui::TouchEvent> initial_press_; | 202 scoped_ptr<ui::TouchEvent> initial_press_; |
| 192 | 203 |
| 193 // The last location where we synthesized a mouse move event. | 204 // The last location where we synthesized a mouse move event. |
| 194 // When the user double-taps, we send the passed-through tap here. | 205 // When the user double-taps, we send the passed-through tap here. |
| 195 gfx::PointF last_touch_exploration_location_; | 206 scoped_ptr<ui::TouchEvent> last_touch_exploration_; |
| 196 | 207 |
| 197 // A timer to fire the mouse move event after the double-tap delay. | 208 // A timer to fire the mouse move event after the double-tap delay. |
| 198 base::OneShotTimer<TouchExplorationController> tap_timer_; | 209 base::OneShotTimer<TouchExplorationController> tap_timer_; |
| 199 | 210 |
| 200 // For testing only, an event handler to use for generated events | 211 // For testing only, an event handler to use for generated events |
| 201 // outside of the normal event rewriting flow. | 212 // outside of the normal event rewriting flow. |
| 202 ui::EventHandler* event_handler_for_testing_; | 213 ui::EventHandler* event_handler_for_testing_; |
| 203 | 214 |
| 204 // A default gesture detector config, so we can share the same | 215 // A default gesture detector config, so we can share the same |
| 205 // timeout and pixel slop constants. | 216 // timeout and pixel slop constants. |
| 206 ui::GestureDetector::Config gesture_detector_config_; | 217 ui::GestureDetector::Config gesture_detector_config_; |
| 207 | 218 |
| 208 // The previous state entered. | 219 // The previous state entered. |
| 209 State prev_state_; | 220 State prev_state_; |
| 210 | 221 |
| 211 // A copy of the previous event passed. | 222 // A copy of the previous event passed. |
| 212 scoped_ptr<ui::TouchEvent> prev_event_; | 223 scoped_ptr<ui::TouchEvent> prev_event_; |
| 213 | 224 |
| 214 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); | 225 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); |
| 215 }; | 226 }; |
| 216 | 227 |
| 217 } // namespace ui | 228 } // namespace ui |
| 218 | 229 |
| 219 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 230 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
| OLD | NEW |