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 17 matching lines...) Expand all Loading... |
28 // In ChromeOS, VKEY_LWIN is synonymous for the search key. | 28 // In ChromeOS, VKEY_LWIN is synonymous for the search key. |
29 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN; | 29 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN; |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 TouchExplorationController::TouchExplorationController( | 32 TouchExplorationController::TouchExplorationController( |
33 aura::Window* root_window, | 33 aura::Window* root_window, |
34 TouchExplorationControllerDelegate* delegate) | 34 TouchExplorationControllerDelegate* delegate) |
35 : root_window_(root_window), | 35 : root_window_(root_window), |
36 delegate_(delegate), | 36 delegate_(delegate), |
37 state_(NO_FINGERS_DOWN), | 37 state_(NO_FINGERS_DOWN), |
| 38 event_handler_for_testing_(NULL), |
38 gesture_provider_(this), | 39 gesture_provider_(this), |
39 prev_state_(NO_FINGERS_DOWN), | 40 prev_state_(NO_FINGERS_DOWN), |
40 VLOG_on_(true), | 41 VLOG_on_(true), |
41 tick_clock_(NULL) { | 42 tick_clock_(NULL) { |
42 CHECK(root_window); | 43 CHECK(root_window); |
43 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 44 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
44 } | 45 } |
45 | 46 |
46 TouchExplorationController::~TouchExplorationController() { | 47 TouchExplorationController::~TouchExplorationController() { |
47 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 48 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 last_touch_exploration_->location(), | 586 last_touch_exploration_->location(), |
586 last_unused_finger_event_->touch_id(), | 587 last_unused_finger_event_->touch_id(), |
587 Now())); | 588 Now())); |
588 DispatchEvent(passthrough_press.get()); | 589 DispatchEvent(passthrough_press.get()); |
589 return; | 590 return; |
590 } | 591 } |
591 case SINGLE_TAP_PRESSED: | 592 case SINGLE_TAP_PRESSED: |
592 case GESTURE_IN_PROGRESS: | 593 case GESTURE_IN_PROGRESS: |
593 // Discard any pending gestures. | 594 // Discard any pending gestures. |
594 delete gesture_provider_.GetAndResetPendingGestures(); | 595 delete gesture_provider_.GetAndResetPendingGestures(); |
| 596 EnterTouchToMouseMode(); |
595 state_ = TOUCH_EXPLORATION; | 597 state_ = TOUCH_EXPLORATION; |
596 VLOG_STATE(); | 598 VLOG_STATE(); |
597 break; | 599 break; |
598 default: | 600 default: |
599 return; | 601 return; |
600 } | 602 } |
601 EnterTouchToMouseMode(); | |
602 scoped_ptr<ui::Event> mouse_move = | 603 scoped_ptr<ui::Event> mouse_move = |
603 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); | 604 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); |
604 DispatchEvent(mouse_move.get()); | 605 DispatchEvent(mouse_move.get()); |
605 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 606 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); |
606 } | 607 } |
607 | 608 |
608 void TouchExplorationController::DispatchEvent(ui::Event* event) { | 609 void TouchExplorationController::DispatchEvent(ui::Event* event) { |
| 610 if (event_handler_for_testing_) { |
| 611 event_handler_for_testing_->OnEvent(event); |
| 612 return; |
| 613 } |
609 ui::EventDispatchDetails result ALLOW_UNUSED = | 614 ui::EventDispatchDetails result ALLOW_UNUSED = |
610 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); | 615 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); |
611 } | 616 } |
612 | 617 |
613 void TouchExplorationController::OnGestureEvent( | 618 void TouchExplorationController::OnGestureEvent( |
614 ui::GestureEvent* gesture) { | 619 ui::GestureEvent* gesture) { |
615 CHECK(gesture->IsGestureEvent()); | 620 CHECK(gesture->IsGestureEvent()); |
616 ui::EventType type = gesture->type(); | 621 ui::EventType type = gesture->type(); |
617 if (VLOG_on_) | 622 if (VLOG_on_) |
618 VLOG(0) << " \n Gesture Triggered: " << gesture->name(); | 623 VLOG(0) << " \n Gesture Triggered: " << gesture->name(); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 return "SLIDE_GESTURE"; | 878 return "SLIDE_GESTURE"; |
874 case ONE_FINGER_PASSTHROUGH: | 879 case ONE_FINGER_PASSTHROUGH: |
875 return "ONE_FINGER_PASSTHROUGH"; | 880 return "ONE_FINGER_PASSTHROUGH"; |
876 case WAIT_FOR_ONE_FINGER: | 881 case WAIT_FOR_ONE_FINGER: |
877 return "WAIT_FOR_ONE_FINGER"; | 882 return "WAIT_FOR_ONE_FINGER"; |
878 } | 883 } |
879 return "Not a state"; | 884 return "Not a state"; |
880 } | 885 } |
881 | 886 |
882 } // namespace ui | 887 } // namespace ui |
OLD | NEW |