Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(938)

Side by Side Diff: ui/chromeos/touch_exploration_controller.cc

Issue 330763007: Swipe Gestures for Accessibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gesture-vlogs
Patch Set: Removed line that Evy was working on Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ui/aura/client/cursor_client.h" 9 #include "ui/aura/client/cursor_client.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 13 matching lines...) Expand all
24 // touch id remapping yet. 24 // touch id remapping yet.
25 const int kTouchIdUnassigned = 0; 25 const int kTouchIdUnassigned = 0;
26 26
27 // The value for initial_touch_id_passthrough_mapping_ if the user has 27 // The value for initial_touch_id_passthrough_mapping_ if the user has
28 // released the first finger but some other fingers are held down. In this 28 // released the first finger but some other fingers are held down. In this
29 // state we don't do any touch id remapping, but we distinguish it from the 29 // state we don't do any touch id remapping, but we distinguish it from the
30 // kTouchIdUnassigned state because we don't want to assign 30 // kTouchIdUnassigned state because we don't want to assign
31 // initial_touch_id_passthrough_mapping_ a touch id anymore, 31 // initial_touch_id_passthrough_mapping_ a touch id anymore,
32 // until all fingers are released. 32 // until all fingers are released.
33 const int kTouchIdNone = -1; 33 const int kTouchIdNone = -1;
34
35 // In ChromeOS, VKEY_LWIN is synonymous for the search key.
36 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN;
34 } // namespace 37 } // namespace
35 38
36 TouchExplorationController::TouchExplorationController( 39 TouchExplorationController::TouchExplorationController(
37 aura::Window* root_window) 40 aura::Window* root_window)
38 : root_window_(root_window), 41 : root_window_(root_window),
39 initial_touch_id_passthrough_mapping_(kTouchIdUnassigned), 42 initial_touch_id_passthrough_mapping_(kTouchIdUnassigned),
40 state_(NO_FINGERS_DOWN), 43 state_(NO_FINGERS_DOWN),
41 event_handler_for_testing_(NULL), 44 event_handler_for_testing_(NULL),
45 gesture_provider_(this),
42 prev_state_(NO_FINGERS_DOWN) { 46 prev_state_(NO_FINGERS_DOWN) {
43 CHECK(root_window); 47 CHECK(root_window);
44 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); 48 root_window->GetHost()->GetEventSource()->AddEventRewriter(this);
45 } 49 }
46 50
47 TouchExplorationController::~TouchExplorationController() { 51 TouchExplorationController::~TouchExplorationController() {
48 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); 52 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this);
49 } 53 }
50 54
51 void TouchExplorationController::CallTapTimerNowForTesting() { 55 void TouchExplorationController::CallTapTimerNowForTesting() {
52 DCHECK(tap_timer_.IsRunning()); 56 DCHECK(tap_timer_.IsRunning());
53 tap_timer_.Stop(); 57 tap_timer_.Stop();
54 OnTapTimerFired(); 58 OnTapTimerFired();
55 } 59 }
56 60
57 void TouchExplorationController::SetEventHandlerForTesting( 61 void TouchExplorationController::SetEventHandlerForTesting(
58 ui::EventHandler* event_handler_for_testing) { 62 ui::EventHandler* event_handler_for_testing) {
59 event_handler_for_testing_ = event_handler_for_testing; 63 event_handler_for_testing_ = event_handler_for_testing;
60 } 64 }
61 65
62 bool TouchExplorationController::IsInNoFingersDownStateForTesting() const { 66 bool TouchExplorationController::IsInNoFingersDownStateForTesting() const {
63 return state_ == NO_FINGERS_DOWN; 67 return state_ == NO_FINGERS_DOWN;
64 } 68 }
65 69
70 bool TouchExplorationController::IsInGestureInProgressStateForTesting() const {
71 return state_ == GESTURE_IN_PROGRESS;
72 }
73
66 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( 74 ui::EventRewriteStatus TouchExplorationController::RewriteEvent(
67 const ui::Event& event, 75 const ui::Event& event,
68 scoped_ptr<ui::Event>* rewritten_event) { 76 scoped_ptr<ui::Event>* rewritten_event) {
69 if (!event.IsTouchEvent()) 77 if (!event.IsTouchEvent())
70 return ui::EVENT_REWRITE_CONTINUE; 78 return ui::EVENT_REWRITE_CONTINUE;
71 const ui::TouchEvent& touch_event = 79 const ui::TouchEvent& touch_event =
72 static_cast<const ui::TouchEvent&>(event); 80 static_cast<const ui::TouchEvent&>(event);
73 81
74 // If the tap timer should have fired by now but hasn't, run it now and 82 // If the tap timer should have fired by now but hasn't, run it now and
75 // stop the timer. This is important so that behavior is consistent with 83 // stop the timer. This is important so that behavior is consistent with
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return InNoFingersDown(touch_event, rewritten_event); 129 return InNoFingersDown(touch_event, rewritten_event);
122 case SINGLE_TAP_PRESSED: 130 case SINGLE_TAP_PRESSED:
123 return InSingleTapPressed(touch_event, rewritten_event); 131 return InSingleTapPressed(touch_event, rewritten_event);
124 case SINGLE_TAP_RELEASED: 132 case SINGLE_TAP_RELEASED:
125 case TOUCH_EXPLORE_RELEASED: 133 case TOUCH_EXPLORE_RELEASED:
126 return InSingleTapOrTouchExploreReleased(touch_event, rewritten_event); 134 return InSingleTapOrTouchExploreReleased(touch_event, rewritten_event);
127 case DOUBLE_TAP_PRESSED: 135 case DOUBLE_TAP_PRESSED:
128 return InDoubleTapPressed(touch_event, rewritten_event); 136 return InDoubleTapPressed(touch_event, rewritten_event);
129 case TOUCH_EXPLORATION: 137 case TOUCH_EXPLORATION:
130 return InTouchExploration(touch_event, rewritten_event); 138 return InTouchExploration(touch_event, rewritten_event);
139 case GESTURE_IN_PROGRESS:
140 return InGestureInProgress(touch_event, rewritten_event);
131 case PASSTHROUGH_MINUS_ONE: 141 case PASSTHROUGH_MINUS_ONE:
132 return InPassthroughMinusOne(touch_event, rewritten_event); 142 return InPassthroughMinusOne(touch_event, rewritten_event);
133 case TOUCH_EXPLORE_SECOND_PRESS: 143 case TOUCH_EXPLORE_SECOND_PRESS:
134 return InTouchExploreSecondPress(touch_event, rewritten_event); 144 return InTouchExploreSecondPress(touch_event, rewritten_event);
135 } 145 }
136 146
137 NOTREACHED(); 147 NOTREACHED();
138 return ui::EVENT_REWRITE_CONTINUE; 148 return ui::EVENT_REWRITE_CONTINUE;
139 } 149 }
140 150
141 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent( 151 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent(
142 const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) { 152 const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) {
143 NOTREACHED(); 153 NOTREACHED();
144 return ui::EVENT_REWRITE_CONTINUE; 154 return ui::EVENT_REWRITE_CONTINUE;
145 } 155 }
146 156
147 ui::EventRewriteStatus TouchExplorationController::InNoFingersDown( 157 ui::EventRewriteStatus TouchExplorationController::InNoFingersDown(
148 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { 158 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) {
149 const ui::EventType type = event.type(); 159 const ui::EventType type = event.type();
150 if (type == ui::ET_TOUCH_PRESSED) { 160 if (type == ui::ET_TOUCH_PRESSED) {
151 initial_press_.reset(new TouchEvent(event)); 161 initial_press_.reset(new TouchEvent(event));
152 tap_timer_.Start(FROM_HERE, 162 tap_timer_.Start(FROM_HERE,
153 gesture_detector_config_.double_tap_timeout, 163 gesture_detector_config_.double_tap_timeout,
154 this, 164 this,
155 &TouchExplorationController::OnTapTimerFired); 165 &TouchExplorationController::OnTapTimerFired);
166 gesture_provider_.OnTouchEvent(event);
167 gesture_provider_.OnTouchEventAck(false);
156 state_ = SINGLE_TAP_PRESSED; 168 state_ = SINGLE_TAP_PRESSED;
157 VLOG_STATE(); 169 VLOG_STATE();
158 return ui::EVENT_REWRITE_DISCARD; 170 return ui::EVENT_REWRITE_DISCARD;
159 } 171 }
160 172
161 NOTREACHED(); 173 NOTREACHED();
162 return ui::EVENT_REWRITE_CONTINUE; 174 return ui::EVENT_REWRITE_CONTINUE;
163 } 175 }
164 176
165 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( 177 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed(
166 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { 178 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) {
167 const ui::EventType type = event.type(); 179 const ui::EventType type = event.type();
168 180
169 if (type == ui::ET_TOUCH_PRESSED) { 181 if (type == ui::ET_TOUCH_PRESSED) {
170 // Adding a second finger within the timeout period switches to 182 // Adding a second finger within the timeout period switches to
171 // passthrough. 183 // passthrough.
172 state_ = PASSTHROUGH_MINUS_ONE; 184 state_ = PASSTHROUGH_MINUS_ONE;
173 VLOG_STATE(); 185 VLOG_STATE();
174 return InPassthroughMinusOne(event, rewritten_event); 186 return InPassthroughMinusOne(event, rewritten_event);
175 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { 187 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
176 DCHECK_EQ(0U, current_touch_ids_.size()); 188 DCHECK_EQ(0U, current_touch_ids_.size());
177 state_ = SINGLE_TAP_RELEASED; 189 state_ = SINGLE_TAP_RELEASED;
178 VLOG_STATE(); 190 VLOG_STATE();
179 return EVENT_REWRITE_DISCARD; 191 return EVENT_REWRITE_DISCARD;
180 } else if (type == ui::ET_TOUCH_MOVED) { 192 } else if (type == ui::ET_TOUCH_MOVED) {
181 // If the user moves far enough from the initial touch location (outside 193 float delta_time =
182 // the "slop" region, jump to the touch exploration mode early. 194 (event.time_stamp() - initial_press_->time_stamp()).InSecondsF();
183 // TODO(evy, lisayin): Add gesture recognition here instead - 195 float delta_distance =
184 // we should probably jump to gesture mode here if the velocity is 196 (event.location() - initial_press_->location()).Length();
185 // high enough, and touch exploration if the velocity is lower. 197 float velocity = delta_distance / delta_time;
186 float delta = (event.location() - initial_press_->location()).Length(); 198 VLOG(0) << "\n Delta time: " << delta_time
187 if (delta > gesture_detector_config_.touch_slop) { 199 << "\n Delta distance: " << delta_distance
188 EnterTouchToMouseMode(); 200 << "\n Velocity of click: " << velocity
189 state_ = TOUCH_EXPLORATION; 201 << "\n Minimum swipe velocity: "
202 << gesture_detector_config_.minimum_swipe_velocity;
203 if (delta_distance <= gesture_detector_config_.touch_slop)
204 return EVENT_REWRITE_DISCARD;
205
206 // If the user moves fast enough and far enough
207 // from the initial touch location, start gesture detection.
208 // Otherwise, if the user moves far enough from the initial touch location
209 // outside the "slop" region, jump to the touch exploration mode early.
210 if (velocity > gesture_detector_config_.minimum_swipe_velocity) {
211 state_ = GESTURE_IN_PROGRESS;
190 VLOG_STATE(); 212 VLOG_STATE();
191 return InTouchExploration(event, rewritten_event); 213 return InGestureInProgress(event, rewritten_event);
192 } 214 }
193 215 EnterTouchToMouseMode();
194 return EVENT_REWRITE_DISCARD; 216 state_ = TOUCH_EXPLORATION;
217 VLOG_STATE();
218 return InTouchExploration(event, rewritten_event);
195 } 219 }
196 NOTREACHED() << "Unexpected event type received."; 220 NOTREACHED() << "Unexpected event type received.";
197 return ui::EVENT_REWRITE_CONTINUE; 221 return ui::EVENT_REWRITE_CONTINUE;
198 } 222 }
199 223
200 ui::EventRewriteStatus 224 ui::EventRewriteStatus
201 TouchExplorationController::InSingleTapOrTouchExploreReleased( 225 TouchExplorationController::InSingleTapOrTouchExploreReleased(
202 const ui::TouchEvent& event, 226 const ui::TouchEvent& event,
203 scoped_ptr<ui::Event>* rewritten_event) { 227 scoped_ptr<ui::Event>* rewritten_event) {
204 const ui::EventType type = event.type(); 228 const ui::EventType type = event.type();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 NOTREACHED() << "Unexpected event type received."; 309 NOTREACHED() << "Unexpected event type received.";
286 return ui::EVENT_REWRITE_CONTINUE; 310 return ui::EVENT_REWRITE_CONTINUE;
287 } 311 }
288 312
289 // Rewrite as a mouse-move event. 313 // Rewrite as a mouse-move event.
290 *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags()); 314 *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags());
291 last_touch_exploration_.reset(new TouchEvent(event)); 315 last_touch_exploration_.reset(new TouchEvent(event));
292 return ui::EVENT_REWRITE_REWRITTEN; 316 return ui::EVENT_REWRITE_REWRITTEN;
293 } 317 }
294 318
319 ui::EventRewriteStatus TouchExplorationController::InGestureInProgress(
320 const ui::TouchEvent& event,
321 scoped_ptr<ui::Event>* rewritten_event) {
322 ui::EventType type = event.type();
323 if (type == ui::ET_TOUCH_PRESSED ||
324 event.touch_id() != initial_press_->touch_id()) {
325 return ui::EVENT_REWRITE_DISCARD;
326 }
327 if (type == ui::ET_TOUCH_MOVED) {
328 gesture_provider_.OnTouchEvent(event);
329 gesture_provider_.OnTouchEventAck(false);
330 }
331 if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
332 gesture_provider_.OnTouchEvent(event);
333 gesture_provider_.OnTouchEventAck(false);
334 if (current_touch_ids_.size() == 0)
335 ResetToNoFingersDown();
336 }
337 return ui::EVENT_REWRITE_DISCARD;
338 }
339
295 ui::EventRewriteStatus TouchExplorationController::InPassthroughMinusOne( 340 ui::EventRewriteStatus TouchExplorationController::InPassthroughMinusOne(
296 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { 341 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) {
297 ui::EventType type = event.type(); 342 ui::EventType type = event.type();
298 gfx::PointF location = event.location_f(); 343 gfx::PointF location = event.location_f();
299 344
300 if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { 345 if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
301 if (current_touch_ids_.size() == 0) 346 if (current_touch_ids_.size() == 0)
302 ResetToNoFingersDown(); 347 ResetToNoFingersDown();
303 348
304 if (initial_touch_id_passthrough_mapping_ == kTouchIdUnassigned) { 349 if (initial_touch_id_passthrough_mapping_ == kTouchIdUnassigned) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 void TouchExplorationController::OnTapTimerFired() { 431 void TouchExplorationController::OnTapTimerFired() {
387 switch (state_) { 432 switch (state_) {
388 case SINGLE_TAP_RELEASED: 433 case SINGLE_TAP_RELEASED:
389 ResetToNoFingersDown(); 434 ResetToNoFingersDown();
390 break; 435 break;
391 case TOUCH_EXPLORE_RELEASED: 436 case TOUCH_EXPLORE_RELEASED:
392 ResetToNoFingersDown(); 437 ResetToNoFingersDown();
393 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); 438 last_touch_exploration_.reset(new TouchEvent(*initial_press_));
394 return; 439 return;
395 case SINGLE_TAP_PRESSED: 440 case SINGLE_TAP_PRESSED:
441 case GESTURE_IN_PROGRESS:
396 EnterTouchToMouseMode(); 442 EnterTouchToMouseMode();
443 // Discard any pending gestures.
444 delete gesture_provider_.GetAndResetPendingGestures();
397 state_ = TOUCH_EXPLORATION; 445 state_ = TOUCH_EXPLORATION;
398 VLOG_STATE(); 446 VLOG_STATE();
399 break; 447 break;
400 default: 448 default:
401 return; 449 return;
402 } 450 }
403 451
404 scoped_ptr<ui::Event> mouse_move = CreateMouseMoveEvent( 452 scoped_ptr<ui::Event> mouse_move = CreateMouseMoveEvent(
405 initial_press_->location(), initial_press_->flags()); 453 initial_press_->location(), initial_press_->flags());
406 DispatchEvent(mouse_move.get()); 454 DispatchEvent(mouse_move.get());
407 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); 455 last_touch_exploration_.reset(new TouchEvent(*initial_press_));
408 } 456 }
409 457
410 void TouchExplorationController::DispatchEvent(ui::Event* event) { 458 void TouchExplorationController::DispatchEvent(ui::Event* event) {
411 if (event_handler_for_testing_) { 459 if (event_handler_for_testing_) {
412 event_handler_for_testing_->OnEvent(event); 460 event_handler_for_testing_->OnEvent(event);
413 return; 461 return;
414 } 462 }
415 463
416 ui::EventDispatchDetails result ALLOW_UNUSED = 464 ui::EventDispatchDetails result ALLOW_UNUSED =
417 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); 465 root_window_->GetHost()->dispatcher()->OnEventFromSource(event);
418 } 466 }
419 467
468 void TouchExplorationController::OnGestureEvent(ui::GestureEvent* gesture) {
469 CHECK(gesture->IsGestureEvent());
470 VLOG(0) << " \n Gesture Triggered: " << gesture->name();
471 if (tap_timer_.IsRunning())
472 tap_timer_.Stop();
473 if (gesture->type() == ui::ET_GESTURE_SWIPE) {
474 OnSwipeEvent(gesture);
475 return;
476 }
477
478 if (current_touch_ids_.size() != 0) {
479 EnterTouchToMouseMode();
480 state_ = TOUCH_EXPLORATION;
481 } else {
482 ResetToNoFingersDown();
483 }
484 }
485
486 void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) {
487 // A swipe gesture contains details for the direction in which the swipe
488 // occurred.
489 GestureEventDetails event_details = swipe_gesture->details();
490 if (event_details.swipe_left()) {
491 DispatchShiftSearchKeyEvent(ui::VKEY_LEFT);
492 return;
493 } else if (event_details.swipe_right()) {
494 DispatchShiftSearchKeyEvent(ui::VKEY_RIGHT);
495 return;
496 } else if (event_details.swipe_up()) {
497 DispatchShiftSearchKeyEvent(ui::VKEY_UP);
498 return;
499 } else if (event_details.swipe_down()) {
500 DispatchShiftSearchKeyEvent(ui::VKEY_DOWN);
501 return;
502 }
503 }
504
505 void TouchExplorationController::DispatchShiftSearchKeyEvent(
506 const ui::KeyboardCode direction) {
507 // In order to activate the shortcut shift+search+<arrow key>
508 // three KeyPressed events must be dispatched in succession along
509 // with three KeyReleased events.
510 DispatchEvent(new ui::KeyEvent(
511 ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN, false));
512 DispatchEvent(new ui::KeyEvent(
513 ui::ET_KEY_PRESSED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN, false));
514 DispatchEvent(new ui::KeyEvent(
515 ui::ET_KEY_PRESSED, direction, ui::EF_SHIFT_DOWN, false));
516
517 DispatchEvent(new ui::KeyEvent(
518 ui::ET_KEY_RELEASED, direction, ui::EF_SHIFT_DOWN, false));
519 DispatchEvent(new ui::KeyEvent(
520 ui::ET_KEY_RELEASED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN, false));
521 DispatchEvent(new ui::KeyEvent(
522 ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, ui::EF_NONE, false));
523 }
524
420 scoped_ptr<ui::Event> TouchExplorationController::CreateMouseMoveEvent( 525 scoped_ptr<ui::Event> TouchExplorationController::CreateMouseMoveEvent(
421 const gfx::PointF& location, 526 const gfx::PointF& location,
422 int flags) { 527 int flags) {
423 return scoped_ptr<ui::Event>( 528 return scoped_ptr<ui::Event>(
424 new ui::MouseEvent( 529 new ui::MouseEvent(
425 ui::ET_MOUSE_MOVED, 530 ui::ET_MOUSE_MOVED,
426 location, 531 location,
427 location, 532 location,
428 flags | ui::EF_IS_SYNTHESIZED | ui::EF_TOUCH_ACCESSIBILITY, 533 flags | ui::EF_IS_SYNTHESIZED | ui::EF_TOUCH_ACCESSIBILITY,
429 0)); 534 0));
430 } 535 }
431 536
432 void TouchExplorationController::EnterTouchToMouseMode() { 537 void TouchExplorationController::EnterTouchToMouseMode() {
433 aura::client::CursorClient* cursor_client = 538 aura::client::CursorClient* cursor_client =
434 aura::client::GetCursorClient(root_window_); 539 aura::client::GetCursorClient(root_window_);
435 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) 540 if (cursor_client && !cursor_client->IsMouseEventsEnabled())
436 cursor_client->EnableMouseEvents(); 541 cursor_client->EnableMouseEvents();
437 if (cursor_client && cursor_client->IsCursorVisible()) 542 if (cursor_client && cursor_client->IsCursorVisible())
438 cursor_client->HideCursor(); 543 cursor_client->HideCursor();
439 } 544 }
440 545
441 void TouchExplorationController::ResetToNoFingersDown() { 546 void TouchExplorationController::ResetToNoFingersDown() {
547 scoped_ptr<ScopedVector<ui::GestureEvent> > gestures;
548 gestures.reset(gesture_provider_.GetAndResetPendingGestures());
549 if (gestures != NULL) {
550 for (ScopedVector<GestureEvent>::iterator i = gestures->begin();
551 i != gestures->end();
552 ++i) {
553 OnGestureEvent(*i);
554 }
555 }
442 state_ = NO_FINGERS_DOWN; 556 state_ = NO_FINGERS_DOWN;
443 initial_touch_id_passthrough_mapping_ = kTouchIdUnassigned; 557 initial_touch_id_passthrough_mapping_ = kTouchIdUnassigned;
444 VLOG_STATE(); 558 VLOG_STATE();
445 if (tap_timer_.IsRunning()) 559 if (tap_timer_.IsRunning())
446 tap_timer_.Stop(); 560 tap_timer_.Stop();
447 } 561 }
448 562
449 void TouchExplorationController::VlogState(const char* function_name) { 563 void TouchExplorationController::VlogState(const char* function_name) {
450 if (prev_state_ == state_) 564 if (prev_state_ == state_)
451 return; 565 return;
(...skipping 28 matching lines...) Expand all
480 case SINGLE_TAP_PRESSED: 594 case SINGLE_TAP_PRESSED:
481 return "SINGLE_TAP_PRESSED"; 595 return "SINGLE_TAP_PRESSED";
482 case SINGLE_TAP_RELEASED: 596 case SINGLE_TAP_RELEASED:
483 return "SINGLE_TAP_RELEASED"; 597 return "SINGLE_TAP_RELEASED";
484 case TOUCH_EXPLORE_RELEASED: 598 case TOUCH_EXPLORE_RELEASED:
485 return "TOUCH_EXPLORE_RELEASED"; 599 return "TOUCH_EXPLORE_RELEASED";
486 case DOUBLE_TAP_PRESSED: 600 case DOUBLE_TAP_PRESSED:
487 return "DOUBLE_TAP_PRESSED"; 601 return "DOUBLE_TAP_PRESSED";
488 case TOUCH_EXPLORATION: 602 case TOUCH_EXPLORATION:
489 return "TOUCH_EXPLORATION"; 603 return "TOUCH_EXPLORATION";
604 case GESTURE_IN_PROGRESS:
605 return "GESTURE_IN_PROGRESS";
490 case PASSTHROUGH_MINUS_ONE: 606 case PASSTHROUGH_MINUS_ONE:
491 return "PASSTHROUGH_MINUS_ONE"; 607 return "PASSTHROUGH_MINUS_ONE";
492 case TOUCH_EXPLORE_SECOND_PRESS: 608 case TOUCH_EXPLORE_SECOND_PRESS:
493 return "TOUCH_EXPLORE_SECOND_PRESS"; 609 return "TOUCH_EXPLORE_SECOND_PRESS";
494 } 610 }
495 return "Not a state"; 611 return "Not a state";
496 } 612 }
497 613
498 std::string TouchExplorationController::EnumEventTypeToString( 614 std::string TouchExplorationController::EnumEventTypeToString(
499 ui::EventType type) { 615 ui::EventType type) {
500 // Add more cases later. For now, these are the most frequently seen 616 // Add more cases later. For now, these are the most frequently seen
501 // event types. 617 // event types.
502 switch (type) { 618 switch (type) {
503 case ET_TOUCH_RELEASED: 619 case ET_TOUCH_RELEASED:
504 return "ET_TOUCH_RELEASED"; 620 return "ET_TOUCH_RELEASED";
505 case ET_TOUCH_PRESSED: 621 case ET_TOUCH_PRESSED:
506 return "ET_TOUCH_PRESSED"; 622 return "ET_TOUCH_PRESSED";
507 case ET_TOUCH_MOVED: 623 case ET_TOUCH_MOVED:
508 return "ET_TOUCH_MOVED"; 624 return "ET_TOUCH_MOVED";
509 case ET_TOUCH_CANCELLED: 625 case ET_TOUCH_CANCELLED:
510 return "ET_TOUCH_CANCELLED"; 626 return "ET_TOUCH_CANCELLED";
511 default: 627 default:
512 return base::IntToString(type); 628 return base::IntToString(type);
513 } 629 }
514 } 630 }
515 631
516 } // namespace ui 632 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698