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 26 matching lines...) Expand all Loading... |
37 aura::Window* root_window) | 37 aura::Window* root_window) |
38 : root_window_(root_window), | 38 : root_window_(root_window), |
39 initial_touch_id_passthrough_mapping_(kTouchIdUnassigned), | 39 initial_touch_id_passthrough_mapping_(kTouchIdUnassigned), |
40 state_(NO_FINGERS_DOWN), | 40 state_(NO_FINGERS_DOWN), |
41 event_handler_for_testing_(NULL), | 41 event_handler_for_testing_(NULL), |
42 prev_state_(NO_FINGERS_DOWN) { | 42 prev_state_(NO_FINGERS_DOWN) { |
43 CHECK(root_window); | 43 CHECK(root_window); |
44 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 44 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
45 } | 45 } |
46 | 46 |
47 | |
48 TouchExplorationController::~TouchExplorationController() { | 47 TouchExplorationController::~TouchExplorationController() { |
49 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 48 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
50 } | 49 } |
51 | 50 |
52 void TouchExplorationController::CallTapTimerNowForTesting() { | 51 void TouchExplorationController::CallTapTimerNowForTesting() { |
53 DCHECK(tap_timer_.IsRunning()); | 52 DCHECK(tap_timer_.IsRunning()); |
54 tap_timer_.Stop(); | 53 tap_timer_.Stop(); |
55 OnTapTimerFired(); | 54 OnTapTimerFired(); |
56 } | 55 } |
57 | 56 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 VLOG_STATE(); | 166 VLOG_STATE(); |
168 return ui::EVENT_REWRITE_DISCARD; | 167 return ui::EVENT_REWRITE_DISCARD; |
169 } | 168 } |
170 NOTREACHED(); | 169 NOTREACHED(); |
171 return ui::EVENT_REWRITE_CONTINUE; | 170 return ui::EVENT_REWRITE_CONTINUE; |
172 } | 171 } |
173 | 172 |
174 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( | 173 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( |
175 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 174 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
176 const ui::EventType type = event.type(); | 175 const ui::EventType type = event.type(); |
177 | |
178 if (type == ui::ET_TOUCH_PRESSED) { | 176 if (type == ui::ET_TOUCH_PRESSED) { |
179 // Adding a second finger within the timeout period switches to | 177 // Adding a second finger within the timeout period switches to |
180 // passthrough. | 178 // passthrough. |
181 state_ = PASSTHROUGH_MINUS_ONE; | 179 state_ = PASSTHROUGH_MINUS_ONE; |
182 VLOG_STATE(); | 180 VLOG_STATE(); |
183 return InPassthroughMinusOne(event, rewritten_event); | 181 return InPassthroughMinusOne(event, rewritten_event); |
184 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 182 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
185 DCHECK_EQ(0U, current_touch_ids_.size()); | 183 DCHECK_EQ(0U, current_touch_ids_.size()); |
186 state_ = SINGLE_TAP_RELEASED; | 184 state_ = SINGLE_TAP_RELEASED; |
187 VLOG_STATE(); | 185 VLOG_STATE(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 return EVENT_REWRITE_DISCARD; | 374 return EVENT_REWRITE_DISCARD; |
377 | 375 |
378 // Rewrite at location of last touch exploration. | 376 // Rewrite at location of last touch exploration. |
379 rewritten_event->reset( | 377 rewritten_event->reset( |
380 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, | 378 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, |
381 last_touch_exploration_->location(), | 379 last_touch_exploration_->location(), |
382 initial_press_->touch_id(), | 380 initial_press_->touch_id(), |
383 event.time_stamp())); | 381 event.time_stamp())); |
384 (*rewritten_event)->set_flags(event.flags()); | 382 (*rewritten_event)->set_flags(event.flags()); |
385 state_ = TOUCH_EXPLORATION; | 383 state_ = TOUCH_EXPLORATION; |
| 384 EnterTouchToMouseMode(); |
386 VLOG_STATE(); | 385 VLOG_STATE(); |
387 return ui::EVENT_REWRITE_REWRITTEN; | 386 return ui::EVENT_REWRITE_REWRITTEN; |
388 } | 387 } |
389 NOTREACHED() << "Unexpected event type received."; | 388 NOTREACHED() << "Unexpected event type received."; |
390 return ui::EVENT_REWRITE_CONTINUE; | 389 return ui::EVENT_REWRITE_CONTINUE; |
391 } | 390 } |
392 | 391 |
393 void TouchExplorationController::OnTapTimerFired() { | 392 void TouchExplorationController::OnTapTimerFired() { |
394 switch (state_) { | 393 switch (state_) { |
395 case SINGLE_TAP_RELEASED: | 394 case SINGLE_TAP_RELEASED: |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 return "TOUCH_EXPLORATION"; | 503 return "TOUCH_EXPLORATION"; |
505 case PASSTHROUGH_MINUS_ONE: | 504 case PASSTHROUGH_MINUS_ONE: |
506 return "PASSTHROUGH_MINUS_ONE"; | 505 return "PASSTHROUGH_MINUS_ONE"; |
507 case TOUCH_EXPLORE_SECOND_PRESS: | 506 case TOUCH_EXPLORE_SECOND_PRESS: |
508 return "TOUCH_EXPLORE_SECOND_PRESS"; | 507 return "TOUCH_EXPLORE_SECOND_PRESS"; |
509 } | 508 } |
510 return "Not a state"; | 509 return "Not a state"; |
511 } | 510 } |
512 | 511 |
513 } // namespace ui | 512 } // namespace ui |
OLD | NEW |