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 #include "ui/chromeos/touch_exploration_controller.h" | 5 #include "ui/chromeos/touch_exploration_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/time/default_tick_clock.h" | |
9 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
10 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
11 #include "ui/aura/window_event_dispatcher.h" | 12 #include "ui/aura/window_event_dispatcher.h" |
12 #include "ui/aura/window_tree_host.h" | 13 #include "ui/aura/window_tree_host.h" |
13 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
14 #include "ui/events/event_processor.h" | 15 #include "ui/events/event_processor.h" |
15 #include "ui/events/event_utils.h" | 16 #include "ui/events/event_utils.h" |
16 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
17 | 18 |
18 #define VLOG_STATE() if (VLOG_IS_ON(0)) VlogState(__func__) | 19 #define VLOG_STATE() if (VLOG_IS_ON(0)) VlogState(__func__) |
(...skipping 26 matching lines...) Expand all Loading... | |
45 } | 46 } |
46 | 47 |
47 TouchExplorationController::~TouchExplorationController() { | 48 TouchExplorationController::~TouchExplorationController() { |
48 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 49 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
49 } | 50 } |
50 | 51 |
51 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( | 52 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
52 const ui::Event& event, | 53 const ui::Event& event, |
53 scoped_ptr<ui::Event>* rewritten_event) { | 54 scoped_ptr<ui::Event>* rewritten_event) { |
54 if (!event.IsTouchEvent()) { | 55 if (!event.IsTouchEvent()) { |
56 if (event.IsKeyEvent()) { | |
57 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | |
58 VLOG(0) << "\nKeyboard event: " << key_event.name() | |
59 << "\n Key code: " << key_event.key_code() | |
60 << ", Flags: " << key_event.flags() | |
61 << ", Is char: " << key_event.is_char(); | |
62 } | |
55 return ui::EVENT_REWRITE_CONTINUE; | 63 return ui::EVENT_REWRITE_CONTINUE; |
56 } | 64 } |
57 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); | 65 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); |
58 | 66 |
59 // If the tap timer should have fired by now but hasn't, run it now and | 67 // If the tap timer should have fired by now but hasn't, run it now and |
60 // stop the timer. This is important so that behavior is consistent with | 68 // stop the timer. This is important so that behavior is consistent with |
61 // the timestamps of the events, and not dependent on the granularity of | 69 // the timestamps of the events, and not dependent on the granularity of |
62 // the timer. | 70 // the timer. |
63 if (tap_timer_.IsRunning() && | 71 if (tap_timer_.IsRunning() && |
64 touch_event.time_stamp() - initial_press_->time_stamp() > | 72 touch_event.time_stamp() - initial_press_->time_stamp() > |
65 gesture_detector_config_.double_tap_timeout) { | 73 gesture_detector_config_.double_tap_timeout) { |
66 tap_timer_.Stop(); | 74 tap_timer_.Stop(); |
67 OnTapTimerFired(); | 75 OnTapTimerFired(); |
68 // Note: this may change the state. We should now continue and process | 76 // Note: this may change the state. We should now continue and process |
69 // this event under this new state. | 77 // this event under this new state. |
70 } | 78 } |
71 | 79 |
72 const ui::EventType type = touch_event.type(); | 80 const ui::EventType type = touch_event.type(); |
73 const gfx::PointF& location = touch_event.location_f(); | 81 const gfx::PointF& location = touch_event.location_f(); |
74 const int touch_id = touch_event.touch_id(); | 82 const int touch_id = touch_event.touch_id(); |
75 | 83 |
84 // Always process gesture events in the gesture provider. Only one swipe | |
aboxhall
2014/08/04 23:38:53
I don't understand the second sentence of this com
evy
2014/08/05 00:14:40
Done.
| |
85 // will be processed in touch_exploration_controller between | |
86 // NO_FINGERS_DOWN states. | |
87 gesture_provider_.OnTouchEvent(touch_event); | |
88 gesture_provider_.OnTouchEventAck(false); | |
89 ProcessGestureEvents(); | |
90 | |
76 // Always update touch ids and touch locations, so we can use those | 91 // Always update touch ids and touch locations, so we can use those |
77 // no matter what state we're in. | 92 // no matter what state we're in. |
78 if (type == ui::ET_TOUCH_PRESSED) { | 93 if (type == ui::ET_TOUCH_PRESSED) { |
79 current_touch_ids_.push_back(touch_id); | 94 current_touch_ids_.push_back(touch_id); |
80 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location)); | 95 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location)); |
81 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 96 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
82 // In order to avoid accidentally double tapping when moving off the edge of | 97 // In order to avoid accidentally double tapping when moving off the edge |
83 // the screen, the state will be rewritten to NoFingersDown. | 98 // of the screen, the state will be rewritten to NoFingersDown. |
84 TouchEvent touch_event = static_cast<const TouchEvent&>(event); | 99 TouchEvent touch_event = static_cast<const TouchEvent&>(event); |
85 if (FindEdgesWithinBounds(touch_event.location(), kLeavingScreenEdge) != | 100 if (FindEdgesWithinBounds(touch_event.location(), kLeavingScreenEdge) != |
86 NO_EDGE) { | 101 NO_EDGE) { |
87 if (current_touch_ids_.size() == 0) { | 102 if (current_touch_ids_.size() == 0) { |
88 ResetToNoFingersDown(); | 103 ResetToNoFingersDown(); |
89 } | 104 } |
90 } | 105 } |
91 | 106 |
92 std::vector<int>::iterator it = std::find( | 107 std::vector<int>::iterator it = std::find( |
93 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id); | 108 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id); |
(...skipping 10 matching lines...) Expand all Loading... | |
104 | 119 |
105 // Can happen if touch exploration is enabled while fingers were down. | 120 // Can happen if touch exploration is enabled while fingers were down. |
106 if (it == current_touch_ids_.end()) | 121 if (it == current_touch_ids_.end()) |
107 return ui::EVENT_REWRITE_CONTINUE; | 122 return ui::EVENT_REWRITE_CONTINUE; |
108 | 123 |
109 touch_locations_[*it] = location; | 124 touch_locations_[*it] = location; |
110 } | 125 } |
111 VLOG_STATE(); | 126 VLOG_STATE(); |
112 VLOG_EVENT(touch_event); | 127 VLOG_EVENT(touch_event); |
113 // The rest of the processing depends on what state we're in. | 128 // The rest of the processing depends on what state we're in. |
114 switch(state_) { | 129 switch (state_) { |
115 case NO_FINGERS_DOWN: | 130 case NO_FINGERS_DOWN: |
116 return InNoFingersDown(touch_event, rewritten_event); | 131 return InNoFingersDown(touch_event, rewritten_event); |
117 case SINGLE_TAP_PRESSED: | 132 case SINGLE_TAP_PRESSED: |
118 return InSingleTapPressed(touch_event, rewritten_event); | 133 return InSingleTapPressed(touch_event, rewritten_event); |
119 case SINGLE_TAP_RELEASED: | 134 case SINGLE_TAP_RELEASED: |
120 case TOUCH_EXPLORE_RELEASED: | 135 case TOUCH_EXPLORE_RELEASED: |
121 return InSingleTapOrTouchExploreReleased(touch_event, rewritten_event); | 136 return InSingleTapOrTouchExploreReleased(touch_event, rewritten_event); |
122 case DOUBLE_TAP_PENDING: | 137 case DOUBLE_TAP_PENDING: |
123 return InDoubleTapPending(touch_event, rewritten_event); | 138 return InDoubleTapPending(touch_event, rewritten_event); |
124 case TOUCH_RELEASE_PENDING: | 139 case TOUCH_RELEASE_PENDING: |
125 return InTouchReleasePending(touch_event, rewritten_event); | 140 return InTouchReleasePending(touch_event, rewritten_event); |
126 case TOUCH_EXPLORATION: | 141 case TOUCH_EXPLORATION: |
127 return InTouchExploration(touch_event, rewritten_event); | 142 return InTouchExploration(touch_event, rewritten_event); |
128 case GESTURE_IN_PROGRESS: | 143 case GESTURE_IN_PROGRESS: |
129 return InGestureInProgress(touch_event, rewritten_event); | 144 return InGestureInProgress(touch_event, rewritten_event); |
130 case TOUCH_EXPLORE_SECOND_PRESS: | 145 case TOUCH_EXPLORE_SECOND_PRESS: |
131 return InTouchExploreSecondPress(touch_event, rewritten_event); | 146 return InTouchExploreSecondPress(touch_event, rewritten_event); |
147 case ONE_FINGER_PASSTHROUGH: | |
148 return InOneFingerPassthrough(touch_event, rewritten_event); | |
149 case WAIT_FOR_NO_FINGERS: | |
150 return InWaitForNoFingers(touch_event, rewritten_event); | |
132 case SLIDE_GESTURE: | 151 case SLIDE_GESTURE: |
133 return InSlideGesture(touch_event, rewritten_event); | 152 return InSlideGesture(touch_event, rewritten_event); |
134 case ONE_FINGER_PASSTHROUGH: | |
135 return InOneFingerPassthrough(touch_event, rewritten_event); | |
136 case WAIT_FOR_ONE_FINGER: | |
137 return InWaitForOneFinger(touch_event, rewritten_event); | |
138 } | 153 } |
139 NOTREACHED(); | 154 NOTREACHED(); |
140 return ui::EVENT_REWRITE_CONTINUE; | 155 return ui::EVENT_REWRITE_CONTINUE; |
141 } | 156 } |
142 | 157 |
143 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent( | 158 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent( |
144 const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) { | 159 const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) { |
145 NOTREACHED(); | 160 NOTREACHED(); |
146 return ui::EVENT_REWRITE_CONTINUE; | 161 return ui::EVENT_REWRITE_CONTINUE; |
147 } | 162 } |
148 | 163 |
149 ui::EventRewriteStatus TouchExplorationController::InNoFingersDown( | 164 ui::EventRewriteStatus TouchExplorationController::InNoFingersDown( |
150 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 165 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
151 const ui::EventType type = event.type(); | 166 const ui::EventType type = event.type(); |
152 if (type == ui::ET_TOUCH_PRESSED) { | 167 if (type == ui::ET_TOUCH_PRESSED) { |
153 initial_press_.reset(new TouchEvent(event)); | 168 initial_press_.reset(new TouchEvent(event)); |
154 last_unused_finger_event_.reset(new TouchEvent(event)); | 169 last_unused_finger_event_.reset(new TouchEvent(event)); |
155 StartTapTimer(); | 170 StartTapTimer(); |
156 gesture_provider_.OnTouchEvent(event); | |
157 gesture_provider_.OnTouchEventAck(false); | |
158 ProcessGestureEvents(); | |
159 state_ = SINGLE_TAP_PRESSED; | 171 state_ = SINGLE_TAP_PRESSED; |
160 VLOG_STATE(); | 172 VLOG_STATE(); |
161 return ui::EVENT_REWRITE_DISCARD; | 173 return ui::EVENT_REWRITE_DISCARD; |
162 } | 174 } |
163 NOTREACHED() << "Unexpected event type received: " << event.name(); | 175 NOTREACHED() << "Unexpected event type received: " << event.name(); |
164 return ui::EVENT_REWRITE_CONTINUE; | 176 return ui::EVENT_REWRITE_CONTINUE; |
165 } | 177 } |
166 | 178 |
167 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( | 179 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( |
168 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 180 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
169 const ui::EventType type = event.type(); | 181 const ui::EventType type = event.type(); |
170 | 182 |
171 if (type == ui::ET_TOUCH_PRESSED) { | 183 if (type == ui::ET_TOUCH_PRESSED) { |
172 // TODO (evy, lisayin) : add support for multifinger swipes. | 184 // This is the start of a multifinger gesture. |
173 // For now, we wait for there to be only one finger down again. | 185 state_ = GESTURE_IN_PROGRESS; |
174 state_ = WAIT_FOR_ONE_FINGER; | 186 VLOG_STATE(); |
175 return EVENT_REWRITE_DISCARD; | 187 return InGestureInProgress(event, rewritten_event); |
176 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 188 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
177 if (current_touch_ids_.size() == 0 && | 189 if (current_touch_ids_.size() == 0 && |
178 event.touch_id() == initial_press_->touch_id()) { | 190 event.touch_id() == initial_press_->touch_id()) { |
179 state_ = SINGLE_TAP_RELEASED; | 191 state_ = SINGLE_TAP_RELEASED; |
180 VLOG_STATE(); | 192 VLOG_STATE(); |
181 } else if (current_touch_ids_.size() == 0) { | 193 } else if (current_touch_ids_.size() == 0) { |
182 ResetToNoFingersDown(); | 194 ResetToNoFingersDown(); |
183 } | 195 } |
184 return EVENT_REWRITE_DISCARD; | 196 return EVENT_REWRITE_DISCARD; |
185 } else if (type == ui::ET_TOUCH_MOVED) { | 197 } else if (type == ui::ET_TOUCH_MOVED) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 } | 233 } |
222 NOTREACHED() << "Unexpected event type received: " << event.name(); | 234 NOTREACHED() << "Unexpected event type received: " << event.name(); |
223 return ui::EVENT_REWRITE_CONTINUE; | 235 return ui::EVENT_REWRITE_CONTINUE; |
224 } | 236 } |
225 | 237 |
226 ui::EventRewriteStatus | 238 ui::EventRewriteStatus |
227 TouchExplorationController::InSingleTapOrTouchExploreReleased( | 239 TouchExplorationController::InSingleTapOrTouchExploreReleased( |
228 const ui::TouchEvent& event, | 240 const ui::TouchEvent& event, |
229 scoped_ptr<ui::Event>* rewritten_event) { | 241 scoped_ptr<ui::Event>* rewritten_event) { |
230 const ui::EventType type = event.type(); | 242 const ui::EventType type = event.type(); |
231 // If there is more than one finger down, then discard to wait until only one | 243 // If there is more than one finger down, then discard to wait until no |
232 // finger is or no fingers are down. | 244 // fingers are down. |
233 if (current_touch_ids_.size() > 1) { | 245 if (current_touch_ids_.size() > 1) { |
234 state_ = WAIT_FOR_ONE_FINGER; | 246 state_ = WAIT_FOR_NO_FINGERS; |
247 VLOG_STATE(); | |
235 return ui::EVENT_REWRITE_DISCARD; | 248 return ui::EVENT_REWRITE_DISCARD; |
236 } | 249 } |
237 if (type == ui::ET_TOUCH_PRESSED) { | 250 if (type == ui::ET_TOUCH_PRESSED) { |
238 // If there is no touch exploration yet, we can't send a click, so discard. | 251 // If there is no touch exploration yet, we can't send a click, so discard. |
239 if (!last_touch_exploration_) { | 252 if (!last_touch_exploration_) { |
240 tap_timer_.Stop(); | 253 if (tap_timer_.IsRunning()) |
aboxhall
2014/08/04 23:38:53
This check shouldn't be necessary: https://code.go
evy
2014/08/05 00:14:40
Thanks for catching that! Updated some other parts
| |
254 tap_timer_.Stop(); | |
241 return ui::EVENT_REWRITE_DISCARD; | 255 return ui::EVENT_REWRITE_DISCARD; |
242 } | 256 } |
243 // This is the second tap in a double-tap (or double tap-hold). | 257 // This is the second tap in a double-tap (or double tap-hold). |
244 // We set the tap timer. If it fires before the user lifts their finger, | 258 // We set the tap timer. If it fires before the user lifts their finger, |
245 // one-finger passthrough begins. Otherwise, there is a touch press and | 259 // one-finger passthrough begins. Otherwise, there is a touch press and |
246 // release at the location of the last touch exploration. | 260 // release at the location of the last touch exploration. |
247 state_ = DOUBLE_TAP_PENDING; | 261 state_ = DOUBLE_TAP_PENDING; |
248 VLOG_STATE(); | 262 VLOG_STATE(); |
263 // The old tap timer (from the initial click) is stopped if it is still | |
264 // going, and the new one is set. | |
265 if (tap_timer_.IsRunning()) | |
266 tap_timer_.Stop(); | |
249 StartTapTimer(); | 267 StartTapTimer(); |
250 // This will update as the finger moves before a possible passthrough, and | 268 // This will update as the finger moves before a possible passthrough, and |
251 // will determine the offset. | 269 // will determine the offset. |
252 last_unused_finger_event_.reset(new ui::TouchEvent(event)); | 270 last_unused_finger_event_.reset(new ui::TouchEvent(event)); |
253 return ui::EVENT_REWRITE_DISCARD; | 271 return ui::EVENT_REWRITE_DISCARD; |
254 } else if (type == ui::ET_TOUCH_RELEASED && !last_touch_exploration_) { | 272 } else if (type == ui::ET_TOUCH_RELEASED && !last_touch_exploration_) { |
255 // If the previous press was discarded, we need to also handle its | 273 // If the previous press was discarded, we need to also handle its |
256 // release. | 274 // release. |
257 if (current_touch_ids_.size() == 0) { | 275 if (current_touch_ids_.size() == 0) { |
258 ResetToNoFingersDown(); | 276 ResetToNoFingersDown(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 // Rewrite as a mouse-move event. | 376 // Rewrite as a mouse-move event. |
359 *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags()); | 377 *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags()); |
360 last_touch_exploration_.reset(new TouchEvent(event)); | 378 last_touch_exploration_.reset(new TouchEvent(event)); |
361 return ui::EVENT_REWRITE_REWRITTEN; | 379 return ui::EVENT_REWRITE_REWRITTEN; |
362 } | 380 } |
363 | 381 |
364 ui::EventRewriteStatus TouchExplorationController::InGestureInProgress( | 382 ui::EventRewriteStatus TouchExplorationController::InGestureInProgress( |
365 const ui::TouchEvent& event, | 383 const ui::TouchEvent& event, |
366 scoped_ptr<ui::Event>* rewritten_event) { | 384 scoped_ptr<ui::Event>* rewritten_event) { |
367 ui::EventType type = event.type(); | 385 ui::EventType type = event.type(); |
368 // If additional fingers are added before a swipe gesture has been | 386 if (type != ui::ET_TOUCH_RELEASED && type != ui::ET_TOUCH_CANCELLED && |
369 // registered, then the state will no longer be GESTURE_IN_PROGRESS. | 387 type != ui::ET_TOUCH_MOVED && type != ui::ET_TOUCH_PRESSED) { |
370 if (type == ui::ET_TOUCH_PRESSED || | 388 NOTREACHED() << "Unexpected event type received: " << event.name(); |
371 event.touch_id() != initial_press_->touch_id()) { | 389 return ui::EVENT_REWRITE_CONTINUE; |
372 if (tap_timer_.IsRunning()) | |
373 tap_timer_.Stop(); | |
374 // Discard any pending gestures. | |
375 delete gesture_provider_.GetAndResetPendingGestures(); | |
376 state_ = WAIT_FOR_ONE_FINGER; | |
377 return EVENT_REWRITE_DISCARD; | |
378 } | 390 } |
379 | 391 // The events were sent to the gesture provider in RewriteEvent already. |
380 // There should not be more than one finger down. | 392 // If no gesture is registered before the tap timer times out, the state |
aboxhall
2014/08/04 23:38:53
So the gesture grace period is the same as the dou
evy
2014/08/05 00:14:40
Yes, any time in this code that the tap timer is s
| |
381 DCHECK(current_touch_ids_.size() <= 1); | 393 // will change to wait for one finger and this function will stop being |
382 if (type == ui::ET_TOUCH_MOVED) { | 394 // called. |
383 gesture_provider_.OnTouchEvent(event); | 395 if (current_touch_ids_.size() == 0) { |
384 gesture_provider_.OnTouchEventAck(false); | 396 ResetToNoFingersDown(); |
385 } | 397 } |
386 if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | |
387 gesture_provider_.OnTouchEvent(event); | |
388 gesture_provider_.OnTouchEventAck(false); | |
389 if (current_touch_ids_.size() == 0) { | |
390 ResetToNoFingersDown(); | |
391 } | |
392 } | |
393 ProcessGestureEvents(); | |
394 return ui::EVENT_REWRITE_DISCARD; | 398 return ui::EVENT_REWRITE_DISCARD; |
395 } | 399 } |
396 | 400 |
397 ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough( | 401 ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough( |
398 const ui::TouchEvent& event, | 402 const ui::TouchEvent& event, |
399 scoped_ptr<ui::Event>* rewritten_event) { | 403 scoped_ptr<ui::Event>* rewritten_event) { |
400 ui::EventType type = event.type(); | 404 ui::EventType type = event.type(); |
401 | 405 if (type != ui::ET_TOUCH_RELEASED && type != ui::ET_TOUCH_CANCELLED && |
402 if (!(type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED || | 406 type != ui::ET_TOUCH_MOVED && type != ui::ET_TOUCH_PRESSED) { |
403 type == ui::ET_TOUCH_MOVED || type == ui::ET_TOUCH_PRESSED)) { | |
404 NOTREACHED() << "Unexpected event type received: " << event.name(); | 407 NOTREACHED() << "Unexpected event type received: " << event.name(); |
405 return ui::EVENT_REWRITE_CONTINUE; | 408 return ui::EVENT_REWRITE_CONTINUE; |
406 } | 409 } |
407 if (event.touch_id() != initial_press_->touch_id()) { | 410 if (event.touch_id() != initial_press_->touch_id()) { |
408 if (current_touch_ids_.size() == 0) { | 411 if (current_touch_ids_.size() == 0) { |
409 ResetToNoFingersDown(); | 412 ResetToNoFingersDown(); |
410 } | 413 } |
411 return ui::EVENT_REWRITE_DISCARD; | 414 return ui::EVENT_REWRITE_DISCARD; |
412 } | 415 } |
413 rewritten_event->reset( | 416 rewritten_event->reset( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 (*rewritten_event)->set_flags(event.flags()); | 462 (*rewritten_event)->set_flags(event.flags()); |
460 state_ = TOUCH_EXPLORATION; | 463 state_ = TOUCH_EXPLORATION; |
461 EnterTouchToMouseMode(); | 464 EnterTouchToMouseMode(); |
462 VLOG_STATE(); | 465 VLOG_STATE(); |
463 return ui::EVENT_REWRITE_REWRITTEN; | 466 return ui::EVENT_REWRITE_REWRITTEN; |
464 } | 467 } |
465 NOTREACHED() << "Unexpected event type received: " << event.name(); | 468 NOTREACHED() << "Unexpected event type received: " << event.name(); |
466 return ui::EVENT_REWRITE_CONTINUE; | 469 return ui::EVENT_REWRITE_CONTINUE; |
467 } | 470 } |
468 | 471 |
469 ui::EventRewriteStatus TouchExplorationController::InWaitForOneFinger( | 472 ui::EventRewriteStatus TouchExplorationController::InWaitForNoFingers( |
470 const ui::TouchEvent& event, | 473 const ui::TouchEvent& event, |
471 scoped_ptr<ui::Event>* rewritten_event) { | 474 scoped_ptr<ui::Event>* rewritten_event) { |
472 ui::EventType type = event.type(); | 475 ui::EventType type = event.type(); |
473 if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED || | 476 if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED || |
474 type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) { | 477 type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) { |
475 NOTREACHED() << "Unexpected event type received: " << event.name(); | 478 NOTREACHED() << "Unexpected event type received: " << event.name(); |
476 return ui::EVENT_REWRITE_CONTINUE; | 479 return ui::EVENT_REWRITE_CONTINUE; |
477 } | 480 } |
478 if (current_touch_ids_.size() == 1) { | 481 |
479 EnterTouchToMouseMode(); | 482 if (current_touch_ids_.size() == 0) |
480 state_ = TOUCH_EXPLORATION; | 483 ResetToNoFingersDown(); |
481 VLOG_STATE(); | 484 |
482 *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags()); | |
483 last_touch_exploration_.reset(new TouchEvent(event)); | |
484 return ui::EVENT_REWRITE_REWRITTEN; | |
485 } | |
486 return EVENT_REWRITE_DISCARD; | 485 return EVENT_REWRITE_DISCARD; |
487 } | 486 } |
488 | 487 |
489 void TouchExplorationController::PlaySoundForTimer() { | 488 void TouchExplorationController::PlaySoundForTimer() { |
490 delegate_->PlayVolumeAdjustSound(); | 489 delegate_->PlayVolumeAdjustSound(); |
491 } | 490 } |
492 | 491 |
493 ui::EventRewriteStatus TouchExplorationController::InSlideGesture( | 492 ui::EventRewriteStatus TouchExplorationController::InSlideGesture( |
494 const ui::TouchEvent& event, | 493 const ui::TouchEvent& event, |
495 scoped_ptr<ui::Event>* rewritten_event) { | 494 scoped_ptr<ui::Event>* rewritten_event) { |
496 // The timer should not fire when sliding. | 495 // The timer should not fire when sliding. |
497 if (tap_timer_.IsRunning()) | 496 if (tap_timer_.IsRunning()) |
498 tap_timer_.Stop(); | 497 tap_timer_.Stop(); |
499 | 498 |
500 ui::EventType type = event.type(); | 499 ui::EventType type = event.type(); |
501 // If additional fingers are added before a swipe gesture has been registered, | 500 // If additional fingers are added before a swipe gesture has been registered, |
502 // then wait until all fingers have been lifted. | 501 // then wait until all fingers have been lifted. |
503 if (type == ui::ET_TOUCH_PRESSED || | 502 if (type == ui::ET_TOUCH_PRESSED || |
504 event.touch_id() != initial_press_->touch_id()) { | 503 event.touch_id() != initial_press_->touch_id()) { |
505 if (sound_timer_.IsRunning()) | 504 if (sound_timer_.IsRunning()) |
506 sound_timer_.Stop(); | 505 sound_timer_.Stop(); |
507 // Discard any pending gestures. | 506 // Discard any pending gestures. |
508 delete gesture_provider_.GetAndResetPendingGestures(); | 507 delete gesture_provider_.GetAndResetPendingGestures(); |
509 state_ = WAIT_FOR_ONE_FINGER; | 508 state_ = WAIT_FOR_NO_FINGERS; |
509 VLOG_STATE(); | |
510 return EVENT_REWRITE_DISCARD; | 510 return EVENT_REWRITE_DISCARD; |
511 } | 511 } |
512 | 512 |
513 // There should not be more than one finger down. | |
514 DCHECK(current_touch_ids_.size() <= 1); | |
515 | |
516 | |
513 // Allows user to return to the edge to adjust the sound if they have left the | 517 // Allows user to return to the edge to adjust the sound if they have left the |
514 // boundaries. | 518 // boundaries. |
515 int edge = FindEdgesWithinBounds(event.location(), kSlopDistanceFromEdge); | 519 int edge = FindEdgesWithinBounds(event.location(), kSlopDistanceFromEdge); |
516 if (!(edge & RIGHT_EDGE) && (type != ui::ET_TOUCH_RELEASED)) { | 520 if (!(edge & RIGHT_EDGE) && (type != ui::ET_TOUCH_RELEASED)) { |
517 if (sound_timer_.IsRunning()) { | 521 if (sound_timer_.IsRunning()) { |
518 sound_timer_.Stop(); | 522 sound_timer_.Stop(); |
519 } | 523 } |
520 return EVENT_REWRITE_DISCARD; | 524 return EVENT_REWRITE_DISCARD; |
521 } | 525 } |
522 | 526 |
523 // This can occur if the user leaves the screen edge and then returns to it to | 527 // This can occur if the user leaves the screen edge and then returns to it to |
524 // continue adjusting the sound. | 528 // continue adjusting the sound. |
525 if (!sound_timer_.IsRunning()) { | 529 if (!sound_timer_.IsRunning()) { |
526 sound_timer_.Start(FROM_HERE, | 530 sound_timer_.Start(FROM_HERE, |
527 kSoundDelay, | 531 kSoundDelay, |
528 this, | 532 this, |
529 &ui::TouchExplorationController::PlaySoundForTimer); | 533 &ui::TouchExplorationController::PlaySoundForTimer); |
530 delegate_->PlayVolumeAdjustSound(); | 534 delegate_->PlayVolumeAdjustSound(); |
531 } | 535 } |
532 | 536 |
533 // There should not be more than one finger down. | 537 if (current_touch_ids_.size() == 0) { |
534 DCHECK(current_touch_ids_.size() <= 1); | 538 ResetToNoFingersDown(); |
535 if (type == ui::ET_TOUCH_MOVED) { | |
536 gesture_provider_.OnTouchEvent(event); | |
537 gesture_provider_.OnTouchEventAck(false); | |
538 } | |
539 if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | |
540 gesture_provider_.OnTouchEvent(event); | |
541 gesture_provider_.OnTouchEventAck(false); | |
542 delete gesture_provider_.GetAndResetPendingGestures(); | |
543 if (current_touch_ids_.size() == 0) { | |
544 ResetToNoFingersDown(); | |
545 } | |
546 return ui::EVENT_REWRITE_DISCARD; | |
547 } | 539 } |
548 | 540 |
549 ProcessGestureEvents(); | |
550 return ui::EVENT_REWRITE_DISCARD; | 541 return ui::EVENT_REWRITE_DISCARD; |
551 } | 542 } |
552 | 543 |
553 base::TimeDelta TouchExplorationController::Now() { | 544 base::TimeDelta TouchExplorationController::Now() { |
554 if (tick_clock_) { | 545 if (tick_clock_) { |
555 // This is the same as what EventTimeForNow() does, but here we do it | 546 // This is the same as what EventTimeForNow() does, but here we do it |
556 // with a clock that can be replaced with a simulated clock for tests. | 547 // with a clock that can be replaced with a simulated clock for tests. |
557 return base::TimeDelta::FromInternalValue( | 548 return base::TimeDelta::FromInternalValue( |
558 tick_clock_->NowTicks().ToInternalValue()); | 549 tick_clock_->NowTicks().ToInternalValue()); |
559 } | 550 } |
(...skipping 23 matching lines...) Expand all Loading... | |
583 last_touch_exploration_->location(); | 574 last_touch_exploration_->location(); |
584 scoped_ptr<ui::TouchEvent> passthrough_press( | 575 scoped_ptr<ui::TouchEvent> passthrough_press( |
585 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, | 576 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, |
586 last_touch_exploration_->location(), | 577 last_touch_exploration_->location(), |
587 last_unused_finger_event_->touch_id(), | 578 last_unused_finger_event_->touch_id(), |
588 Now())); | 579 Now())); |
589 DispatchEvent(passthrough_press.get()); | 580 DispatchEvent(passthrough_press.get()); |
590 return; | 581 return; |
591 } | 582 } |
592 case SINGLE_TAP_PRESSED: | 583 case SINGLE_TAP_PRESSED: |
584 EnterTouchToMouseMode(); | |
585 state_ = TOUCH_EXPLORATION; | |
586 break; | |
593 case GESTURE_IN_PROGRESS: | 587 case GESTURE_IN_PROGRESS: |
594 // Discard any pending gestures. | 588 // Discard any pending gestures. |
595 delete gesture_provider_.GetAndResetPendingGestures(); | 589 delete gesture_provider_.GetAndResetPendingGestures(); |
596 EnterTouchToMouseMode(); | 590 // If only one finger is down, go into touch exploration. |
597 state_ = TOUCH_EXPLORATION; | 591 if(current_touch_ids_.size() == 1){ |
aboxhall
2014/08/04 23:38:53
nit: space between if and (, and ) and {
evy
2014/08/05 00:14:40
Done.
| |
592 EnterTouchToMouseMode(); | |
593 state_ = TOUCH_EXPLORATION; | |
594 VLOG_STATE(); | |
595 return; | |
596 } | |
597 // Otherwise wait for all fingers to be lifted. | |
598 state_ = WAIT_FOR_NO_FINGERS; | |
598 VLOG_STATE(); | 599 VLOG_STATE(); |
599 break; | 600 return; |
600 default: | 601 default: |
601 return; | 602 return; |
602 } | 603 } |
603 scoped_ptr<ui::Event> mouse_move = | 604 scoped_ptr<ui::Event> mouse_move = |
604 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); | 605 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); |
605 DispatchEvent(mouse_move.get()); | 606 DispatchEvent(mouse_move.get()); |
606 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 607 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); |
607 } | 608 } |
608 | 609 |
609 void TouchExplorationController::DispatchEvent(ui::Event* event) { | 610 void TouchExplorationController::DispatchEvent(ui::Event* event) { |
610 if (event_handler_for_testing_) { | 611 if (event_handler_for_testing_) { |
611 event_handler_for_testing_->OnEvent(event); | 612 event_handler_for_testing_->OnEvent(event); |
612 return; | 613 return; |
613 } | 614 } |
614 ui::EventDispatchDetails result ALLOW_UNUSED = | 615 ui::EventDispatchDetails result ALLOW_UNUSED = |
615 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); | 616 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); |
616 } | 617 } |
617 | 618 |
618 void TouchExplorationController::OnGestureEvent( | 619 void TouchExplorationController::OnGestureEvent( |
619 ui::GestureEvent* gesture) { | 620 ui::GestureEvent* gesture) { |
620 CHECK(gesture->IsGestureEvent()); | 621 CHECK(gesture->IsGestureEvent()); |
621 ui::EventType type = gesture->type(); | 622 ui::EventType type = gesture->type(); |
622 if (VLOG_on_) | 623 if (type == ui::ET_GESTURE_SWIPE && state_ == GESTURE_IN_PROGRESS) { |
623 VLOG(0) << " \n Gesture Triggered: " << gesture->name(); | |
624 if (type == ui::ET_GESTURE_SWIPE && state_ != SLIDE_GESTURE) { | |
625 if (VLOG_on_) | |
626 VLOG(0) << "Swipe!"; | |
627 delete gesture_provider_.GetAndResetPendingGestures(); | 624 delete gesture_provider_.GetAndResetPendingGestures(); |
628 OnSwipeEvent(gesture); | 625 OnSwipeEvent(gesture); |
626 // The tap timer to leave gesture state is ended, and we now wait for all | |
627 // fingers to be released. | |
628 tap_timer_.Stop(); | |
629 state_ = WAIT_FOR_NO_FINGERS; | |
630 VLOG_STATE(); | |
629 return; | 631 return; |
630 } | 632 } |
631 } | 633 } |
632 | 634 |
633 void TouchExplorationController::ProcessGestureEvents() { | 635 void TouchExplorationController::ProcessGestureEvents() { |
634 scoped_ptr<ScopedVector<ui::GestureEvent> > gestures( | 636 scoped_ptr<ScopedVector<ui::GestureEvent> > gestures( |
635 gesture_provider_.GetAndResetPendingGestures()); | 637 gesture_provider_.GetAndResetPendingGestures()); |
636 if (gestures) { | 638 if (gestures) { |
637 for (ScopedVector<GestureEvent>::iterator i = gestures->begin(); | 639 for (ScopedVector<GestureEvent>::iterator i = gestures->begin(); |
638 i != gestures->end(); | 640 i != gestures->end(); |
639 ++i) { | 641 ++i) { |
642 if (VLOG_on_ && | |
643 (state_ == SLIDE_GESTURE || state_ == GESTURE_IN_PROGRESS) && | |
644 (*i)->type() == ui::ET_GESTURE_SWIPE) | |
645 VLOG(0) << " \n Gesture Triggered: " << (*i)->name(); | |
640 if (state_ == SLIDE_GESTURE) | 646 if (state_ == SLIDE_GESTURE) |
641 SideSlideControl(*i); | 647 SideSlideControl(*i); |
642 else | 648 else |
643 OnGestureEvent(*i); | 649 OnGestureEvent(*i); |
644 } | 650 } |
645 } | 651 } |
646 } | 652 } |
647 | 653 |
648 void TouchExplorationController::SideSlideControl(ui::GestureEvent* gesture) { | 654 void TouchExplorationController::SideSlideControl(ui::GestureEvent* gesture) { |
649 ui::EventType type = gesture->type(); | 655 ui::EventType type = gesture->type(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
686 float ratio = (location.y() - kMaxDistanceFromEdge) / volume_adjust_height; | 692 float ratio = (location.y() - kMaxDistanceFromEdge) / volume_adjust_height; |
687 float volume = 100 - 100 * ratio; | 693 float volume = 100 - 100 * ratio; |
688 if (VLOG_on_) { | 694 if (VLOG_on_) { |
689 VLOG(0) << "\n Volume = " << volume | 695 VLOG(0) << "\n Volume = " << volume |
690 << "\n Location = " << location.ToString() | 696 << "\n Location = " << location.ToString() |
691 << "\n Bounds = " << root_window_->bounds().right(); | 697 << "\n Bounds = " << root_window_->bounds().right(); |
692 } | 698 } |
693 delegate_->SetOutputLevel(int(volume)); | 699 delegate_->SetOutputLevel(int(volume)); |
694 } | 700 } |
695 | 701 |
696 | |
697 void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) { | 702 void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) { |
698 // A swipe gesture contains details for the direction in which the swipe | 703 // A swipe gesture contains details for the direction in which the swipe |
699 // occurred. | 704 // occurred. TODO(evy) : Research which swipe results users most want and |
705 // remap these swipes to the best events. Hopefully in the near future | |
706 // there will also be a menu for users to pick custom mappings. | |
700 GestureEventDetails event_details = swipe_gesture->details(); | 707 GestureEventDetails event_details = swipe_gesture->details(); |
701 if (event_details.swipe_left()) { | 708 int num_fingers = event_details.touch_points(); |
702 DispatchShiftSearchKeyEvent(ui::VKEY_LEFT); | 709 if(VLOG_on_) |
710 VLOG(0) << "\nSwipe with " << num_fingers << " fingers."; | |
711 if (num_fingers > 4) | |
703 return; | 712 return; |
704 } else if (event_details.swipe_right()) { | 713 switch (num_fingers) { |
705 DispatchShiftSearchKeyEvent(ui::VKEY_RIGHT); | 714 case 1: |
706 return; | 715 if (event_details.swipe_left()) { |
707 } else if (event_details.swipe_up()) { | 716 DispatchShiftSearchKeyEvent(ui::VKEY_LEFT); |
708 DispatchShiftSearchKeyEvent(ui::VKEY_UP); | 717 return; |
709 return; | 718 } else if (event_details.swipe_right()) { |
710 } else if (event_details.swipe_down()) { | 719 DispatchShiftSearchKeyEvent(ui::VKEY_RIGHT); |
711 DispatchShiftSearchKeyEvent(ui::VKEY_DOWN); | 720 return; |
712 return; | 721 } else if (event_details.swipe_up()) { |
722 DispatchShiftSearchKeyEvent(ui::VKEY_UP); | |
723 return; | |
724 } else if (event_details.swipe_down()) { | |
725 DispatchShiftSearchKeyEvent(ui::VKEY_DOWN); | |
726 return; | |
727 } | |
728 case 2: | |
729 if (event_details.swipe_left()) { | |
730 DispatchKeyWithFlags(VKEY_BROWSER_BACK, ui::EF_NONE); | |
731 return; | |
732 } else if (event_details.swipe_right()) { | |
733 DispatchKeyWithFlags(VKEY_BROWSER_FORWARD, ui::EF_NONE); | |
734 return; | |
735 } else if (event_details.swipe_up()) { | |
736 DispatchShiftSearchKeyEvent(ui::VKEY_A); | |
737 return; | |
738 } else if (event_details.swipe_down()) { | |
739 DispatchShiftSearchKeyEvent(ui::VKEY_R); | |
740 return; | |
741 } | |
742 case 3: | |
743 if (event_details.swipe_left()) { | |
744 DispatchKeyWithFlags(ui::VKEY_TAB, | |
745 ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN); | |
746 } else if (event_details.swipe_right()) { | |
747 DispatchKeyWithFlags(ui::VKEY_TAB, ui::EF_CONTROL_DOWN); | |
748 } else if (event_details.swipe_up()) { | |
749 DispatchKeyWithFlags(ui::VKEY_NEXT, ui::EF_NONE); | |
750 return; | |
751 } else if (event_details.swipe_down()) { | |
752 DispatchKeyWithFlags(ui::VKEY_PRIOR, ui::EF_NONE); | |
753 return; | |
754 } | |
755 return; | |
756 case 4: | |
757 // Brightness can be important for vision users, but none of these | |
aboxhall
2014/08/04 23:38:53
nit: low vision users
evy
2014/08/05 00:14:40
Thanks! That's what I meant :)
| |
758 // mappings are permanent. Four finger gestures shoudl probably | |
aboxhall
2014/08/04 23:38:53
nit: "shoudl"
evy
2014/08/05 00:14:40
Done.
| |
759 // eventually be used for rare needs that are hard to access through | |
760 // menus. | |
761 if (event_details.swipe_left()) { | |
762 DispatchKeyWithFlags(VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); | |
763 return; | |
764 } else if (event_details.swipe_right()) { | |
765 DispatchKeyWithFlags(VKEY_BRIGHTNESS_UP, ui::EF_NONE); | |
766 return; | |
767 } else if (event_details.swipe_up()) { | |
768 DispatchKeyWithFlags(VKEY_BROWSER_HOME, ui::EF_NONE); | |
769 return; | |
770 } else if (event_details.swipe_down()) { | |
771 DispatchKeyWithFlags(VKEY_BROWSER_REFRESH, ui::EF_NONE); | |
772 return; | |
773 } | |
713 } | 774 } |
775 return; | |
714 } | 776 } |
715 | 777 |
716 int TouchExplorationController::FindEdgesWithinBounds(gfx::Point point, | 778 int TouchExplorationController::FindEdgesWithinBounds(gfx::Point point, |
717 float bounds) { | 779 float bounds) { |
718 // Since GetBoundsInScreen is in DIPs but point is not, then point needs to be | 780 // Since GetBoundsInScreen is in DIPs but point is not, then point needs to be |
719 // converted. | 781 // converted. |
720 root_window_->GetHost()->ConvertPointFromNativeScreen(&point); | 782 root_window_->GetHost()->ConvertPointFromNativeScreen(&point); |
721 gfx::Rect window = root_window_->GetBoundsInScreen(); | 783 gfx::Rect window = root_window_->GetBoundsInScreen(); |
722 | 784 |
723 float left_edge_limit = window.x() + bounds; | 785 float left_edge_limit = window.x() + bounds; |
(...skipping 11 matching lines...) Expand all Loading... | |
735 if (point.x() > right_edge_limit) | 797 if (point.x() > right_edge_limit) |
736 result |= RIGHT_EDGE; | 798 result |= RIGHT_EDGE; |
737 if (point.y() < top_edge_limit) | 799 if (point.y() < top_edge_limit) |
738 result |= TOP_EDGE; | 800 result |= TOP_EDGE; |
739 if (point.y() > bottom_edge_limit) | 801 if (point.y() > bottom_edge_limit) |
740 result |= BOTTOM_EDGE; | 802 result |= BOTTOM_EDGE; |
741 return result; | 803 return result; |
742 } | 804 } |
743 | 805 |
744 void TouchExplorationController::DispatchShiftSearchKeyEvent( | 806 void TouchExplorationController::DispatchShiftSearchKeyEvent( |
745 const ui::KeyboardCode direction) { | 807 const ui::KeyboardCode third_key) { |
746 // In order to activate the shortcut shift+search+<arrow key> | 808 // In order to activate the shortcut shift+search+<key> |
747 // three KeyPressed events must be dispatched in succession along | 809 // three KeyPressed events must be dispatched in succession along |
748 // with three KeyReleased events. | 810 // with three KeyReleased events. |
749 ui::KeyEvent shift_down = ui::KeyEvent( | 811 |
812 ui::KeyEvent shift_down( | |
750 ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN); | 813 ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN); |
751 ui::KeyEvent search_down = ui::KeyEvent( | 814 ui::KeyEvent search_down( |
752 ui::ET_KEY_PRESSED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN); | 815 ui::ET_KEY_PRESSED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN); |
753 ui::KeyEvent direction_down = | 816 ui::KeyEvent third_key_down(ui::ET_KEY_PRESSED, third_key, ui::EF_SHIFT_DOWN); |
754 ui::KeyEvent(ui::ET_KEY_PRESSED, direction, ui::EF_SHIFT_DOWN); | |
755 | 817 |
756 ui::KeyEvent direction_up = | 818 ui::KeyEvent third_key_up(ui::ET_KEY_RELEASED, third_key, ui::EF_SHIFT_DOWN); |
757 ui::KeyEvent(ui::ET_KEY_RELEASED, direction, ui::EF_SHIFT_DOWN); | 819 ui::KeyEvent search_up( |
758 ui::KeyEvent search_up = ui::KeyEvent( | |
759 ui::ET_KEY_RELEASED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN); | 820 ui::ET_KEY_RELEASED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN); |
760 ui::KeyEvent shift_up = | 821 ui ::KeyEvent shift_up(ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, ui::EF_NONE); |
761 ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, ui::EF_NONE); | |
762 | 822 |
763 DispatchEvent(&shift_down); | 823 DispatchEvent(&shift_down); |
764 DispatchEvent(&search_down); | 824 DispatchEvent(&search_down); |
765 DispatchEvent(&direction_down); | 825 DispatchEvent(&third_key_down); |
766 DispatchEvent(&direction_up); | 826 DispatchEvent(&third_key_up); |
767 DispatchEvent(&search_up); | 827 DispatchEvent(&search_up); |
768 DispatchEvent(&shift_up); | 828 DispatchEvent(&shift_up); |
769 } | 829 } |
770 | 830 |
831 void TouchExplorationController::DispatchKeyWithFlags( | |
832 const ui::KeyboardCode key, | |
833 int flags) { | |
834 ui::KeyEvent key_down(ui::ET_KEY_PRESSED, key, flags); | |
835 ui::KeyEvent key_up(ui::ET_KEY_RELEASED, key, flags); | |
836 DispatchEvent(&key_down); | |
837 DispatchEvent(&key_up); | |
838 if(VLOG_on_) { | |
839 VLOG(0) << "\nKey down: key code : " << key_down.key_code() | |
840 << ", flags: " << key_down.flags() | |
841 << "\nKey up: key code : " << key_up.key_code() | |
842 << ", flags: " << key_up.flags(); | |
843 } | |
844 } | |
845 | |
771 scoped_ptr<ui::Event> TouchExplorationController::CreateMouseMoveEvent( | 846 scoped_ptr<ui::Event> TouchExplorationController::CreateMouseMoveEvent( |
772 const gfx::PointF& location, | 847 const gfx::PointF& location, |
773 int flags) { | 848 int flags) { |
774 // The "synthesized" flag should be set on all events that don't have a | 849 // The "synthesized" flag should be set on all events that don't have a |
775 // backing native event. | 850 // backing native event. |
776 flags |= ui::EF_IS_SYNTHESIZED; | 851 flags |= ui::EF_IS_SYNTHESIZED; |
777 | 852 |
778 // This flag is used to identify mouse move events that were generated from | 853 // This flag is used to identify mouse move events that were generated from |
779 // touch exploration in Chrome code. | 854 // touch exploration in Chrome code. |
780 flags |= ui::EF_TOUCH_ACCESSIBILITY; | 855 flags |= ui::EF_TOUCH_ACCESSIBILITY; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 return; | 911 return; |
837 } | 912 } |
838 // The above statement prevents events of the same type and id from being | 913 // The above statement prevents events of the same type and id from being |
839 // printed in a row. However, if two fingers are down, they would both be | 914 // printed in a row. However, if two fingers are down, they would both be |
840 // moving and alternating printing move events unless we check for this. | 915 // moving and alternating printing move events unless we check for this. |
841 if (prev_event_ != NULL && | 916 if (prev_event_ != NULL && |
842 prev_event_->type() == ET_TOUCH_MOVED && | 917 prev_event_->type() == ET_TOUCH_MOVED && |
843 touch_event.type() == ET_TOUCH_MOVED){ | 918 touch_event.type() == ET_TOUCH_MOVED){ |
844 return; | 919 return; |
845 } | 920 } |
921 | |
846 const std::string& type = touch_event.name(); | 922 const std::string& type = touch_event.name(); |
847 const gfx::PointF& location = touch_event.location_f(); | 923 const gfx::PointF& location = touch_event.location_f(); |
848 const int touch_id = touch_event.touch_id(); | 924 const int touch_id = touch_event.touch_id(); |
849 | 925 |
850 VLOG(0) << "\n Function name: " << function_name | 926 VLOG(0) << "\n Function name: " << function_name |
851 << "\n Event Type: " << type | 927 << "\n Event Type: " << type |
852 << "\n Location: " << location.ToString() | 928 << "\n Location: " << location.ToString() |
853 << "\n Touch ID: " << touch_id; | 929 << "\n Touch ID: " << touch_id; |
854 prev_event_.reset(new TouchEvent(touch_event)); | 930 prev_event_.reset(new TouchEvent(touch_event)); |
855 } | 931 } |
(...skipping 11 matching lines...) Expand all Loading... | |
867 case DOUBLE_TAP_PENDING: | 943 case DOUBLE_TAP_PENDING: |
868 return "DOUBLE_TAP_PENDING"; | 944 return "DOUBLE_TAP_PENDING"; |
869 case TOUCH_RELEASE_PENDING: | 945 case TOUCH_RELEASE_PENDING: |
870 return "TOUCH_RELEASE_PENDING"; | 946 return "TOUCH_RELEASE_PENDING"; |
871 case TOUCH_EXPLORATION: | 947 case TOUCH_EXPLORATION: |
872 return "TOUCH_EXPLORATION"; | 948 return "TOUCH_EXPLORATION"; |
873 case GESTURE_IN_PROGRESS: | 949 case GESTURE_IN_PROGRESS: |
874 return "GESTURE_IN_PROGRESS"; | 950 return "GESTURE_IN_PROGRESS"; |
875 case TOUCH_EXPLORE_SECOND_PRESS: | 951 case TOUCH_EXPLORE_SECOND_PRESS: |
876 return "TOUCH_EXPLORE_SECOND_PRESS"; | 952 return "TOUCH_EXPLORE_SECOND_PRESS"; |
953 case ONE_FINGER_PASSTHROUGH: | |
954 return "ONE_FINGER_PASSTHROUGH"; | |
955 case WAIT_FOR_NO_FINGERS: | |
956 return "WAIT_FOR_NO_FINGERS"; | |
877 case SLIDE_GESTURE: | 957 case SLIDE_GESTURE: |
878 return "SLIDE_GESTURE"; | 958 return "SLIDE_GESTURE"; |
879 case ONE_FINGER_PASSTHROUGH: | |
880 return "ONE_FINGER_PASSTHROUGH"; | |
881 case WAIT_FOR_ONE_FINGER: | |
882 return "WAIT_FOR_ONE_FINGER"; | |
883 } | 959 } |
884 return "Not a state"; | 960 return "Not a state"; |
885 } | 961 } |
886 | 962 |
887 } // namespace ui | 963 } // namespace ui |
OLD | NEW |