| 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 "base/time/default_tick_clock.h" | 
| 10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" | 
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 358     if (delta > gesture_detector_config_.touch_slop) { | 358     if (delta > gesture_detector_config_.touch_slop) { | 
| 359       tap_timer_.Stop(); | 359       tap_timer_.Stop(); | 
| 360       OnTapTimerFired(); | 360       OnTapTimerFired(); | 
| 361     } | 361     } | 
| 362     return EVENT_REWRITE_DISCARD; | 362     return EVENT_REWRITE_DISCARD; | 
| 363   } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 363   } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 
| 364     if (current_touch_ids_.size() != 0) | 364     if (current_touch_ids_.size() != 0) | 
| 365       return EVENT_REWRITE_DISCARD; | 365       return EVENT_REWRITE_DISCARD; | 
| 366 | 366 | 
| 367     scoped_ptr<ui::TouchEvent> touch_press; | 367     scoped_ptr<ui::TouchEvent> touch_press; | 
| 368     touch_press.reset(new ui::TouchEvent( | 368     touch_press.reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), | 
| 369         ui::ET_TOUCH_PRESSED, last_touch_exploration_->location_f(), | 369                                          initial_press_->touch_id(), | 
| 370         initial_press_->touch_id(), event.time_stamp())); | 370                                          event.time_stamp())); | 
|  | 371     touch_press->set_location_f(last_touch_exploration_->location_f()); | 
|  | 372     touch_press->set_root_location_f(last_touch_exploration_->location_f()); | 
| 371     DispatchEvent(touch_press.get()); | 373     DispatchEvent(touch_press.get()); | 
| 372 | 374 | 
| 373     rewritten_event->reset(new ui::TouchEvent( | 375     scoped_ptr<ui::TouchEvent> new_event( | 
| 374         ui::ET_TOUCH_RELEASED, last_touch_exploration_->location_f(), | 376         new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), | 
| 375         initial_press_->touch_id(), event.time_stamp())); | 377                            initial_press_->touch_id(), event.time_stamp())); | 
| 376     (*rewritten_event)->set_flags(event.flags()); | 378     new_event->set_location_f(last_touch_exploration_->location_f()); | 
|  | 379     new_event->set_root_location_f(last_touch_exploration_->location_f()); | 
|  | 380     new_event->set_flags(event.flags()); | 
|  | 381     *rewritten_event = new_event.Pass(); | 
| 377     SET_STATE(NO_FINGERS_DOWN); | 382     SET_STATE(NO_FINGERS_DOWN); | 
| 378     return ui::EVENT_REWRITE_REWRITTEN; | 383     return ui::EVENT_REWRITE_REWRITTEN; | 
| 379   } | 384   } | 
| 380   NOTREACHED(); | 385   NOTREACHED(); | 
| 381   return ui::EVENT_REWRITE_CONTINUE; | 386   return ui::EVENT_REWRITE_CONTINUE; | 
| 382 } | 387 } | 
| 383 | 388 | 
| 384 ui::EventRewriteStatus TouchExplorationController::InTouchReleasePending( | 389 ui::EventRewriteStatus TouchExplorationController::InTouchReleasePending( | 
| 385     const ui::TouchEvent& event, | 390     const ui::TouchEvent& event, | 
| 386     scoped_ptr<ui::Event>* rewritten_event) { | 391     scoped_ptr<ui::Event>* rewritten_event) { | 
| 387   const ui::EventType type = event.type(); | 392   const ui::EventType type = event.type(); | 
| 388   if (type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED) { | 393   if (type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED) { | 
| 389     return ui::EVENT_REWRITE_DISCARD; | 394     return ui::EVENT_REWRITE_DISCARD; | 
| 390   } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 395   } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 
| 391     if (current_touch_ids_.size() != 0) | 396     if (current_touch_ids_.size() != 0) | 
| 392       return EVENT_REWRITE_DISCARD; | 397       return EVENT_REWRITE_DISCARD; | 
| 393 | 398 | 
| 394     rewritten_event->reset(new ui::TouchEvent( | 399     scoped_ptr<ui::TouchEvent> new_event( | 
| 395         ui::ET_TOUCH_RELEASED, last_touch_exploration_->location_f(), | 400         new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), | 
| 396         initial_press_->touch_id(), event.time_stamp())); | 401                            initial_press_->touch_id(), event.time_stamp())); | 
| 397     (*rewritten_event)->set_flags(event.flags()); | 402     new_event->set_location_f(last_touch_exploration_->location_f()); | 
|  | 403     new_event->set_root_location_f(last_touch_exploration_->location_f()); | 
|  | 404     new_event->set_flags(event.flags()); | 
|  | 405     *rewritten_event = new_event.Pass(); | 
| 398     SET_STATE(NO_FINGERS_DOWN); | 406     SET_STATE(NO_FINGERS_DOWN); | 
| 399     return ui::EVENT_REWRITE_REWRITTEN; | 407     return ui::EVENT_REWRITE_REWRITTEN; | 
| 400   } | 408   } | 
| 401   NOTREACHED(); | 409   NOTREACHED(); | 
| 402   return ui::EVENT_REWRITE_CONTINUE; | 410   return ui::EVENT_REWRITE_CONTINUE; | 
| 403 } | 411 } | 
| 404 | 412 | 
| 405 ui::EventRewriteStatus TouchExplorationController::InTouchExploration( | 413 ui::EventRewriteStatus TouchExplorationController::InTouchExploration( | 
| 406     const ui::TouchEvent& event, | 414     const ui::TouchEvent& event, | 
| 407     scoped_ptr<ui::Event>* rewritten_event) { | 415     scoped_ptr<ui::Event>* rewritten_event) { | 
| 408   const ui::EventType type = event.type(); | 416   const ui::EventType type = event.type(); | 
| 409   if (type == ui::ET_TOUCH_PRESSED) { | 417   if (type == ui::ET_TOUCH_PRESSED) { | 
| 410     // Handle split-tap. | 418     // Handle split-tap. | 
| 411     initial_press_.reset(new TouchEvent(event)); | 419     initial_press_.reset(new TouchEvent(event)); | 
| 412     tap_timer_.Stop(); | 420     tap_timer_.Stop(); | 
| 413     rewritten_event->reset(new ui::TouchEvent( | 421     scoped_ptr<ui::TouchEvent> new_event( | 
| 414         ui::ET_TOUCH_PRESSED, last_touch_exploration_->location_f(), | 422         new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), event.touch_id(), | 
| 415         event.touch_id(), event.time_stamp())); | 423                            event.time_stamp())); | 
| 416     (*rewritten_event)->set_flags(event.flags()); | 424     new_event->set_location_f(last_touch_exploration_->location_f()); | 
|  | 425     new_event->set_root_location_f(last_touch_exploration_->location_f()); | 
|  | 426     new_event->set_flags(event.flags()); | 
|  | 427     *rewritten_event = new_event.Pass(); | 
| 417     SET_STATE(TOUCH_EXPLORE_SECOND_PRESS); | 428     SET_STATE(TOUCH_EXPLORE_SECOND_PRESS); | 
| 418     return ui::EVENT_REWRITE_REWRITTEN; | 429     return ui::EVENT_REWRITE_REWRITTEN; | 
| 419   } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 430   } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 
| 420     initial_press_.reset(new TouchEvent(event)); | 431     initial_press_.reset(new TouchEvent(event)); | 
| 421     StartTapTimer(); | 432     StartTapTimer(); | 
| 422     SET_STATE(TOUCH_EXPLORE_RELEASED); | 433     SET_STATE(TOUCH_EXPLORE_RELEASED); | 
| 423   } else if (type != ui::ET_TOUCH_MOVED) { | 434   } else if (type != ui::ET_TOUCH_MOVED) { | 
| 424     NOTREACHED(); | 435     NOTREACHED(); | 
| 425     return ui::EVENT_REWRITE_CONTINUE; | 436     return ui::EVENT_REWRITE_CONTINUE; | 
| 426   } | 437   } | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 458       return ui::EVENT_REWRITE_DISCARD; | 469       return ui::EVENT_REWRITE_DISCARD; | 
| 459 | 470 | 
| 460     if (current_touch_ids_.size() == 0) { | 471     if (current_touch_ids_.size() == 0) { | 
| 461       SET_STATE(NO_FINGERS_DOWN); | 472       SET_STATE(NO_FINGERS_DOWN); | 
| 462       return ui::EVENT_REWRITE_DISCARD; | 473       return ui::EVENT_REWRITE_DISCARD; | 
| 463     } | 474     } | 
| 464     SET_STATE(WAIT_FOR_NO_FINGERS); | 475     SET_STATE(WAIT_FOR_NO_FINGERS); | 
| 465     return ui::EVENT_REWRITE_DISCARD; | 476     return ui::EVENT_REWRITE_DISCARD; | 
| 466   } | 477   } | 
| 467 | 478 | 
| 468   rewritten_event->reset(new ui::TouchEvent( | 479   scoped_ptr<ui::TouchEvent> new_event(new ui::TouchEvent( | 
| 469       type, event.location_f(), event.touch_id(), event.time_stamp())); | 480       type, gfx::Point(), event.touch_id(), event.time_stamp())); | 
| 470   (*rewritten_event)->set_flags(event.flags()); | 481   new_event->set_location_f(event.location_f()); | 
|  | 482   new_event->set_root_location_f(event.location_f()); | 
|  | 483   new_event->set_flags(event.flags()); | 
|  | 484   *rewritten_event = new_event.Pass(); | 
| 471 | 485 | 
| 472   if (current_touch_ids_.size() == 0) | 486   if (current_touch_ids_.size() == 0) | 
| 473     SET_STATE(NO_FINGERS_DOWN); | 487     SET_STATE(NO_FINGERS_DOWN); | 
| 474 | 488 | 
| 475   return ui::EVENT_REWRITE_REWRITTEN; | 489   return ui::EVENT_REWRITE_REWRITTEN; | 
| 476 } | 490 } | 
| 477 | 491 | 
| 478 ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough( | 492 ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough( | 
| 479     const ui::TouchEvent& event, | 493     const ui::TouchEvent& event, | 
| 480     scoped_ptr<ui::Event>* rewritten_event) { | 494     scoped_ptr<ui::Event>* rewritten_event) { | 
| 481   if (event.touch_id() != initial_press_->touch_id()) { | 495   if (event.touch_id() != initial_press_->touch_id()) { | 
| 482     if (current_touch_ids_.size() == 0) { | 496     if (current_touch_ids_.size() == 0) { | 
| 483       SET_STATE(NO_FINGERS_DOWN); | 497       SET_STATE(NO_FINGERS_DOWN); | 
| 484     } | 498     } | 
| 485     return ui::EVENT_REWRITE_DISCARD; | 499     return ui::EVENT_REWRITE_DISCARD; | 
| 486   } | 500   } | 
| 487   rewritten_event->reset( | 501   scoped_ptr<ui::TouchEvent> new_event(new ui::TouchEvent( | 
| 488       new ui::TouchEvent(event.type(), event.location_f() - passthrough_offset_, | 502       event.type(), gfx::Point(), event.touch_id(), event.time_stamp())); | 
| 489                          event.touch_id(), event.time_stamp())); | 503   new_event->set_location_f(event.location_f() - passthrough_offset_); | 
| 490 | 504   new_event->set_root_location_f(event.location_f() - passthrough_offset_); | 
| 491   (*rewritten_event)->set_flags(event.flags()); | 505   new_event->set_flags(event.flags()); | 
|  | 506   *rewritten_event = new_event.Pass(); | 
| 492   if (current_touch_ids_.size() == 0) { | 507   if (current_touch_ids_.size() == 0) { | 
| 493     SET_STATE(NO_FINGERS_DOWN); | 508     SET_STATE(NO_FINGERS_DOWN); | 
| 494   } | 509   } | 
| 495   return ui::EVENT_REWRITE_REWRITTEN; | 510   return ui::EVENT_REWRITE_REWRITTEN; | 
| 496 } | 511 } | 
| 497 | 512 | 
| 498 ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress( | 513 ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress( | 
| 499     const ui::TouchEvent& event, | 514     const ui::TouchEvent& event, | 
| 500     scoped_ptr<ui::Event>* rewritten_event) { | 515     scoped_ptr<ui::Event>* rewritten_event) { | 
| 501   ui::EventType type = event.type(); | 516   ui::EventType type = event.type(); | 
| 502   gfx::PointF location = event.location_f(); | 517   gfx::PointF location = event.location_f(); | 
| 503   if (type == ui::ET_TOUCH_PRESSED) { | 518   if (type == ui::ET_TOUCH_PRESSED) { | 
| 504     // A third finger being pressed means that a split tap can no longer go | 519     // A third finger being pressed means that a split tap can no longer go | 
| 505     // through. The user enters the wait state, Since there has already been | 520     // through. The user enters the wait state, Since there has already been | 
| 506     // a press dispatched when split tap began, the touch needs to be | 521     // a press dispatched when split tap began, the touch needs to be | 
| 507     // cancelled. | 522     // cancelled. | 
| 508     rewritten_event->reset(new ui::TouchEvent( | 523     scoped_ptr<ui::TouchEvent> new_event( | 
| 509         ui::ET_TOUCH_CANCELLED, last_touch_exploration_->location_f(), | 524         new ui::TouchEvent(ui::ET_TOUCH_CANCELLED, gfx::Point(), | 
| 510         initial_press_->touch_id(), event.time_stamp())); | 525                            initial_press_->touch_id(), event.time_stamp())); | 
| 511     (*rewritten_event)->set_flags(event.flags()); | 526     new_event->set_location_f(last_touch_exploration_->location_f()); | 
|  | 527     new_event->set_root_location_f(last_touch_exploration_->location_f()); | 
|  | 528     new_event->set_flags(event.flags()); | 
|  | 529     *rewritten_event = new_event.Pass(); | 
| 512     SET_STATE(WAIT_FOR_NO_FINGERS); | 530     SET_STATE(WAIT_FOR_NO_FINGERS); | 
| 513     return ui::EVENT_REWRITE_REWRITTEN; | 531     return ui::EVENT_REWRITE_REWRITTEN; | 
| 514   } else if (type == ui::ET_TOUCH_MOVED) { | 532   } else if (type == ui::ET_TOUCH_MOVED) { | 
| 515     // If the fingers have moved too far from their original locations, | 533     // If the fingers have moved too far from their original locations, | 
| 516     // the user can no longer split tap. | 534     // the user can no longer split tap. | 
| 517     ui::TouchEvent* original_touch; | 535     ui::TouchEvent* original_touch; | 
| 518     if (event.touch_id() == last_touch_exploration_->touch_id()) { | 536     if (event.touch_id() == last_touch_exploration_->touch_id()) { | 
| 519       original_touch = last_touch_exploration_.get(); | 537       original_touch = last_touch_exploration_.get(); | 
| 520     } else if (event.touch_id() == initial_press_->touch_id()) { | 538     } else if (event.touch_id() == initial_press_->touch_id()) { | 
| 521       original_touch = initial_press_.get(); | 539       original_touch = initial_press_.get(); | 
| 522     } else { | 540     } else { | 
| 523       NOTREACHED(); | 541       NOTREACHED(); | 
| 524       SET_STATE(WAIT_FOR_NO_FINGERS); | 542       SET_STATE(WAIT_FOR_NO_FINGERS); | 
| 525       return ui::EVENT_REWRITE_DISCARD; | 543       return ui::EVENT_REWRITE_DISCARD; | 
| 526     } | 544     } | 
| 527     // Check the distance between the current finger location and the original | 545     // Check the distance between the current finger location and the original | 
| 528     // location. The slop for this is a bit more generous since keeping two | 546     // location. The slop for this is a bit more generous since keeping two | 
| 529     // fingers in place is a bit harder. If the user has left the slop, the | 547     // fingers in place is a bit harder. If the user has left the slop, the | 
| 530     // split tap press (which was previous dispatched) is lifted with a touch | 548     // split tap press (which was previous dispatched) is lifted with a touch | 
| 531     // cancelled, and the user enters the wait state. | 549     // cancelled, and the user enters the wait state. | 
| 532     if ((event.location_f() - original_touch->location_f()).Length() > | 550     if ((event.location_f() - original_touch->location_f()).Length() > | 
| 533         GetSplitTapTouchSlop()) { | 551         GetSplitTapTouchSlop()) { | 
| 534       rewritten_event->reset(new ui::TouchEvent( | 552       scoped_ptr<ui::TouchEvent> new_event( | 
| 535           ui::ET_TOUCH_CANCELLED, last_touch_exploration_->location_f(), | 553           new ui::TouchEvent(ui::ET_TOUCH_CANCELLED, gfx::Point(), | 
| 536           initial_press_->touch_id(), event.time_stamp())); | 554                              initial_press_->touch_id(), event.time_stamp())); | 
| 537       (*rewritten_event)->set_flags(event.flags()); | 555       new_event->set_location_f(last_touch_exploration_->location_f()); | 
|  | 556       new_event->set_root_location_f(last_touch_exploration_->location_f()); | 
|  | 557       new_event->set_flags(event.flags()); | 
|  | 558       *rewritten_event = new_event.Pass(); | 
| 538       SET_STATE(WAIT_FOR_NO_FINGERS); | 559       SET_STATE(WAIT_FOR_NO_FINGERS); | 
| 539       return ui::EVENT_REWRITE_REWRITTEN; | 560       return ui::EVENT_REWRITE_REWRITTEN; | 
| 540     } | 561     } | 
| 541     return ui::EVENT_REWRITE_DISCARD; | 562     return ui::EVENT_REWRITE_DISCARD; | 
| 542   } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 563   } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 
| 543     // If the touch exploration finger is lifted, there is no option to return | 564     // If the touch exploration finger is lifted, there is no option to return | 
| 544     // to touch explore anymore. The remaining finger acts as a pending | 565     // to touch explore anymore. The remaining finger acts as a pending | 
| 545     // tap or long tap for the last touch explore location. | 566     // tap or long tap for the last touch explore location. | 
| 546     if (event.touch_id() == last_touch_exploration_->touch_id()) { | 567     if (event.touch_id() == last_touch_exploration_->touch_id()) { | 
| 547       SET_STATE(TOUCH_RELEASE_PENDING); | 568       SET_STATE(TOUCH_RELEASE_PENDING); | 
| 548       return EVENT_REWRITE_DISCARD; | 569       return EVENT_REWRITE_DISCARD; | 
| 549     } | 570     } | 
| 550 | 571 | 
| 551     // Continue to release the touch only if the touch explore finger is the | 572     // Continue to release the touch only if the touch explore finger is the | 
| 552     // only finger remaining. | 573     // only finger remaining. | 
| 553     if (current_touch_ids_.size() != 1) | 574     if (current_touch_ids_.size() != 1) | 
| 554       return EVENT_REWRITE_DISCARD; | 575       return EVENT_REWRITE_DISCARD; | 
| 555 | 576 | 
| 556     // Rewrite at location of last touch exploration. | 577     // Rewrite at location of last touch exploration. | 
| 557     rewritten_event->reset(new ui::TouchEvent( | 578     scoped_ptr<ui::TouchEvent> new_event( | 
| 558         ui::ET_TOUCH_RELEASED, last_touch_exploration_->location_f(), | 579         new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), | 
| 559         initial_press_->touch_id(), event.time_stamp())); | 580                            initial_press_->touch_id(), event.time_stamp())); | 
| 560     (*rewritten_event)->set_flags(event.flags()); | 581     new_event->set_location_f(last_touch_exploration_->location_f()); | 
|  | 582     new_event->set_root_location_f(last_touch_exploration_->location_f()); | 
|  | 583     new_event->set_flags(event.flags()); | 
|  | 584     *rewritten_event = new_event.Pass(); | 
| 561     SET_STATE(TOUCH_EXPLORATION); | 585     SET_STATE(TOUCH_EXPLORATION); | 
| 562     EnterTouchToMouseMode(); | 586     EnterTouchToMouseMode(); | 
| 563     return ui::EVENT_REWRITE_REWRITTEN; | 587     return ui::EVENT_REWRITE_REWRITTEN; | 
| 564   } | 588   } | 
| 565   NOTREACHED(); | 589   NOTREACHED(); | 
| 566   return ui::EVENT_REWRITE_CONTINUE; | 590   return ui::EVENT_REWRITE_CONTINUE; | 
| 567 } | 591 } | 
| 568 | 592 | 
| 569 ui::EventRewriteStatus TouchExplorationController::InWaitForNoFingers( | 593 ui::EventRewriteStatus TouchExplorationController::InWaitForNoFingers( | 
| 570     const ui::TouchEvent& event, | 594     const ui::TouchEvent& event, | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 685       SET_STATE(NO_FINGERS_DOWN); | 709       SET_STATE(NO_FINGERS_DOWN); | 
| 686       break; | 710       break; | 
| 687     case TOUCH_EXPLORE_RELEASED: | 711     case TOUCH_EXPLORE_RELEASED: | 
| 688       SET_STATE(NO_FINGERS_DOWN); | 712       SET_STATE(NO_FINGERS_DOWN); | 
| 689       last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 713       last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 
| 690       return; | 714       return; | 
| 691     case DOUBLE_TAP_PENDING: { | 715     case DOUBLE_TAP_PENDING: { | 
| 692       SET_STATE(ONE_FINGER_PASSTHROUGH); | 716       SET_STATE(ONE_FINGER_PASSTHROUGH); | 
| 693       passthrough_offset_ = last_unused_finger_event_->location_f() - | 717       passthrough_offset_ = last_unused_finger_event_->location_f() - | 
| 694                             last_touch_exploration_->location_f(); | 718                             last_touch_exploration_->location_f(); | 
| 695       scoped_ptr<ui::TouchEvent> passthrough_press(new ui::TouchEvent( | 719       scoped_ptr<ui::TouchEvent> passthrough_press( | 
| 696           ui::ET_TOUCH_PRESSED, last_touch_exploration_->location_f(), | 720           new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), | 
| 697           last_unused_finger_event_->touch_id(), Now())); | 721                              last_unused_finger_event_->touch_id(), Now())); | 
|  | 722       passthrough_press->set_location_f(last_touch_exploration_->location_f()); | 
|  | 723       passthrough_press->set_root_location_f( | 
|  | 724           last_touch_exploration_->location_f()); | 
| 698       DispatchEvent(passthrough_press.get()); | 725       DispatchEvent(passthrough_press.get()); | 
| 699       return; | 726       return; | 
| 700     } | 727     } | 
| 701     case SINGLE_TAP_PRESSED: | 728     case SINGLE_TAP_PRESSED: | 
| 702       if (passthrough_timer_.IsRunning()) | 729       if (passthrough_timer_.IsRunning()) | 
| 703         return; | 730         return; | 
| 704     case GESTURE_IN_PROGRESS: | 731     case GESTURE_IN_PROGRESS: | 
| 705       // If only one finger is down, go into touch exploration. | 732       // If only one finger is down, go into touch exploration. | 
| 706       if (current_touch_ids_.size() == 1) { | 733       if (current_touch_ids_.size() == 1) { | 
| 707         EnterTouchToMouseMode(); | 734         EnterTouchToMouseMode(); | 
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 936 | 963 | 
| 937 base::Closure TouchExplorationController::BindKeyEventWithFlags( | 964 base::Closure TouchExplorationController::BindKeyEventWithFlags( | 
| 938     const ui::KeyboardCode key, | 965     const ui::KeyboardCode key, | 
| 939     int flags) { | 966     int flags) { | 
| 940   return base::Bind(&TouchExplorationController::DispatchKeyWithFlags, | 967   return base::Bind(&TouchExplorationController::DispatchKeyWithFlags, | 
| 941                     base::Unretained(this), | 968                     base::Unretained(this), | 
| 942                     key, | 969                     key, | 
| 943                     flags); | 970                     flags); | 
| 944 } | 971 } | 
| 945 | 972 | 
| 946 scoped_ptr<ui::Event> TouchExplorationController::CreateMouseMoveEvent( | 973 scoped_ptr<ui::MouseEvent> TouchExplorationController::CreateMouseMoveEvent( | 
| 947     const gfx::PointF& location, | 974     const gfx::PointF& location, | 
| 948     int flags) { | 975     int flags) { | 
| 949   // The "synthesized" flag should be set on all events that don't have a | 976   // The "synthesized" flag should be set on all events that don't have a | 
| 950   // backing native event. | 977   // backing native event. | 
| 951   flags |= ui::EF_IS_SYNTHESIZED; | 978   flags |= ui::EF_IS_SYNTHESIZED; | 
| 952 | 979 | 
| 953   // This flag is used to identify mouse move events that were generated from | 980   // This flag is used to identify mouse move events that were generated from | 
| 954   // touch exploration in Chrome code. | 981   // touch exploration in Chrome code. | 
| 955   flags |= ui::EF_TOUCH_ACCESSIBILITY; | 982   flags |= ui::EF_TOUCH_ACCESSIBILITY; | 
| 956 | 983 | 
| 957   // TODO(dmazzoni) http://crbug.com/391008 - get rid of this hack. | 984   // TODO(dmazzoni) http://crbug.com/391008 - get rid of this hack. | 
| 958   // This is a short-term workaround for the limitation that we're using | 985   // This is a short-term workaround for the limitation that we're using | 
| 959   // the ChromeVox content script to process touch exploration events, but | 986   // the ChromeVox content script to process touch exploration events, but | 
| 960   // ChromeVox needs a way to distinguish between a real mouse move and a | 987   // ChromeVox needs a way to distinguish between a real mouse move and a | 
| 961   // mouse move generated from touch exploration, so we have touch exploration | 988   // mouse move generated from touch exploration, so we have touch exploration | 
| 962   // pretend that the command key was down (which becomes the "meta" key in | 989   // pretend that the command key was down (which becomes the "meta" key in | 
| 963   // JavaScript). We can remove this hack when the ChromeVox content script | 990   // JavaScript). We can remove this hack when the ChromeVox content script | 
| 964   // goes away and native accessibility code sends a touch exploration | 991   // goes away and native accessibility code sends a touch exploration | 
| 965   // event to the new ChromeVox background page via the automation api. | 992   // event to the new ChromeVox background page via the automation api. | 
| 966   flags |= ui::EF_COMMAND_DOWN; | 993   flags |= ui::EF_COMMAND_DOWN; | 
| 967 | 994 | 
| 968   return make_scoped_ptr(new ui::MouseEvent( | 995   scoped_ptr<ui::MouseEvent> event( | 
| 969       ui::ET_MOUSE_MOVED, location, location, ui::EventTimeForNow(), flags, 0)); | 996       new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 
|  | 997                          ui::EventTimeForNow(), flags, 0)); | 
|  | 998   event->set_location_f(location); | 
|  | 999   event->set_root_location_f(location); | 
|  | 1000   return event; | 
| 970 } | 1001 } | 
| 971 | 1002 | 
| 972 void TouchExplorationController::EnterTouchToMouseMode() { | 1003 void TouchExplorationController::EnterTouchToMouseMode() { | 
| 973   aura::client::CursorClient* cursor_client = | 1004   aura::client::CursorClient* cursor_client = | 
| 974       aura::client::GetCursorClient(root_window_); | 1005       aura::client::GetCursorClient(root_window_); | 
| 975   if (cursor_client && !cursor_client->IsMouseEventsEnabled()) | 1006   if (cursor_client && !cursor_client->IsMouseEventsEnabled()) | 
| 976     cursor_client->EnableMouseEvents(); | 1007     cursor_client->EnableMouseEvents(); | 
| 977   if (cursor_client && cursor_client->IsCursorVisible()) | 1008   if (cursor_client && cursor_client->IsCursorVisible()) | 
| 978     cursor_client->HideCursor(); | 1009     cursor_client->HideCursor(); | 
| 979 } | 1010 } | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1127   up_swipe_gestures_[4] = BindKeyEventWithFlags(VKEY_BROWSER_HOME, ui::EF_NONE); | 1158   up_swipe_gestures_[4] = BindKeyEventWithFlags(VKEY_BROWSER_HOME, ui::EF_NONE); | 
| 1128   down_swipe_gestures_[4] = | 1159   down_swipe_gestures_[4] = | 
| 1129       BindKeyEventWithFlags(VKEY_BROWSER_REFRESH, ui::EF_NONE); | 1160       BindKeyEventWithFlags(VKEY_BROWSER_REFRESH, ui::EF_NONE); | 
| 1130 } | 1161 } | 
| 1131 | 1162 | 
| 1132 float TouchExplorationController::GetSplitTapTouchSlop() { | 1163 float TouchExplorationController::GetSplitTapTouchSlop() { | 
| 1133   return gesture_detector_config_.touch_slop * 3; | 1164   return gesture_detector_config_.touch_slop * 3; | 
| 1134 } | 1165 } | 
| 1135 | 1166 | 
| 1136 }  // namespace ui | 1167 }  // namespace ui | 
| OLD | NEW | 
|---|