Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Side by Side Diff: ui/chromeos/touch_exploration_controller.cc

Issue 385073009: Side Slide Gestures for Accessibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
8 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
9 #include "ui/aura/client/cursor_client.h" 8 #include "ui/aura/client/cursor_client.h"
10 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
11 #include "ui/aura/window_event_dispatcher.h" 10 #include "ui/aura/window_event_dispatcher.h"
12 #include "ui/aura/window_tree_host.h" 11 #include "ui/aura/window_tree_host.h"
13 #include "ui/events/event.h" 12 #include "ui/events/event.h"
14 #include "ui/events/event_processor.h" 13 #include "ui/events/event_processor.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
23 // Delay between adjustment sounds.
24 const base::TimeDelta kSoundDelay = base::TimeDelta::FromMilliseconds(150);
25
26 // Within these bounds, the release event generated will reset the state to
dmazzoni 2014/07/22 17:14:54 Nit: something like "within this many dips of the
lisayin 2014/07/22 18:06:26 Done.
27 // NoFingersDown.
28 const float kLeavingScreenEdge = 6;
29
30 // Swipe/scroll gestures within these bounds (in dips) will change preset
31 // settings.
32 const float kMaxDistanceFromEdge = 75;
aboxhall 2014/07/22 17:20:41 Where do these numbers come from? What are the uni
lisayin 2014/07/22 18:06:25 Dip stands for device independent pixels so they s
33
34 // After a slide gesture has been triggered, if the finger is still within these
35 // bounds (in DIPs), the preset settings will still change.
36 const float kSlopDistanceFromEdge = kMaxDistanceFromEdge + 40;
37
22 // In ChromeOS, VKEY_LWIN is synonymous for the search key. 38 // In ChromeOS, VKEY_LWIN is synonymous for the search key.
23 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN; 39 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN;
24 } // namespace 40 } // namespace
25 41
26 TouchExplorationController::TouchExplorationController( 42 TouchExplorationController::TouchExplorationController(
27 aura::Window* root_window) 43 aura::Window* root_window,
44 TouchExplorationControllerDelegate* delegate)
28 : root_window_(root_window), 45 : root_window_(root_window),
46 delegate_(delegate),
29 state_(NO_FINGERS_DOWN), 47 state_(NO_FINGERS_DOWN),
30 event_handler_for_testing_(NULL), 48 event_handler_for_testing_(NULL),
31 gesture_provider_(this), 49 gesture_provider_(this),
32 prev_state_(NO_FINGERS_DOWN), 50 prev_state_(NO_FINGERS_DOWN),
33 VLOG_on_(true) { 51 VLOG_on_(true) {
34 CHECK(root_window); 52 CHECK(root_window);
35 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); 53 root_window->GetHost()->GetEventSource()->AddEventRewriter(this);
36 } 54 }
37 55
38 TouchExplorationController::~TouchExplorationController() { 56 TouchExplorationController::~TouchExplorationController() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 const ui::EventType type = touch_event.type(); 88 const ui::EventType type = touch_event.type();
71 const gfx::PointF& location = touch_event.location_f(); 89 const gfx::PointF& location = touch_event.location_f();
72 const int touch_id = touch_event.touch_id(); 90 const int touch_id = touch_event.touch_id();
73 91
74 // 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
75 // no matter what state we're in. 93 // no matter what state we're in.
76 if (type == ui::ET_TOUCH_PRESSED) { 94 if (type == ui::ET_TOUCH_PRESSED) {
77 current_touch_ids_.push_back(touch_id); 95 current_touch_ids_.push_back(touch_id);
78 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location)); 96 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location));
79 } 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) {
98 // In order to avoid accidentally double tapping when moving off the edge of
99 // the screen, the state will be rewritten to NoFingersDown.
100 TouchEvent touch_event = static_cast<const TouchEvent&>(event);
101 if (WithinBoundsOfEdge(touch_event.location(), kLeavingScreenEdge) !=
102 SCREEN_CENTER) {
103 if (current_touch_ids_.size() == 0)
104 ResetToNoFingersDown();
105 }
106
80 std::vector<int>::iterator it = std::find( 107 std::vector<int>::iterator it = std::find(
81 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id); 108 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id);
82 109
83 // Can happen if touch exploration is enabled while fingers were down. 110 // Can happen if touch exploration is enabled while fingers were down.
84 if (it == current_touch_ids_.end()) 111 if (it == current_touch_ids_.end())
85 return ui::EVENT_REWRITE_CONTINUE; 112 return ui::EVENT_REWRITE_CONTINUE;
86 113
87 current_touch_ids_.erase(it); 114 current_touch_ids_.erase(it);
88 touch_locations_.erase(touch_id); 115 touch_locations_.erase(touch_id);
89 } else if (type == ui::ET_TOUCH_MOVED) { 116 } else if (type == ui::ET_TOUCH_MOVED) {
(...skipping 24 matching lines...) Expand all
114 case GESTURE_IN_PROGRESS: 141 case GESTURE_IN_PROGRESS:
115 return InGestureInProgress(touch_event, rewritten_event); 142 return InGestureInProgress(touch_event, rewritten_event);
116 case TOUCH_EXPLORE_SECOND_PRESS: 143 case TOUCH_EXPLORE_SECOND_PRESS:
117 return InTouchExploreSecondPress(touch_event, rewritten_event); 144 return InTouchExploreSecondPress(touch_event, rewritten_event);
118 case TWO_TO_ONE_FINGER: 145 case TWO_TO_ONE_FINGER:
119 return InTwoToOneFinger(touch_event, rewritten_event); 146 return InTwoToOneFinger(touch_event, rewritten_event);
120 case PASSTHROUGH: 147 case PASSTHROUGH:
121 return InPassthrough(touch_event, rewritten_event); 148 return InPassthrough(touch_event, rewritten_event);
122 case WAIT_FOR_RELEASE: 149 case WAIT_FOR_RELEASE:
123 return InWaitForRelease(touch_event, rewritten_event); 150 return InWaitForRelease(touch_event, rewritten_event);
151 case SLIDE_GESTURE:
152 return InSlideGesture(touch_event, rewritten_event);
124 } 153 }
125 NOTREACHED(); 154 NOTREACHED();
126 return ui::EVENT_REWRITE_CONTINUE; 155 return ui::EVENT_REWRITE_CONTINUE;
127 } 156 }
128 157
129 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent( 158 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent(
130 const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) { 159 const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) {
131 NOTREACHED(); 160 NOTREACHED();
132 return ui::EVENT_REWRITE_CONTINUE; 161 return ui::EVENT_REWRITE_CONTINUE;
133 } 162 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 213
185 float delta_time = 214 float delta_time =
186 (event.time_stamp() - initial_press_->time_stamp()).InSecondsF(); 215 (event.time_stamp() - initial_press_->time_stamp()).InSecondsF();
187 float velocity = distance / delta_time; 216 float velocity = distance / delta_time;
188 VLOG(0) << "\n Delta time: " << delta_time 217 VLOG(0) << "\n Delta time: " << delta_time
189 << "\n Distance: " << distance 218 << "\n Distance: " << distance
190 << "\n Velocity of click: " << velocity 219 << "\n Velocity of click: " << velocity
191 << "\n Minimum swipe velocity: " 220 << "\n Minimum swipe velocity: "
192 << gesture_detector_config_.minimum_swipe_velocity; 221 << gesture_detector_config_.minimum_swipe_velocity;
193 222
223 // Change to slide gesture if the slide occurred at the right edge.
224 int where = WithinBoundsOfEdge(event.location(), kMaxDistanceFromEdge);
aboxhall 2014/07/22 17:20:41 Similarly, I think 'where' here is a little mislea
lisayin 2014/07/22 18:06:25 Done.
225 if (where & RIGHT_EDGE) {
226 state_ = SLIDE_GESTURE;
227 VLOG_STATE();
228 return InSlideGesture(event, rewritten_event);
229 }
230
194 // If the user moves fast enough from the initial touch location, start 231 // If the user moves fast enough from the initial touch location, start
195 // gesture detection. Otherwise, jump to the touch exploration mode early. 232 // gesture detection. Otherwise, jump to the touch exploration mode early.
196 if (velocity > gesture_detector_config_.minimum_swipe_velocity) { 233 if (velocity > gesture_detector_config_.minimum_swipe_velocity) {
197 state_ = GESTURE_IN_PROGRESS; 234 state_ = GESTURE_IN_PROGRESS;
198 VLOG_STATE(); 235 VLOG_STATE();
199 return InGestureInProgress(event, rewritten_event); 236 return InGestureInProgress(event, rewritten_event);
200 } 237 }
201 EnterTouchToMouseMode(); 238 EnterTouchToMouseMode();
202 state_ = TOUCH_EXPLORATION; 239 state_ = TOUCH_EXPLORATION;
203 VLOG_STATE(); 240 VLOG_STATE();
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 return ui::EVENT_REWRITE_CONTINUE; 527 return ui::EVENT_REWRITE_CONTINUE;
491 } 528 }
492 if (current_touch_ids_.size() == 0) { 529 if (current_touch_ids_.size() == 0) {
493 state_ = NO_FINGERS_DOWN; 530 state_ = NO_FINGERS_DOWN;
494 VLOG_STATE(); 531 VLOG_STATE();
495 ResetToNoFingersDown(); 532 ResetToNoFingersDown();
496 } 533 }
497 return EVENT_REWRITE_DISCARD; 534 return EVENT_REWRITE_DISCARD;
498 } 535 }
499 536
537 void TouchExplorationController::PlaySoundForTimer() {
538 delegate_->PlayVolumeAdjustSound();
539 }
540
541 ui::EventRewriteStatus TouchExplorationController::InSlideGesture(
542 const ui::TouchEvent& event,
543 scoped_ptr<ui::Event>* rewritten_event) {
544 // The timer should not fire when sliding.
545 if (tap_timer_.IsRunning())
546 tap_timer_.Stop();
547
548 ui::EventType type = event.type();
549 // If additional fingers are added before a swipe gesture has been registered,
550 // then wait until all fingers have been lifted.
551 if (type == ui::ET_TOUCH_PRESSED ||
552 event.touch_id() != initial_press_->touch_id()) {
553 if (sound_timer_.IsRunning())
554 sound_timer_.Stop();
555 // Discard any pending gestures.
556 ignore_result(gesture_provider_.GetAndResetPendingGestures());
557 state_ = WAIT_FOR_RELEASE;
558 return EVENT_REWRITE_DISCARD;
559 }
560
561 // Allows user to return to the edge to adjust the sound if they have left the
562 // boundaries.
563 int where = WithinBoundsOfEdge(event.location(), kSlopDistanceFromEdge);
564 if (!(where & RIGHT_EDGE) && (type != ui::ET_TOUCH_RELEASED)) {
565 if (sound_timer_.IsRunning()) {
566 sound_timer_.Stop();
567 }
568 return EVENT_REWRITE_DISCARD;
569 }
570
571 // This can occur if the user leaves the screen edge and then returns to it to
572 // continue adjusting the sound.
573 if (!sound_timer_.IsRunning()) {
574 sound_timer_.Start(FROM_HERE,
575 kSoundDelay,
576 this,
577 &ui::TouchExplorationController::PlaySoundForTimer);
578 delegate_->PlayVolumeAdjustSound();
579 }
580
581 // There should not be more than one finger down.
582 DCHECK(current_touch_ids_.size() <= 1);
583 if (type == ui::ET_TOUCH_MOVED) {
584 gesture_provider_.OnTouchEvent(event);
585 gesture_provider_.OnTouchEventAck(false);
586 }
587 if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
588 gesture_provider_.OnTouchEvent(event);
589 gesture_provider_.OnTouchEventAck(false);
590 ignore_result(gesture_provider_.GetAndResetPendingGestures());
591 if (current_touch_ids_.size() == 0)
592 ResetToNoFingersDown();
593 return ui::EVENT_REWRITE_DISCARD;
594 }
595
596 ProcessGestureEvents();
597 return ui::EVENT_REWRITE_DISCARD;
598 }
599
500 void TouchExplorationController::OnTapTimerFired() { 600 void TouchExplorationController::OnTapTimerFired() {
501 switch (state_) { 601 switch (state_) {
502 case SINGLE_TAP_RELEASED: 602 case SINGLE_TAP_RELEASED:
503 ResetToNoFingersDown(); 603 ResetToNoFingersDown();
504 break; 604 break;
505 case TOUCH_EXPLORE_RELEASED: 605 case TOUCH_EXPLORE_RELEASED:
506 ResetToNoFingersDown(); 606 ResetToNoFingersDown();
507 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); 607 last_touch_exploration_.reset(new TouchEvent(*initial_press_));
508 return; 608 return;
509 case SINGLE_TAP_PRESSED: 609 case SINGLE_TAP_PRESSED:
510 case GESTURE_IN_PROGRESS: 610 case GESTURE_IN_PROGRESS:
511 // Discard any pending gestures. 611 // Discard any pending gestures.
512 ignore_result(gesture_provider_.GetAndResetPendingGestures()); 612 ignore_result(gesture_provider_.GetAndResetPendingGestures());
513 EnterTouchToMouseMode(); 613 EnterTouchToMouseMode();
514 state_ = TOUCH_EXPLORATION; 614 state_ = TOUCH_EXPLORATION;
515 VLOG_STATE(); 615 VLOG_STATE();
516 break; 616 break;
517 default: 617 default:
518 return; 618 return;
519 } 619 }
520 scoped_ptr<ui::Event> mouse_move = 620 scoped_ptr<ui::Event> mouse_move =
521 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); 621 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags());
522 DispatchEvent(mouse_move.get()); 622 DispatchEvent(mouse_move.get());
523 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); 623 last_touch_exploration_.reset(new TouchEvent(*initial_press_));
524 } 624 }
525 625
526 void TouchExplorationController::DispatchEvent(ui::Event* event) { 626 void TouchExplorationController::DispatchEvent(ui::Event* event) {
527 if (event_handler_for_testing_) { 627 if (event_handler_for_testing_) {
528 event_handler_for_testing_->OnEvent(event); 628 event_handler_for_testing_->OnEvent(event);
529 return; 629 return;
530 } 630 }
531 ui::EventDispatchDetails result ALLOW_UNUSED = 631 ui::EventDispatchDetails result ALLOW_UNUSED =
532 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); 632 root_window_->GetHost()->dispatcher()->OnEventFromSource(event);
533 } 633 }
534 634
535 void TouchExplorationController::OnGestureEvent(ui::GestureEvent* gesture) { 635 void TouchExplorationController::OnGestureEvent(
636 ui::GestureEvent* gesture) {
536 CHECK(gesture->IsGestureEvent()); 637 CHECK(gesture->IsGestureEvent());
638 ui::EventType type = gesture->type();
537 VLOG(0) << " \n Gesture Triggered: " << gesture->name(); 639 VLOG(0) << " \n Gesture Triggered: " << gesture->name();
538 if (gesture->type() == ui::ET_GESTURE_SWIPE) { 640 if (type == ui::ET_GESTURE_SWIPE && state_ != SLIDE_GESTURE) {
539 if (tap_timer_.IsRunning()) 641 VLOG(0) << "Swipe!";
540 tap_timer_.Stop(); 642 ignore_result(gesture_provider_.GetAndResetPendingGestures());
541 OnSwipeEvent(gesture); 643 OnSwipeEvent(gesture);
542 return; 644 return;
543 } 645 }
544 } 646 }
545 647
546 void TouchExplorationController::ProcessGestureEvents() { 648 void TouchExplorationController::ProcessGestureEvents() {
547 scoped_ptr<ScopedVector<ui::GestureEvent> > gestures( 649 scoped_ptr<ScopedVector<ui::GestureEvent> > gestures(
548 gesture_provider_.GetAndResetPendingGestures()); 650 gesture_provider_.GetAndResetPendingGestures());
549 if (gestures) { 651 if (gestures) {
550 for (ScopedVector<GestureEvent>::iterator i = gestures->begin(); 652 for (ScopedVector<GestureEvent>::iterator i = gestures->begin();
551 i != gestures->end(); 653 i != gestures->end();
552 ++i) { 654 ++i) {
553 OnGestureEvent(*i); 655 if (state_ == SLIDE_GESTURE)
656 SideSlideControl(*i);
657 else
658 OnGestureEvent(*i);
554 } 659 }
555 } 660 }
556 } 661 }
557 662
663 void TouchExplorationController::SideSlideControl(ui::GestureEvent* gesture) {
664 ui::EventType type = gesture->type();
665 if (!gesture->IsScrollGestureEvent())
666 return;
667
668 if (type == ET_GESTURE_SCROLL_BEGIN) {
669 delegate_->PlayVolumeAdjustSound();
670 }
671
672 if (type == ET_GESTURE_SCROLL_END) {
673 if (sound_timer_.IsRunning())
674 sound_timer_.Stop();
675 delegate_->PlayVolumeAdjustSound();
676 }
677
678 // If the user is in the corner of the right side of the screen, the volume
679 // will be automatically set to 100% or muted depending on which corner they
680 // are in. Otherwise, the user will be able to adjust the volume by sliding
681 // their finger along the right side of the screen. Volume is relative to
682 // where they are on the right side of the screen.
683 gfx::Point location = gesture->location();
684 int where = WithinBoundsOfEdge(location, kSlopDistanceFromEdge);
685 if (!(where & RIGHT_EDGE))
686 return;
687
688 if (where == RIGHT_EDGE) {
689 location = gesture->location();
690 root_window_->GetHost()->ConvertPointFromNativeScreen(&location);
691 float volume_adjust_height =
692 root_window_->bounds().height() - 2 * kMaxDistanceFromEdge;
693 float ratio = (location.y() - kMaxDistanceFromEdge) / volume_adjust_height;
694 float volume = 100 - 100 * ratio;
695 VLOG(0) << "\n Volume = " << volume
696 << "\n Location = " << location.ToString()
697 << "\n Bounds = " << root_window_->bounds().right();
698
699 delegate_->SetOutputLevel(int(volume));
700 return;
701 }
702 else if (where & TOP_EDGE) {
dmazzoni 2014/07/22 17:14:54 nit: belongs on previous line after }
aboxhall 2014/07/22 17:20:41 Trivial, optional suggestion: move this and the be
lisayin 2014/07/22 18:06:25 Done.
703 delegate_->SetOutputLevel(100);
704 return;
705 } else if (where & BOTTOM_EDGE) {
706 delegate_->SetOutputLevel(0);
707 return;
708 }
709 NOTREACHED() << "Invalid location " << where;
710 }
711
712
558 void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) { 713 void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) {
559 // A swipe gesture contains details for the direction in which the swipe 714 // A swipe gesture contains details for the direction in which the swipe
560 // occurred. 715 // occurred.
561 GestureEventDetails event_details = swipe_gesture->details(); 716 GestureEventDetails event_details = swipe_gesture->details();
562 if (event_details.swipe_left()) { 717 if (event_details.swipe_left()) {
563 DispatchShiftSearchKeyEvent(ui::VKEY_LEFT); 718 DispatchShiftSearchKeyEvent(ui::VKEY_LEFT);
564 return; 719 return;
565 } else if (event_details.swipe_right()) { 720 } else if (event_details.swipe_right()) {
566 DispatchShiftSearchKeyEvent(ui::VKEY_RIGHT); 721 DispatchShiftSearchKeyEvent(ui::VKEY_RIGHT);
567 return; 722 return;
568 } else if (event_details.swipe_up()) { 723 } else if (event_details.swipe_up()) {
569 DispatchShiftSearchKeyEvent(ui::VKEY_UP); 724 DispatchShiftSearchKeyEvent(ui::VKEY_UP);
570 return; 725 return;
571 } else if (event_details.swipe_down()) { 726 } else if (event_details.swipe_down()) {
572 DispatchShiftSearchKeyEvent(ui::VKEY_DOWN); 727 DispatchShiftSearchKeyEvent(ui::VKEY_DOWN);
573 return; 728 return;
574 } 729 }
575 } 730 }
576 731
732 int TouchExplorationController::WithinBoundsOfEdge(gfx::Point point,
733 float bounds) {
734 // Since GetBoundsInScreen is in DIPs but point is not, then point needs to be
735 // converted.
736 root_window_->GetHost()->ConvertPointFromNativeScreen(&point);
737 gfx::Rect window = root_window_->GetBoundsInScreen();
738
739 float left_edge_limit = window.x() + bounds;
740 float right_edge_limit = window.right() - bounds;
741 float top_edge_limit = window.y() + bounds;
742 float bottom_edge_limit = window.bottom() - bounds;
743
744 // Bitwise manipulation in order to determine where on the screen the point
745 // lies. If more than one bit is turned on, then it is a corner where the two
746 // bit/edges intersect. Otherwise, if no bits are turned on, the point must be
747 // in the center of the screen.
748 int result = SCREEN_CENTER;
749 if (point.x() < left_edge_limit)
750 result |= LEFT_EDGE;
751 if (point.x() > right_edge_limit)
752 result |= RIGHT_EDGE;
753 if (point.y() < top_edge_limit)
754 result |= TOP_EDGE;
755 if (point.y() > bottom_edge_limit)
756 result |= BOTTOM_EDGE;
757 return result;
758 }
759
577 void TouchExplorationController::DispatchShiftSearchKeyEvent( 760 void TouchExplorationController::DispatchShiftSearchKeyEvent(
578 const ui::KeyboardCode direction) { 761 const ui::KeyboardCode direction) {
579 // In order to activate the shortcut shift+search+<arrow key> 762 // In order to activate the shortcut shift+search+<arrow key>
580 // three KeyPressed events must be dispatched in succession along 763 // three KeyPressed events must be dispatched in succession along
581 // with three KeyReleased events. 764 // with three KeyReleased events.
582 ui::KeyEvent shift_down = ui::KeyEvent( 765 ui::KeyEvent shift_down = ui::KeyEvent(
583 ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN, false); 766 ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN, false);
584 ui::KeyEvent search_down = ui::KeyEvent( 767 ui::KeyEvent search_down = ui::KeyEvent(
585 ui::ET_KEY_PRESSED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN, false); 768 ui::ET_KEY_PRESSED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN, false);
586 ui::KeyEvent direction_down = 769 ui::KeyEvent direction_down =
(...skipping 29 matching lines...) Expand all
616 void TouchExplorationController::EnterTouchToMouseMode() { 799 void TouchExplorationController::EnterTouchToMouseMode() {
617 aura::client::CursorClient* cursor_client = 800 aura::client::CursorClient* cursor_client =
618 aura::client::GetCursorClient(root_window_); 801 aura::client::GetCursorClient(root_window_);
619 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) 802 if (cursor_client && !cursor_client->IsMouseEventsEnabled())
620 cursor_client->EnableMouseEvents(); 803 cursor_client->EnableMouseEvents();
621 if (cursor_client && cursor_client->IsCursorVisible()) 804 if (cursor_client && cursor_client->IsCursorVisible())
622 cursor_client->HideCursor(); 805 cursor_client->HideCursor();
623 } 806 }
624 807
625 void TouchExplorationController::ResetToNoFingersDown() { 808 void TouchExplorationController::ResetToNoFingersDown() {
809 ProcessGestureEvents();
810 if (sound_timer_.IsRunning())
811 sound_timer_.Stop();
626 state_ = NO_FINGERS_DOWN; 812 state_ = NO_FINGERS_DOWN;
627 VLOG_STATE(); 813 VLOG_STATE();
628 if (tap_timer_.IsRunning()) 814 if (tap_timer_.IsRunning())
629 tap_timer_.Stop(); 815 tap_timer_.Stop();
630 } 816 }
631 817
632 void TouchExplorationController::VlogState(const char* function_name) { 818 void TouchExplorationController::VlogState(const char* function_name) {
633 if (!VLOG_on_) 819 if (!VLOG_on_)
634 return; 820 return;
635 if (prev_state_ == state_) 821 if (prev_state_ == state_)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 case GESTURE_IN_PROGRESS: 873 case GESTURE_IN_PROGRESS:
688 return "GESTURE_IN_PROGRESS"; 874 return "GESTURE_IN_PROGRESS";
689 case TOUCH_EXPLORE_SECOND_PRESS: 875 case TOUCH_EXPLORE_SECOND_PRESS:
690 return "TOUCH_EXPLORE_SECOND_PRESS"; 876 return "TOUCH_EXPLORE_SECOND_PRESS";
691 case TWO_TO_ONE_FINGER: 877 case TWO_TO_ONE_FINGER:
692 return "TWO_TO_ONE_FINGER"; 878 return "TWO_TO_ONE_FINGER";
693 case PASSTHROUGH: 879 case PASSTHROUGH:
694 return "PASSTHROUGH"; 880 return "PASSTHROUGH";
695 case WAIT_FOR_RELEASE: 881 case WAIT_FOR_RELEASE:
696 return "WAIT_FOR_RELEASE"; 882 return "WAIT_FOR_RELEASE";
883 case SLIDE_GESTURE:
884 return "SLIDE_GESTURE";
697 } 885 }
698 return "Not a state"; 886 return "Not a state";
699 } 887 }
700 888
701 } // namespace ui 889 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698