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" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 // In ChromeOS, VKEY_LWIN is synonymous for the search key. | 26 // In ChromeOS, VKEY_LWIN is synonymous for the search key. |
27 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN; | 27 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN; |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 TouchExplorationController::TouchExplorationController( | 30 TouchExplorationController::TouchExplorationController( |
31 aura::Window* root_window, | 31 aura::Window* root_window, |
32 TouchExplorationControllerDelegate* delegate) | 32 TouchExplorationControllerDelegate* delegate) |
33 : root_window_(root_window), | 33 : root_window_(root_window), |
34 delegate_(delegate), | 34 delegate_(delegate), |
35 state_(NO_FINGERS_DOWN), | 35 state_(NO_FINGERS_DOWN), |
36 event_handler_for_testing_(NULL), | |
37 gesture_provider_(this), | 36 gesture_provider_(this), |
38 prev_state_(NO_FINGERS_DOWN), | 37 prev_state_(NO_FINGERS_DOWN), |
39 VLOG_on_(true) { | 38 VLOG_on_(true) { |
40 CHECK(root_window); | 39 CHECK(root_window); |
41 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 40 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
42 } | 41 } |
43 | 42 |
44 TouchExplorationController::~TouchExplorationController() { | 43 TouchExplorationController::~TouchExplorationController() { |
45 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 44 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
46 } | 45 } |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 delete gesture_provider_.GetAndResetPendingGestures(); | 596 delete gesture_provider_.GetAndResetPendingGestures(); |
598 EnterTouchToMouseMode(); | 597 EnterTouchToMouseMode(); |
599 state_ = TOUCH_EXPLORATION; | 598 state_ = TOUCH_EXPLORATION; |
600 VLOG_STATE(); | 599 VLOG_STATE(); |
601 break; | 600 break; |
602 default: | 601 default: |
603 return; | 602 return; |
604 } | 603 } |
605 scoped_ptr<ui::Event> mouse_move = | 604 scoped_ptr<ui::Event> mouse_move = |
606 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); | 605 CreateMouseMoveEvent(initial_press_->location(), initial_press_->flags()); |
607 DispatchEvent(mouse_move.get()); | 606 DispatchEvent(mouse_move.get()); |
tdresser
2014/07/28 20:11:30
Do we need a |EnterTouchToMouseMode()| before this
| |
608 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 607 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); |
609 } | 608 } |
610 | 609 |
611 void TouchExplorationController::DispatchEvent(ui::Event* event) { | 610 void TouchExplorationController::DispatchEvent(ui::Event* event) { |
612 if (event_handler_for_testing_) { | |
613 event_handler_for_testing_->OnEvent(event); | |
614 return; | |
615 } | |
616 ui::EventDispatchDetails result ALLOW_UNUSED = | 611 ui::EventDispatchDetails result ALLOW_UNUSED = |
617 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); | 612 root_window_->GetHost()->dispatcher()->OnEventFromSource(event); |
618 } | 613 } |
619 | 614 |
620 void TouchExplorationController::OnGestureEvent( | 615 void TouchExplorationController::OnGestureEvent( |
621 ui::GestureEvent* gesture) { | 616 ui::GestureEvent* gesture) { |
622 CHECK(gesture->IsGestureEvent()); | 617 CHECK(gesture->IsGestureEvent()); |
623 ui::EventType type = gesture->type(); | 618 ui::EventType type = gesture->type(); |
624 VLOG(0) << " \n Gesture Triggered: " << gesture->name(); | 619 VLOG(0) << " \n Gesture Triggered: " << gesture->name(); |
625 if (type == ui::ET_GESTURE_SWIPE && state_ != SLIDE_GESTURE) { | 620 if (type == ui::ET_GESTURE_SWIPE && state_ != SLIDE_GESTURE) { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 return "PASSTHROUGH"; | 871 return "PASSTHROUGH"; |
877 case WAIT_FOR_RELEASE: | 872 case WAIT_FOR_RELEASE: |
878 return "WAIT_FOR_RELEASE"; | 873 return "WAIT_FOR_RELEASE"; |
879 case SLIDE_GESTURE: | 874 case SLIDE_GESTURE: |
880 return "SLIDE_GESTURE"; | 875 return "SLIDE_GESTURE"; |
881 } | 876 } |
882 return "Not a state"; | 877 return "Not a state"; |
883 } | 878 } |
884 | 879 |
885 } // namespace ui | 880 } // namespace ui |
OLD | NEW |