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()); |
188 return EVENT_REWRITE_REWRITTEN; | 236 return EVENT_REWRITE_REWRITTEN; |
189 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 237 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
| 238 waiting_for_corner_passthrough_ = false; |
190 DCHECK_EQ(0U, current_touch_ids_.size()); | 239 DCHECK_EQ(0U, current_touch_ids_.size()); |
191 state_ = SINGLE_TAP_RELEASED; | 240 state_ = SINGLE_TAP_RELEASED; |
192 VLOG_STATE(); | 241 VLOG_STATE(); |
193 return EVENT_REWRITE_DISCARD; | 242 return EVENT_REWRITE_DISCARD; |
194 } else if (type == ui::ET_TOUCH_MOVED) { | 243 } else if (type == ui::ET_TOUCH_MOVED) { |
195 float distance = (event.location() - initial_press_->location()).Length(); | 244 float distance = (event.location() - initial_press_->location()).Length(); |
196 // If the user does not move far enough from the original position, then the | 245 // If the user does not move far enough from the original position, then the |
197 // resulting movement should not be considered to be a deliberate gesture or | 246 // resulting movement should not be considered to be a deliberate gesture or |
198 // touch exploration. | 247 // touch exploration. |
199 if (distance <= gesture_detector_config_.touch_slop) | 248 if (distance <= gesture_detector_config_.touch_slop) |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 event.time_stamp())); | 444 event.time_stamp())); |
396 (*rewritten_event)->set_flags(event.flags()); | 445 (*rewritten_event)->set_flags(event.flags()); |
397 state_ = WAIT_FOR_RELEASE; | 446 state_ = WAIT_FOR_RELEASE; |
398 return ui::EVENT_REWRITE_REWRITTEN; | 447 return ui::EVENT_REWRITE_REWRITTEN; |
399 } | 448 } |
400 } else if (type == ui::ET_TOUCH_PRESSED) { | 449 } else if (type == ui::ET_TOUCH_PRESSED) { |
401 DCHECK(current_touch_ids_.size() == 3); | 450 DCHECK(current_touch_ids_.size() == 3); |
402 // If a third finger is pressed, we are now going into passthrough mode | 451 // 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 | 452 // and now need to dispatch the first finger into a press, as well as the |
404 // recent press. | 453 // recent press. |
405 if (current_touch_ids_.size() == 3){ | 454 if (current_touch_ids_.size() == 3) { |
406 state_ = PASSTHROUGH; | 455 state_ = PASSTHROUGH; |
407 scoped_ptr<ui::TouchEvent> first_finger_press; | 456 scoped_ptr<ui::TouchEvent> first_finger_press; |
408 first_finger_press.reset( | 457 first_finger_press.reset( |
409 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, | 458 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, |
410 last_unused_finger_event_->location(), | 459 last_unused_finger_event_->location(), |
411 last_unused_finger_event_->touch_id(), | 460 last_unused_finger_event_->touch_id(), |
412 event.time_stamp())); | 461 event.time_stamp())); |
413 DispatchEvent(first_finger_press.get()); | 462 DispatchEvent(first_finger_press.get()); |
414 rewritten_event->reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, | 463 rewritten_event->reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, |
415 event.location(), | 464 event.location(), |
(...skipping 18 matching lines...) Expand all Loading... |
434 event.touch_id(), | 483 event.touch_id(), |
435 event.time_stamp())); | 484 event.time_stamp())); |
436 (*rewritten_event)->set_flags(event.flags()); | 485 (*rewritten_event)->set_flags(event.flags()); |
437 return ui::EVENT_REWRITE_REWRITTEN; | 486 return ui::EVENT_REWRITE_REWRITTEN; |
438 } | 487 } |
439 } | 488 } |
440 NOTREACHED() << "Unexpected event type received: " << event.name(); | 489 NOTREACHED() << "Unexpected event type received: " << event.name(); |
441 return ui::EVENT_REWRITE_CONTINUE; | 490 return ui::EVENT_REWRITE_CONTINUE; |
442 } | 491 } |
443 | 492 |
| 493 ui::EventRewriteStatus TouchExplorationController::InCornerPassthrough( |
| 494 const ui::TouchEvent& event, |
| 495 scoped_ptr<ui::Event>* rewritten_event) { |
| 496 ui::EventType type = event.type(); |
| 497 |
| 498 // If the first finger has left the corner, then exit passthrough. |
| 499 if (event.touch_id() == initial_press_->touch_id()) { |
| 500 int edges = FindEdgesWithinBounds(event.location(), kSlopDistanceFromEdge); |
| 501 bool in_a_bottom_corner = (edges == BOTTOM_LEFT_CORNER) || |
| 502 (edges == BOTTOM_RIGHT_CORNER); |
| 503 if (type == ui::ET_TOUCH_MOVED && in_a_bottom_corner) |
| 504 return ui::EVENT_REWRITE_DISCARD; |
| 505 |
| 506 if (current_touch_ids_.size() == 0) { |
| 507 ResetToNoFingersDown(); |
| 508 return ui::EVENT_REWRITE_DISCARD; |
| 509 } |
| 510 |
| 511 waiting_for_corner_passthrough_ = false; |
| 512 VLOG(0) << "Waiting for corner passthrough is false"; |
| 513 state_ = WAIT_FOR_RELEASE; |
| 514 VLOG_STATE(); |
| 515 return ui::EVENT_REWRITE_DISCARD; |
| 516 } |
| 517 |
| 518 rewritten_event->reset(new ui::TouchEvent( |
| 519 type, event.location(), event.touch_id(), event.time_stamp())); |
| 520 (*rewritten_event)->set_flags(event.flags()); |
| 521 |
| 522 if (current_touch_ids_.size() == 0) |
| 523 ResetToNoFingersDown(); |
| 524 |
| 525 return ui::EVENT_REWRITE_REWRITTEN; |
| 526 } |
| 527 |
444 ui::EventRewriteStatus TouchExplorationController::InPassthrough( | 528 ui::EventRewriteStatus TouchExplorationController::InPassthrough( |
445 const ui::TouchEvent& event, | 529 const ui::TouchEvent& event, |
446 scoped_ptr<ui::Event>* rewritten_event) { | 530 scoped_ptr<ui::Event>* rewritten_event) { |
447 ui::EventType type = event.type(); | 531 ui::EventType type = event.type(); |
448 | 532 |
449 if (!(type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED || | 533 if (!(type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED || |
450 type == ui::ET_TOUCH_MOVED || type == ui::ET_TOUCH_PRESSED)) { | 534 type == ui::ET_TOUCH_MOVED || type == ui::ET_TOUCH_PRESSED)) { |
451 NOTREACHED() << "Unexpected event type received: " << event.name(); | 535 NOTREACHED() << "Unexpected event type received: " << event.name(); |
452 return ui::EVENT_REWRITE_CONTINUE; | 536 return ui::EVENT_REWRITE_CONTINUE; |
453 } | 537 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 VLOG_STATE(); | 585 VLOG_STATE(); |
502 return ui::EVENT_REWRITE_REWRITTEN; | 586 return ui::EVENT_REWRITE_REWRITTEN; |
503 } | 587 } |
504 NOTREACHED() << "Unexpected event type received: " << event.name(); | 588 NOTREACHED() << "Unexpected event type received: " << event.name(); |
505 return ui::EVENT_REWRITE_CONTINUE; | 589 return ui::EVENT_REWRITE_CONTINUE; |
506 } | 590 } |
507 | 591 |
508 ui::EventRewriteStatus TouchExplorationController::InWaitForRelease( | 592 ui::EventRewriteStatus TouchExplorationController::InWaitForRelease( |
509 const ui::TouchEvent& event, | 593 const ui::TouchEvent& event, |
510 scoped_ptr<ui::Event>* rewritten_event) { | 594 scoped_ptr<ui::Event>* rewritten_event) { |
| 595 waiting_for_corner_passthrough_ = false; |
511 ui::EventType type = event.type(); | 596 ui::EventType type = event.type(); |
512 if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED || | 597 if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED || |
513 type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) { | 598 type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) { |
514 NOTREACHED() << "Unexpected event type received: " << event.name(); | 599 NOTREACHED() << "Unexpected event type received: " << event.name(); |
515 return ui::EVENT_REWRITE_CONTINUE; | 600 return ui::EVENT_REWRITE_CONTINUE; |
516 } | 601 } |
517 if (current_touch_ids_.size() == 0) { | 602 if (current_touch_ids_.size() == 0) { |
518 state_ = NO_FINGERS_DOWN; | 603 state_ = NO_FINGERS_DOWN; |
519 VLOG_STATE(); | 604 VLOG_STATE(); |
520 ResetToNoFingersDown(); | 605 ResetToNoFingersDown(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 void TouchExplorationController::OnTapTimerFired() { | 673 void TouchExplorationController::OnTapTimerFired() { |
589 switch (state_) { | 674 switch (state_) { |
590 case SINGLE_TAP_RELEASED: | 675 case SINGLE_TAP_RELEASED: |
591 ResetToNoFingersDown(); | 676 ResetToNoFingersDown(); |
592 break; | 677 break; |
593 case TOUCH_EXPLORE_RELEASED: | 678 case TOUCH_EXPLORE_RELEASED: |
594 ResetToNoFingersDown(); | 679 ResetToNoFingersDown(); |
595 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 680 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); |
596 return; | 681 return; |
597 case SINGLE_TAP_PRESSED: | 682 case SINGLE_TAP_PRESSED: |
| 683 if (waiting_for_corner_passthrough_) |
| 684 return; |
598 case GESTURE_IN_PROGRESS: | 685 case GESTURE_IN_PROGRESS: |
| 686 waiting_for_corner_passthrough_ = false; |
599 // Discard any pending gestures. | 687 // Discard any pending gestures. |
600 delete gesture_provider_.GetAndResetPendingGestures(); | 688 delete gesture_provider_.GetAndResetPendingGestures(); |
601 EnterTouchToMouseMode(); | 689 EnterTouchToMouseMode(); |
602 state_ = TOUCH_EXPLORATION; | 690 state_ = TOUCH_EXPLORATION; |
603 VLOG_STATE(); | 691 VLOG_STATE(); |
604 break; | 692 break; |
605 default: | 693 default: |
606 return; | 694 return; |
607 } | 695 } |
608 scoped_ptr<ui::Event> mouse_move = | 696 scoped_ptr<ui::Event> mouse_move = |
609 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); | 697 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); |
610 DispatchEvent(mouse_move.get()); | 698 DispatchEvent(mouse_move.get()); |
611 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 699 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); |
612 } | 700 } |
613 | 701 |
| 702 void TouchExplorationController::OnLongPressTimerFired() { |
| 703 if (waiting_for_corner_passthrough_) { |
| 704 delegate_->PlayCornerPassthroughEarcon(); |
| 705 delete gesture_provider_.GetAndResetPendingGestures(); |
| 706 state_ = CORNER_PASSTHROUGH; |
| 707 VLOG_STATE(); |
| 708 return; |
| 709 } |
| 710 } |
| 711 |
614 void TouchExplorationController::DispatchEvent(ui::Event* event) { | 712 void TouchExplorationController::DispatchEvent(ui::Event* event) { |
615 if (event_handler_for_testing_) { | 713 if (event_handler_for_testing_) { |
616 event_handler_for_testing_->OnEvent(event); | 714 event_handler_for_testing_->OnEvent(event); |
617 return; | 715 return; |
618 } | 716 } |
619 ui::EventDispatchDetails result ALLOW_UNUSED = | 717 ui::EventDispatchDetails result ALLOW_UNUSED = |
620 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); | 718 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); |
621 } | 719 } |
622 | 720 |
623 void TouchExplorationController::OnGestureEvent( | 721 void TouchExplorationController::OnGestureEvent( |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 void TouchExplorationController::EnterTouchToMouseMode() { | 896 void TouchExplorationController::EnterTouchToMouseMode() { |
799 aura::client::CursorClient* cursor_client = | 897 aura::client::CursorClient* cursor_client = |
800 aura::client::GetCursorClient(root_window_); | 898 aura::client::GetCursorClient(root_window_); |
801 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) | 899 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) |
802 cursor_client->EnableMouseEvents(); | 900 cursor_client->EnableMouseEvents(); |
803 if (cursor_client && cursor_client->IsCursorVisible()) | 901 if (cursor_client && cursor_client->IsCursorVisible()) |
804 cursor_client->HideCursor(); | 902 cursor_client->HideCursor(); |
805 } | 903 } |
806 | 904 |
807 void TouchExplorationController::ResetToNoFingersDown() { | 905 void TouchExplorationController::ResetToNoFingersDown() { |
| 906 waiting_for_corner_passthrough_ = false; |
808 ProcessGestureEvents(); | 907 ProcessGestureEvents(); |
809 if (sound_timer_.IsRunning()) | 908 if (sound_timer_.IsRunning()) |
810 sound_timer_.Stop(); | 909 sound_timer_.Stop(); |
811 state_ = NO_FINGERS_DOWN; | 910 state_ = NO_FINGERS_DOWN; |
812 VLOG_STATE(); | 911 VLOG_STATE(); |
813 if (tap_timer_.IsRunning()) | 912 if (tap_timer_.IsRunning()) |
814 tap_timer_.Stop(); | 913 tap_timer_.Stop(); |
815 } | 914 } |
816 | 915 |
817 void TouchExplorationController::VlogState(const char* function_name) { | 916 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: | 967 case DOUBLE_TAP_PRESSED: |
869 return "DOUBLE_TAP_PRESSED"; | 968 return "DOUBLE_TAP_PRESSED"; |
870 case TOUCH_EXPLORATION: | 969 case TOUCH_EXPLORATION: |
871 return "TOUCH_EXPLORATION"; | 970 return "TOUCH_EXPLORATION"; |
872 case GESTURE_IN_PROGRESS: | 971 case GESTURE_IN_PROGRESS: |
873 return "GESTURE_IN_PROGRESS"; | 972 return "GESTURE_IN_PROGRESS"; |
874 case TOUCH_EXPLORE_SECOND_PRESS: | 973 case TOUCH_EXPLORE_SECOND_PRESS: |
875 return "TOUCH_EXPLORE_SECOND_PRESS"; | 974 return "TOUCH_EXPLORE_SECOND_PRESS"; |
876 case TWO_TO_ONE_FINGER: | 975 case TWO_TO_ONE_FINGER: |
877 return "TWO_TO_ONE_FINGER"; | 976 return "TWO_TO_ONE_FINGER"; |
| 977 case CORNER_PASSTHROUGH: |
| 978 return "CORNER_PASSTHROUGH"; |
878 case PASSTHROUGH: | 979 case PASSTHROUGH: |
879 return "PASSTHROUGH"; | 980 return "PASSTHROUGH"; |
880 case WAIT_FOR_RELEASE: | 981 case WAIT_FOR_RELEASE: |
881 return "WAIT_FOR_RELEASE"; | 982 return "WAIT_FOR_RELEASE"; |
882 case SLIDE_GESTURE: | 983 case SLIDE_GESTURE: |
883 return "SLIDE_GESTURE"; | 984 return "SLIDE_GESTURE"; |
884 } | 985 } |
885 return "Not a state"; | 986 return "Not a state"; |
886 } | 987 } |
887 | 988 |
888 } // namespace ui | 989 } // namespace ui |
OLD | NEW |