Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #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 28 matching lines...) Expand all Loading... | |
| 39 TouchExplorationController::~TouchExplorationController() { | 39 TouchExplorationController::~TouchExplorationController() { |
| 40 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 40 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void TouchExplorationController::CallTapTimerNowForTesting() { | 43 void TouchExplorationController::CallTapTimerNowForTesting() { |
| 44 DCHECK(tap_timer_.IsRunning()); | 44 DCHECK(tap_timer_.IsRunning()); |
| 45 tap_timer_.Stop(); | 45 tap_timer_.Stop(); |
| 46 OnTapTimerFired(); | 46 OnTapTimerFired(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void TouchExplorationController::CallTapTimerNowIfRunningForTesting() { | 49 void TouchExplorationController::CallTapTimerNowIfRunningForTesting() { |
|
mfomitchev
2014/07/09 19:20:37
Do we really need both of these methods? Seems lik
evy
2014/07/09 19:36:00
The IfRunning version was added in the last CL I c
| |
| 50 if (tap_timer_.IsRunning()) { | 50 if (tap_timer_.IsRunning()) { |
| 51 tap_timer_.Stop(); | 51 tap_timer_.Stop(); |
| 52 OnTapTimerFired(); | 52 OnTapTimerFired(); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 void TouchExplorationController::SetEventHandlerForTesting( | 56 void TouchExplorationController::SetEventHandlerForTesting( |
| 57 ui::EventHandler* event_handler_for_testing) { | 57 ui::EventHandler* event_handler_for_testing) { |
| 58 event_handler_for_testing_ = event_handler_for_testing; | 58 event_handler_for_testing_ = event_handler_for_testing; |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool TouchExplorationController::IsInNoFingersDownStateForTesting() const { | 61 bool TouchExplorationController::IsInNoFingersDownStateForTesting() const { |
| 62 return state_ == NO_FINGERS_DOWN; | 62 return state_ == NO_FINGERS_DOWN; |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool TouchExplorationController::IsInGestureInProgressStateForTesting() const { | 65 bool TouchExplorationController::IsInGestureInProgressStateForTesting() const { |
| 66 return state_ == GESTURE_IN_PROGRESS; | 66 return state_ == GESTURE_IN_PROGRESS; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void TouchExplorationController::SuppressVLOGsForTesting(bool suppress) { | 69 void TouchExplorationController::SuppressVLOGsForTesting(bool suppress) { |
|
mfomitchev
2014/07/09 19:20:37
Why do we need to suppress logging for testing?
P
evy
2014/07/09 19:36:00
Yeah - also part of the permutations test CL.
The
mfomitchev
2014/07/09 20:47:21
Ok. We are starting to get a lot of these ForTesti
evy
2014/07/09 21:32:09
That's a good idea - I think I'll start it in a ne
mfomitchev
2014/07/09 21:53:03
Yup, doing it in a separate CL makes sense. Feel f
evy
2014/07/10 02:44:20
Sounds good - thanks for the suggestion!
| |
| 70 VLOG_on_ = !suppress; | 70 VLOG_on_ = !suppress; |
| 71 } | 71 } |
| 72 | 72 |
| 73 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( | 73 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
| 74 const ui::Event& event, | 74 const ui::Event& event, |
| 75 scoped_ptr<ui::Event>* rewritten_event) { | 75 scoped_ptr<ui::Event>* rewritten_event) { |
| 76 if (!event.IsTouchEvent()) { | 76 if (!event.IsTouchEvent()) { |
| 77 if (event.IsKeyEvent()) { | 77 if (event.IsKeyEvent()) { |
| 78 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | 78 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); |
| 79 VLOG(0) << "\nKeyboard event: " << key_event.name() | 79 VLOG(0) << "\nKeyboard event: " << key_event.name() |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 if (current_touch_ids_.size() != 1) | 495 if (current_touch_ids_.size() != 1) |
| 496 return EVENT_REWRITE_DISCARD; | 496 return EVENT_REWRITE_DISCARD; |
| 497 | 497 |
| 498 // Rewrite at location of last touch exploration. | 498 // Rewrite at location of last touch exploration. |
| 499 rewritten_event->reset( | 499 rewritten_event->reset( |
| 500 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, | 500 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, |
| 501 last_touch_exploration_->location(), | 501 last_touch_exploration_->location(), |
| 502 initial_press_->touch_id(), | 502 initial_press_->touch_id(), |
| 503 event.time_stamp())); | 503 event.time_stamp())); |
| 504 (*rewritten_event)->set_flags(event.flags()); | 504 (*rewritten_event)->set_flags(event.flags()); |
| 505 state_ = TOUCH_EXPLORATION; | |
| 505 EnterTouchToMouseMode(); | 506 EnterTouchToMouseMode(); |
| 506 state_ = TOUCH_EXPLORATION; | |
| 507 VLOG_STATE(); | 507 VLOG_STATE(); |
| 508 return ui::EVENT_REWRITE_REWRITTEN; | 508 return ui::EVENT_REWRITE_REWRITTEN; |
| 509 } | 509 } |
| 510 NOTREACHED() << "Unexpected event type received: " << event.name(); | 510 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 511 return ui::EVENT_REWRITE_CONTINUE; | 511 return ui::EVENT_REWRITE_CONTINUE; |
| 512 } | 512 } |
| 513 | 513 |
| 514 ui::EventRewriteStatus TouchExplorationController::InWaitForRelease( | 514 ui::EventRewriteStatus TouchExplorationController::InWaitForRelease( |
| 515 const ui::TouchEvent& event, | 515 const ui::TouchEvent& event, |
| 516 scoped_ptr<ui::Event>* rewritten_event) { | 516 scoped_ptr<ui::Event>* rewritten_event) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 723 return "TWO_TO_ONE_FINGER"; | 723 return "TWO_TO_ONE_FINGER"; |
| 724 case PASSTHROUGH: | 724 case PASSTHROUGH: |
| 725 return "PASSTHROUGH"; | 725 return "PASSTHROUGH"; |
| 726 case WAIT_FOR_RELEASE: | 726 case WAIT_FOR_RELEASE: |
| 727 return "WAIT_FOR_RELEASE"; | 727 return "WAIT_FOR_RELEASE"; |
| 728 } | 728 } |
| 729 return "Not a state"; | 729 return "Not a state"; |
| 730 } | 730 } |
| 731 | 731 |
| 732 } // namespace ui | 732 } // namespace ui |
| OLD | NEW |