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/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "ui/aura/client/cursor_client.h" | 8 #include "ui/aura/client/cursor_client.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
11 #include "ui/aura/window_tree_host.h" | 11 #include "ui/aura/window_tree_host.h" |
12 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
13 #include "ui/events/event_processor.h" | 13 #include "ui/events/event_processor.h" |
14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
15 | 15 |
16 #define VLOG_STATE() if (VLOG_IS_ON(0)) VlogState(__func__) | 16 #define VLOG_STATE() if (VLOG_IS_ON(0)) VlogState(__func__) |
17 #define VLOG_EVENT(event) if (VLOG_IS_ON(0)) VlogEvent(event, __func__) | 17 #define VLOG_EVENT(event) if (VLOG_IS_ON(0)) VlogEvent(event, __func__) |
18 | 18 |
19 namespace ui { | 19 namespace ui { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 // Delay between adjustment sounds. | 23 // Delay between adjustment sounds. |
24 const base::TimeDelta kSoundDelay = base::TimeDelta::FromMilliseconds(150); | 24 const base::TimeDelta kSoundDelay = base::TimeDelta::FromMilliseconds(150); |
25 | 25 |
| 26 // Delay before corner passthrough activates. |
| 27 const base::TimeDelta kCornerPassthroughDelay = |
| 28 base::TimeDelta::FromMilliseconds(500); |
| 29 |
26 // In ChromeOS, VKEY_LWIN is synonymous for the search key. | 30 // In ChromeOS, VKEY_LWIN is synonymous for the search key. |
27 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN; | 31 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN; |
28 } // namespace | 32 } // namespace |
29 | 33 |
30 TouchExplorationController::TouchExplorationController( | 34 TouchExplorationController::TouchExplorationController( |
31 aura::Window* root_window, | 35 aura::Window* root_window, |
32 TouchExplorationControllerDelegate* delegate) | 36 TouchExplorationControllerDelegate* delegate) |
33 : root_window_(root_window), | 37 : root_window_(root_window), |
34 delegate_(delegate), | 38 delegate_(delegate), |
35 state_(NO_FINGERS_DOWN), | 39 state_(NO_FINGERS_DOWN), |
36 event_handler_for_testing_(NULL), | 40 event_handler_for_testing_(NULL), |
37 gesture_provider_(this), | 41 gesture_provider_(this), |
38 prev_state_(NO_FINGERS_DOWN), | 42 prev_state_(NO_FINGERS_DOWN), |
39 VLOG_on_(true) { | 43 VLOG_on_(true), |
| 44 waiting_for_corner_passthrough_(false) { |
40 CHECK(root_window); | 45 CHECK(root_window); |
41 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 46 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
42 } | 47 } |
43 | 48 |
44 TouchExplorationController::~TouchExplorationController() { | 49 TouchExplorationController::~TouchExplorationController() { |
45 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 50 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
46 } | 51 } |
47 | 52 |
48 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( | 53 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
49 const ui::Event& event, | 54 const ui::Event& event, |
(...skipping 16 matching lines...) Expand all Loading... |
66 // the timer. | 71 // the timer. |
67 if (tap_timer_.IsRunning() && | 72 if (tap_timer_.IsRunning() && |
68 touch_event.time_stamp() - initial_press_->time_stamp() > | 73 touch_event.time_stamp() - initial_press_->time_stamp() > |
69 gesture_detector_config_.double_tap_timeout) { | 74 gesture_detector_config_.double_tap_timeout) { |
70 tap_timer_.Stop(); | 75 tap_timer_.Stop(); |
71 OnTapTimerFired(); | 76 OnTapTimerFired(); |
72 // Note: this may change the state. We should now continue and process | 77 // Note: this may change the state. We should now continue and process |
73 // this event under this new state. | 78 // this event under this new state. |
74 } | 79 } |
75 | 80 |
| 81 if (long_press_timer_.IsRunning() && |
| 82 event.time_stamp() - initial_press_->time_stamp() > |
| 83 gesture_detector_config_.longpress_timeout) { |
| 84 long_press_timer_.Stop(); |
| 85 OnLongPressTimerFired(); |
| 86 } |
| 87 |
76 const ui::EventType type = touch_event.type(); | 88 const ui::EventType type = touch_event.type(); |
77 const gfx::PointF& location = touch_event.location_f(); | 89 const gfx::PointF& location = touch_event.location_f(); |
78 const int touch_id = touch_event.touch_id(); | 90 const int touch_id = touch_event.touch_id(); |
79 | 91 |
80 // Always update touch ids and touch locations, so we can use those | 92 // Always update touch ids and touch locations, so we can use those |
81 // no matter what state we're in. | 93 // no matter what state we're in. |
82 if (type == ui::ET_TOUCH_PRESSED) { | 94 if (type == ui::ET_TOUCH_PRESSED) { |
83 current_touch_ids_.push_back(touch_id); | 95 current_touch_ids_.push_back(touch_id); |
84 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location)); | 96 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location)); |
85 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 97 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 case DOUBLE_TAP_PRESSED: | 137 case DOUBLE_TAP_PRESSED: |
126 return InDoubleTapPressed(touch_event, rewritten_event); | 138 return InDoubleTapPressed(touch_event, rewritten_event); |
127 case TOUCH_EXPLORATION: | 139 case TOUCH_EXPLORATION: |
128 return InTouchExploration(touch_event, rewritten_event); | 140 return InTouchExploration(touch_event, rewritten_event); |
129 case GESTURE_IN_PROGRESS: | 141 case GESTURE_IN_PROGRESS: |
130 return InGestureInProgress(touch_event, rewritten_event); | 142 return InGestureInProgress(touch_event, rewritten_event); |
131 case TOUCH_EXPLORE_SECOND_PRESS: | 143 case TOUCH_EXPLORE_SECOND_PRESS: |
132 return InTouchExploreSecondPress(touch_event, rewritten_event); | 144 return InTouchExploreSecondPress(touch_event, rewritten_event); |
133 case TWO_TO_ONE_FINGER: | 145 case TWO_TO_ONE_FINGER: |
134 return InTwoToOneFinger(touch_event, rewritten_event); | 146 return InTwoToOneFinger(touch_event, rewritten_event); |
| 147 case CORNER_PASSTHROUGH: |
| 148 return InCornerPassthrough(touch_event, rewritten_event); |
135 case PASSTHROUGH: | 149 case PASSTHROUGH: |
136 return InPassthrough(touch_event, rewritten_event); | 150 return InPassthrough(touch_event, rewritten_event); |
137 case WAIT_FOR_RELEASE: | 151 case WAIT_FOR_RELEASE: |
138 return InWaitForRelease(touch_event, rewritten_event); | 152 return InWaitForRelease(touch_event, rewritten_event); |
139 case SLIDE_GESTURE: | 153 case SLIDE_GESTURE: |
140 return InSlideGesture(touch_event, rewritten_event); | 154 return InSlideGesture(touch_event, rewritten_event); |
141 } | 155 } |
142 NOTREACHED(); | 156 NOTREACHED(); |
143 return ui::EVENT_REWRITE_CONTINUE; | 157 return ui::EVENT_REWRITE_CONTINUE; |
144 } | 158 } |
145 | 159 |
146 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent( | 160 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent( |
147 const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) { | 161 const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) { |
148 NOTREACHED(); | 162 NOTREACHED(); |
149 return ui::EVENT_REWRITE_CONTINUE; | 163 return ui::EVENT_REWRITE_CONTINUE; |
150 } | 164 } |
151 | 165 |
152 ui::EventRewriteStatus TouchExplorationController::InNoFingersDown( | 166 ui::EventRewriteStatus TouchExplorationController::InNoFingersDown( |
153 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 167 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
154 const ui::EventType type = event.type(); | 168 const ui::EventType type = event.type(); |
155 if (type == ui::ET_TOUCH_PRESSED) { | 169 if (type != ui::ET_TOUCH_PRESSED) { |
156 initial_press_.reset(new TouchEvent(event)); | 170 NOTREACHED() << "Unexpected event type received: " << event.name(); |
157 last_unused_finger_event_.reset(new TouchEvent(event)); | 171 return ui::EVENT_REWRITE_CONTINUE; |
158 tap_timer_.Start(FROM_HERE, | |
159 gesture_detector_config_.double_tap_timeout, | |
160 this, | |
161 &TouchExplorationController::OnTapTimerFired); | |
162 gesture_provider_.OnTouchEvent(event); | |
163 gesture_provider_.OnTouchEventAck(false); | |
164 ProcessGestureEvents(); | |
165 state_ = SINGLE_TAP_PRESSED; | |
166 VLOG_STATE(); | |
167 return ui::EVENT_REWRITE_DISCARD; | |
168 } | 172 } |
169 NOTREACHED() << "Unexpected event type received: " << event.name();; | 173 int location = FindEdgesWithinBounds(event.location(), kSlopDistanceFromEdge); |
170 return ui::EVENT_REWRITE_CONTINUE; | 174 base::TimeDelta timeout; |
| 175 |
| 176 // If the press was at a corner, the user might go into corner passthrough |
| 177 // instead. |
| 178 bool in_a_bottom_corner = |
| 179 (BOTTOM_LEFT_CORNER == location) || (BOTTOM_RIGHT_CORNER == location); |
| 180 if (in_a_bottom_corner) { |
| 181 VLOG(0) << "Location: " << location; |
| 182 long_press_timer_.Start(FROM_HERE, |
| 183 gesture_detector_config_.longpress_timeout, |
| 184 this, |
| 185 &TouchExplorationController::OnLongPressTimerFired); |
| 186 waiting_for_corner_passthrough_ = true; |
| 187 } else { |
| 188 waiting_for_corner_passthrough_ = false; |
| 189 } |
| 190 tap_timer_.Start(FROM_HERE, |
| 191 gesture_detector_config_.double_tap_timeout, |
| 192 this, |
| 193 &TouchExplorationController::OnTapTimerFired); |
| 194 initial_press_.reset(new TouchEvent(event)); |
| 195 last_unused_finger_event_.reset(new TouchEvent(event)); |
| 196 gesture_provider_.OnTouchEvent(event); |
| 197 gesture_provider_.OnTouchEventAck(false); |
| 198 ProcessGestureEvents(); |
| 199 state_ = SINGLE_TAP_PRESSED; |
| 200 VLOG_STATE(); |
| 201 return ui::EVENT_REWRITE_DISCARD; |
171 } | 202 } |
172 | 203 |
173 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( | 204 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( |
174 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 205 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
175 const ui::EventType type = event.type(); | 206 const ui::EventType type = event.type(); |
176 | 207 |
| 208 int location = FindEdgesWithinBounds(event.location(), kMaxDistanceFromEdge); |
| 209 bool in_a_bottom_corner = |
| 210 (location == BOTTOM_LEFT_CORNER) || (location == BOTTOM_RIGHT_CORNER); |
| 211 // If the event is from the initial press and the location is no longer in the |
| 212 // corner, then we are not waiting for a corner passthrough anymore. |
| 213 if (event.touch_id() == initial_press_->touch_id() && !in_a_bottom_corner) { |
| 214 waiting_for_corner_passthrough_ = false; |
| 215 if (long_press_timer_.IsRunning()) { |
| 216 long_press_timer_.Stop(); |
| 217 if (event.time_stamp() - initial_press_->time_stamp() > |
| 218 gesture_detector_config_.double_tap_timeout) { |
| 219 OnTapTimerFired(); |
| 220 } |
| 221 } |
| 222 } |
| 223 |
177 if (type == ui::ET_TOUCH_PRESSED) { | 224 if (type == ui::ET_TOUCH_PRESSED) { |
| 225 waiting_for_corner_passthrough_ = false; |
178 // Adding a second finger within the timeout period switches to | 226 // Adding a second finger within the timeout period switches to |
179 // passing through every event from the second finger and none form the | 227 // passing through every event from the second finger and none form the |
180 // first. The event from the first finger is still saved in initial_press_. | 228 // first. The event from the first finger is still saved in initial_press_. |
181 state_ = TWO_TO_ONE_FINGER; | 229 state_ = TWO_TO_ONE_FINGER; |
182 last_two_to_one_.reset(new TouchEvent(event)); | 230 last_two_to_one_.reset(new TouchEvent(event)); |
183 rewritten_event->reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, | 231 rewritten_event->reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, |
184 event.location(), | 232 event.location(), |
185 event.touch_id(), | 233 event.touch_id(), |
186 event.time_stamp())); | 234 event.time_stamp())); |
187 (*rewritten_event)->set_flags(event.flags()); | 235 (*rewritten_event)->set_flags(event.flags()); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 event.time_stamp())); | 443 event.time_stamp())); |
396 (*rewritten_event)->set_flags(event.flags()); | 444 (*rewritten_event)->set_flags(event.flags()); |
397 state_ = WAIT_FOR_RELEASE; | 445 state_ = WAIT_FOR_RELEASE; |
398 return ui::EVENT_REWRITE_REWRITTEN; | 446 return ui::EVENT_REWRITE_REWRITTEN; |
399 } | 447 } |
400 } else if (type == ui::ET_TOUCH_PRESSED) { | 448 } else if (type == ui::ET_TOUCH_PRESSED) { |
401 DCHECK(current_touch_ids_.size() == 3); | 449 DCHECK(current_touch_ids_.size() == 3); |
402 // If a third finger is pressed, we are now going into passthrough mode | 450 // If a third finger is pressed, we are now going into passthrough mode |
403 // and now need to dispatch the first finger into a press, as well as the | 451 // and now need to dispatch the first finger into a press, as well as the |
404 // recent press. | 452 // recent press. |
405 if (current_touch_ids_.size() == 3){ | 453 if (current_touch_ids_.size() == 3) { |
406 state_ = PASSTHROUGH; | 454 state_ = PASSTHROUGH; |
407 scoped_ptr<ui::TouchEvent> first_finger_press; | 455 scoped_ptr<ui::TouchEvent> first_finger_press; |
408 first_finger_press.reset( | 456 first_finger_press.reset( |
409 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, | 457 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, |
410 last_unused_finger_event_->location(), | 458 last_unused_finger_event_->location(), |
411 last_unused_finger_event_->touch_id(), | 459 last_unused_finger_event_->touch_id(), |
412 event.time_stamp())); | 460 event.time_stamp())); |
413 DispatchEvent(first_finger_press.get()); | 461 DispatchEvent(first_finger_press.get()); |
414 rewritten_event->reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, | 462 rewritten_event->reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, |
415 event.location(), | 463 event.location(), |
(...skipping 18 matching lines...) Expand all Loading... |
434 event.touch_id(), | 482 event.touch_id(), |
435 event.time_stamp())); | 483 event.time_stamp())); |
436 (*rewritten_event)->set_flags(event.flags()); | 484 (*rewritten_event)->set_flags(event.flags()); |
437 return ui::EVENT_REWRITE_REWRITTEN; | 485 return ui::EVENT_REWRITE_REWRITTEN; |
438 } | 486 } |
439 } | 487 } |
440 NOTREACHED() << "Unexpected event type received: " << event.name(); | 488 NOTREACHED() << "Unexpected event type received: " << event.name(); |
441 return ui::EVENT_REWRITE_CONTINUE; | 489 return ui::EVENT_REWRITE_CONTINUE; |
442 } | 490 } |
443 | 491 |
| 492 ui::EventRewriteStatus TouchExplorationController::InCornerPassthrough( |
| 493 const ui::TouchEvent& event, |
| 494 scoped_ptr<ui::Event>* rewritten_event) { |
| 495 ui::EventType type = event.type(); |
| 496 |
| 497 // If the first finger has left the corner, then exit passthrough. |
| 498 if (event.touch_id() == initial_press_->touch_id()) { |
| 499 int edges = FindEdgesWithinBounds(event.location(), kSlopDistanceFromEdge); |
| 500 bool in_a_bottom_corner = (edges == BOTTOM_LEFT_CORNER) || |
| 501 (edges == BOTTOM_RIGHT_CORNER); |
| 502 if (type == ui::ET_TOUCH_MOVED && in_a_bottom_corner) |
| 503 return ui::EVENT_REWRITE_DISCARD; |
| 504 |
| 505 if (current_touch_ids_.size() == 0) { |
| 506 ResetToNoFingersDown(); |
| 507 return ui::EVENT_REWRITE_DISCARD; |
| 508 } |
| 509 |
| 510 waiting_for_corner_passthrough_ = false; |
| 511 VLOG(0) << "Waiting for corner passthrough is false"; |
| 512 state_ = WAIT_FOR_RELEASE; |
| 513 VLOG_STATE(); |
| 514 return ui::EVENT_REWRITE_DISCARD; |
| 515 } |
| 516 |
| 517 rewritten_event->reset(new ui::TouchEvent( |
| 518 type, event.location(), event.touch_id(), event.time_stamp())); |
| 519 (*rewritten_event)->set_flags(event.flags()); |
| 520 |
| 521 if (current_touch_ids_.size() == 0) |
| 522 ResetToNoFingersDown(); |
| 523 |
| 524 return ui::EVENT_REWRITE_REWRITTEN; |
| 525 } |
| 526 |
444 ui::EventRewriteStatus TouchExplorationController::InPassthrough( | 527 ui::EventRewriteStatus TouchExplorationController::InPassthrough( |
445 const ui::TouchEvent& event, | 528 const ui::TouchEvent& event, |
446 scoped_ptr<ui::Event>* rewritten_event) { | 529 scoped_ptr<ui::Event>* rewritten_event) { |
447 ui::EventType type = event.type(); | 530 ui::EventType type = event.type(); |
448 | 531 |
449 if (!(type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED || | 532 if (!(type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED || |
450 type == ui::ET_TOUCH_MOVED || type == ui::ET_TOUCH_PRESSED)) { | 533 type == ui::ET_TOUCH_MOVED || type == ui::ET_TOUCH_PRESSED)) { |
451 NOTREACHED() << "Unexpected event type received: " << event.name(); | 534 NOTREACHED() << "Unexpected event type received: " << event.name(); |
452 return ui::EVENT_REWRITE_CONTINUE; | 535 return ui::EVENT_REWRITE_CONTINUE; |
453 } | 536 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 VLOG_STATE(); | 584 VLOG_STATE(); |
502 return ui::EVENT_REWRITE_REWRITTEN; | 585 return ui::EVENT_REWRITE_REWRITTEN; |
503 } | 586 } |
504 NOTREACHED() << "Unexpected event type received: " << event.name(); | 587 NOTREACHED() << "Unexpected event type received: " << event.name(); |
505 return ui::EVENT_REWRITE_CONTINUE; | 588 return ui::EVENT_REWRITE_CONTINUE; |
506 } | 589 } |
507 | 590 |
508 ui::EventRewriteStatus TouchExplorationController::InWaitForRelease( | 591 ui::EventRewriteStatus TouchExplorationController::InWaitForRelease( |
509 const ui::TouchEvent& event, | 592 const ui::TouchEvent& event, |
510 scoped_ptr<ui::Event>* rewritten_event) { | 593 scoped_ptr<ui::Event>* rewritten_event) { |
| 594 waiting_for_corner_passthrough_ = false; |
511 ui::EventType type = event.type(); | 595 ui::EventType type = event.type(); |
512 if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED || | 596 if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED || |
513 type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) { | 597 type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) { |
514 NOTREACHED() << "Unexpected event type received: " << event.name(); | 598 NOTREACHED() << "Unexpected event type received: " << event.name(); |
515 return ui::EVENT_REWRITE_CONTINUE; | 599 return ui::EVENT_REWRITE_CONTINUE; |
516 } | 600 } |
517 if (current_touch_ids_.size() == 0) { | 601 if (current_touch_ids_.size() == 0) { |
518 state_ = NO_FINGERS_DOWN; | 602 state_ = NO_FINGERS_DOWN; |
519 VLOG_STATE(); | 603 VLOG_STATE(); |
520 ResetToNoFingersDown(); | 604 ResetToNoFingersDown(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 void TouchExplorationController::OnTapTimerFired() { | 672 void TouchExplorationController::OnTapTimerFired() { |
589 switch (state_) { | 673 switch (state_) { |
590 case SINGLE_TAP_RELEASED: | 674 case SINGLE_TAP_RELEASED: |
591 ResetToNoFingersDown(); | 675 ResetToNoFingersDown(); |
592 break; | 676 break; |
593 case TOUCH_EXPLORE_RELEASED: | 677 case TOUCH_EXPLORE_RELEASED: |
594 ResetToNoFingersDown(); | 678 ResetToNoFingersDown(); |
595 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 679 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); |
596 return; | 680 return; |
597 case SINGLE_TAP_PRESSED: | 681 case SINGLE_TAP_PRESSED: |
| 682 if (waiting_for_corner_passthrough_) |
| 683 return; |
598 case GESTURE_IN_PROGRESS: | 684 case GESTURE_IN_PROGRESS: |
599 // Discard any pending gestures. | 685 // Discard any pending gestures. |
600 delete gesture_provider_.GetAndResetPendingGestures(); | 686 delete gesture_provider_.GetAndResetPendingGestures(); |
601 EnterTouchToMouseMode(); | 687 EnterTouchToMouseMode(); |
602 state_ = TOUCH_EXPLORATION; | 688 state_ = TOUCH_EXPLORATION; |
603 VLOG_STATE(); | 689 VLOG_STATE(); |
604 break; | 690 break; |
605 default: | 691 default: |
606 return; | 692 return; |
607 } | 693 } |
608 scoped_ptr<ui::Event> mouse_move = | 694 scoped_ptr<ui::Event> mouse_move = |
609 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); | 695 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); |
610 DispatchEvent(mouse_move.get()); | 696 DispatchEvent(mouse_move.get()); |
611 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 697 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); |
612 } | 698 } |
613 | 699 |
| 700 void TouchExplorationController::OnLongPressTimerFired() { |
| 701 if (waiting_for_corner_passthrough_) { |
| 702 delegate_->PlayEarCon(); |
| 703 delete gesture_provider_.GetAndResetPendingGestures(); |
| 704 state_ = CORNER_PASSTHROUGH; |
| 705 VLOG_STATE(); |
| 706 return; |
| 707 } |
| 708 } |
| 709 |
614 void TouchExplorationController::DispatchEvent(ui::Event* event) { | 710 void TouchExplorationController::DispatchEvent(ui::Event* event) { |
615 if (event_handler_for_testing_) { | 711 if (event_handler_for_testing_) { |
616 event_handler_for_testing_->OnEvent(event); | 712 event_handler_for_testing_->OnEvent(event); |
617 return; | 713 return; |
618 } | 714 } |
619 ui::EventDispatchDetails result ALLOW_UNUSED = | 715 ui::EventDispatchDetails result ALLOW_UNUSED = |
620 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); | 716 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); |
621 } | 717 } |
622 | 718 |
623 void TouchExplorationController::OnGestureEvent( | 719 void TouchExplorationController::OnGestureEvent( |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 void TouchExplorationController::EnterTouchToMouseMode() { | 894 void TouchExplorationController::EnterTouchToMouseMode() { |
799 aura::client::CursorClient* cursor_client = | 895 aura::client::CursorClient* cursor_client = |
800 aura::client::GetCursorClient(root_window_); | 896 aura::client::GetCursorClient(root_window_); |
801 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) | 897 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) |
802 cursor_client->EnableMouseEvents(); | 898 cursor_client->EnableMouseEvents(); |
803 if (cursor_client && cursor_client->IsCursorVisible()) | 899 if (cursor_client && cursor_client->IsCursorVisible()) |
804 cursor_client->HideCursor(); | 900 cursor_client->HideCursor(); |
805 } | 901 } |
806 | 902 |
807 void TouchExplorationController::ResetToNoFingersDown() { | 903 void TouchExplorationController::ResetToNoFingersDown() { |
| 904 waiting_for_corner_passthrough_ = false; |
808 ProcessGestureEvents(); | 905 ProcessGestureEvents(); |
809 if (sound_timer_.IsRunning()) | 906 if (sound_timer_.IsRunning()) |
810 sound_timer_.Stop(); | 907 sound_timer_.Stop(); |
811 state_ = NO_FINGERS_DOWN; | 908 state_ = NO_FINGERS_DOWN; |
812 VLOG_STATE(); | 909 VLOG_STATE(); |
813 if (tap_timer_.IsRunning()) | 910 if (tap_timer_.IsRunning()) |
814 tap_timer_.Stop(); | 911 tap_timer_.Stop(); |
815 } | 912 } |
816 | 913 |
817 void TouchExplorationController::VlogState(const char* function_name) { | 914 void TouchExplorationController::VlogState(const char* function_name) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 case DOUBLE_TAP_PRESSED: | 965 case DOUBLE_TAP_PRESSED: |
869 return "DOUBLE_TAP_PRESSED"; | 966 return "DOUBLE_TAP_PRESSED"; |
870 case TOUCH_EXPLORATION: | 967 case TOUCH_EXPLORATION: |
871 return "TOUCH_EXPLORATION"; | 968 return "TOUCH_EXPLORATION"; |
872 case GESTURE_IN_PROGRESS: | 969 case GESTURE_IN_PROGRESS: |
873 return "GESTURE_IN_PROGRESS"; | 970 return "GESTURE_IN_PROGRESS"; |
874 case TOUCH_EXPLORE_SECOND_PRESS: | 971 case TOUCH_EXPLORE_SECOND_PRESS: |
875 return "TOUCH_EXPLORE_SECOND_PRESS"; | 972 return "TOUCH_EXPLORE_SECOND_PRESS"; |
876 case TWO_TO_ONE_FINGER: | 973 case TWO_TO_ONE_FINGER: |
877 return "TWO_TO_ONE_FINGER"; | 974 return "TWO_TO_ONE_FINGER"; |
| 975 case CORNER_PASSTHROUGH: |
| 976 return "CORNER_PASSTHROUGH"; |
878 case PASSTHROUGH: | 977 case PASSTHROUGH: |
879 return "PASSTHROUGH"; | 978 return "PASSTHROUGH"; |
880 case WAIT_FOR_RELEASE: | 979 case WAIT_FOR_RELEASE: |
881 return "WAIT_FOR_RELEASE"; | 980 return "WAIT_FOR_RELEASE"; |
882 case SLIDE_GESTURE: | 981 case SLIDE_GESTURE: |
883 return "SLIDE_GESTURE"; | 982 return "SLIDE_GESTURE"; |
884 } | 983 } |
885 return "Not a state"; | 984 return "Not a state"; |
886 } | 985 } |
887 | 986 |
888 } // namespace ui | 987 } // namespace ui |
OLD | NEW |