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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 ui::KeyEvent control_up(ui::ET_KEY_RELEASED, ui::VKEY_CONTROL, ui::EF_NONE); | 681 ui::KeyEvent control_up(ui::ET_KEY_RELEASED, ui::VKEY_CONTROL, ui::EF_NONE); |
682 | 682 |
683 DispatchEvent(&control_down); | 683 DispatchEvent(&control_down); |
684 DispatchEvent(&control_up); | 684 DispatchEvent(&control_up); |
685 SET_STATE(NO_FINGERS_DOWN); | 685 SET_STATE(NO_FINGERS_DOWN); |
686 return ui::EVENT_REWRITE_DISCARD; | 686 return ui::EVENT_REWRITE_DISCARD; |
687 } | 687 } |
688 return ui::EVENT_REWRITE_DISCARD; | 688 return ui::EVENT_REWRITE_DISCARD; |
689 } | 689 } |
690 | 690 |
691 base::TimeDelta TouchExplorationController::Now() { | 691 base::TimeTicks TouchExplorationController::Now() { |
692 if (tick_clock_) { | 692 if (tick_clock_) { |
693 // This is the same as what EventTimeForNow() does, but here we do it | 693 // This is the same as what EventTimeForNow() does, but here we do it |
694 // with a clock that can be replaced with a simulated clock for tests. | 694 // with a clock that can be replaced with a simulated clock for tests. |
695 return base::TimeDelta::FromInternalValue( | 695 return tick_clock_->NowTicks(); |
696 tick_clock_->NowTicks().ToInternalValue()); | |
697 } | 696 } |
698 return ui::EventTimeForNow(); | 697 return ui::EventTimeForNow(); |
699 } | 698 } |
700 | 699 |
701 void TouchExplorationController::StartTapTimer() { | 700 void TouchExplorationController::StartTapTimer() { |
702 tap_timer_.Start(FROM_HERE, | 701 tap_timer_.Start(FROM_HERE, |
703 gesture_detector_config_.double_tap_timeout, | 702 gesture_detector_config_.double_tap_timeout, |
704 this, | 703 this, |
705 &TouchExplorationController::OnTapTimerFired); | 704 &TouchExplorationController::OnTapTimerFired); |
706 } | 705 } |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 // This is a short-term workaround for the limitation that we're using | 1011 // This is a short-term workaround for the limitation that we're using |
1013 // the ChromeVox content script to process touch exploration events, but | 1012 // the ChromeVox content script to process touch exploration events, but |
1014 // ChromeVox needs a way to distinguish between a real mouse move and a | 1013 // ChromeVox needs a way to distinguish between a real mouse move and a |
1015 // mouse move generated from touch exploration, so we have touch exploration | 1014 // mouse move generated from touch exploration, so we have touch exploration |
1016 // pretend that the command key was down (which becomes the "meta" key in | 1015 // pretend that the command key was down (which becomes the "meta" key in |
1017 // JavaScript). We can remove this hack when the ChromeVox content script | 1016 // JavaScript). We can remove this hack when the ChromeVox content script |
1018 // goes away and native accessibility code sends a touch exploration | 1017 // goes away and native accessibility code sends a touch exploration |
1019 // event to the new ChromeVox background page via the automation api. | 1018 // event to the new ChromeVox background page via the automation api. |
1020 flags |= ui::EF_COMMAND_DOWN; | 1019 flags |= ui::EF_COMMAND_DOWN; |
1021 | 1020 |
1022 std::unique_ptr<ui::MouseEvent> event( | 1021 std::unique_ptr<ui::MouseEvent> event(new ui::MouseEvent( |
1023 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 1022 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), Now(), flags, 0)); |
1024 ui::EventTimeForNow(), flags, 0)); | |
1025 event->set_location_f(location); | 1023 event->set_location_f(location); |
1026 event->set_root_location_f(location); | 1024 event->set_root_location_f(location); |
1027 return event; | 1025 return event; |
1028 } | 1026 } |
1029 | 1027 |
1030 void TouchExplorationController::EnterTouchToMouseMode() { | 1028 void TouchExplorationController::EnterTouchToMouseMode() { |
1031 aura::client::CursorClient* cursor_client = | 1029 aura::client::CursorClient* cursor_client = |
1032 aura::client::GetCursorClient(root_window_); | 1030 aura::client::GetCursorClient(root_window_); |
1033 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) | 1031 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) |
1034 cursor_client->EnableMouseEvents(); | 1032 cursor_client->EnableMouseEvents(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 return "TWO_FINGER_TAP"; | 1140 return "TWO_FINGER_TAP"; |
1143 } | 1141 } |
1144 return "Not a state"; | 1142 return "Not a state"; |
1145 } | 1143 } |
1146 | 1144 |
1147 float TouchExplorationController::GetSplitTapTouchSlop() { | 1145 float TouchExplorationController::GetSplitTapTouchSlop() { |
1148 return gesture_detector_config_.touch_slop * 3; | 1146 return gesture_detector_config_.touch_slop * 3; |
1149 } | 1147 } |
1150 | 1148 |
1151 } // namespace ui | 1149 } // namespace ui |
OLD | NEW |