| 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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 ui::KeyEvent control_up(ui::ET_KEY_RELEASED, ui::VKEY_CONTROL, ui::EF_NONE); | 686 ui::KeyEvent control_up(ui::ET_KEY_RELEASED, ui::VKEY_CONTROL, ui::EF_NONE); |
| 687 | 687 |
| 688 DispatchEvent(&control_down); | 688 DispatchEvent(&control_down); |
| 689 DispatchEvent(&control_up); | 689 DispatchEvent(&control_up); |
| 690 SET_STATE(NO_FINGERS_DOWN); | 690 SET_STATE(NO_FINGERS_DOWN); |
| 691 return ui::EVENT_REWRITE_DISCARD; | 691 return ui::EVENT_REWRITE_DISCARD; |
| 692 } | 692 } |
| 693 return ui::EVENT_REWRITE_DISCARD; | 693 return ui::EVENT_REWRITE_DISCARD; |
| 694 } | 694 } |
| 695 | 695 |
| 696 base::TimeDelta TouchExplorationController::Now() { | 696 base::TimeTicks TouchExplorationController::Now() { |
| 697 if (tick_clock_) { | 697 if (tick_clock_) { |
| 698 // This is the same as what EventTimeForNow() does, but here we do it | 698 // This is the same as what EventTimeForNow() does, but here we do it |
| 699 // with a clock that can be replaced with a simulated clock for tests. | 699 // with a clock that can be replaced with a simulated clock for tests. |
| 700 return base::TimeDelta::FromInternalValue( | 700 return tick_clock_->NowTicks(); |
| 701 tick_clock_->NowTicks().ToInternalValue()); | |
| 702 } | 701 } |
| 703 return ui::EventTimeForNow(); | 702 return ui::EventTimeForNow(); |
| 704 } | 703 } |
| 705 | 704 |
| 706 void TouchExplorationController::StartTapTimer() { | 705 void TouchExplorationController::StartTapTimer() { |
| 707 tap_timer_.Start(FROM_HERE, | 706 tap_timer_.Start(FROM_HERE, |
| 708 gesture_detector_config_.double_tap_timeout, | 707 gesture_detector_config_.double_tap_timeout, |
| 709 this, | 708 this, |
| 710 &TouchExplorationController::OnTapTimerFired); | 709 &TouchExplorationController::OnTapTimerFired); |
| 711 } | 710 } |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 // This is a short-term workaround for the limitation that we're using | 1019 // This is a short-term workaround for the limitation that we're using |
| 1021 // the ChromeVox content script to process touch exploration events, but | 1020 // the ChromeVox content script to process touch exploration events, but |
| 1022 // ChromeVox needs a way to distinguish between a real mouse move and a | 1021 // ChromeVox needs a way to distinguish between a real mouse move and a |
| 1023 // mouse move generated from touch exploration, so we have touch exploration | 1022 // mouse move generated from touch exploration, so we have touch exploration |
| 1024 // pretend that the command key was down (which becomes the "meta" key in | 1023 // pretend that the command key was down (which becomes the "meta" key in |
| 1025 // JavaScript). We can remove this hack when the ChromeVox content script | 1024 // JavaScript). We can remove this hack when the ChromeVox content script |
| 1026 // goes away and native accessibility code sends a touch exploration | 1025 // goes away and native accessibility code sends a touch exploration |
| 1027 // event to the new ChromeVox background page via the automation api. | 1026 // event to the new ChromeVox background page via the automation api. |
| 1028 flags |= ui::EF_COMMAND_DOWN; | 1027 flags |= ui::EF_COMMAND_DOWN; |
| 1029 | 1028 |
| 1030 std::unique_ptr<ui::MouseEvent> event( | 1029 std::unique_ptr<ui::MouseEvent> event(new ui::MouseEvent( |
| 1031 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 1030 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), Now(), flags, 0)); |
| 1032 ui::EventTimeForNow(), flags, 0)); | |
| 1033 event->set_location_f(location); | 1031 event->set_location_f(location); |
| 1034 event->set_root_location_f(location); | 1032 event->set_root_location_f(location); |
| 1035 return event; | 1033 return event; |
| 1036 } | 1034 } |
| 1037 | 1035 |
| 1038 void TouchExplorationController::EnterTouchToMouseMode() { | 1036 void TouchExplorationController::EnterTouchToMouseMode() { |
| 1039 aura::client::CursorClient* cursor_client = | 1037 aura::client::CursorClient* cursor_client = |
| 1040 aura::client::GetCursorClient(root_window_); | 1038 aura::client::GetCursorClient(root_window_); |
| 1041 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) | 1039 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) |
| 1042 cursor_client->EnableMouseEvents(); | 1040 cursor_client->EnableMouseEvents(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 return "TWO_FINGER_TAP"; | 1148 return "TWO_FINGER_TAP"; |
| 1151 } | 1149 } |
| 1152 return "Not a state"; | 1150 return "Not a state"; |
| 1153 } | 1151 } |
| 1154 | 1152 |
| 1155 float TouchExplorationController::GetSplitTapTouchSlop() { | 1153 float TouchExplorationController::GetSplitTapTouchSlop() { |
| 1156 return gesture_detector_config_.touch_slop * 3; | 1154 return gesture_detector_config_.touch_slop * 3; |
| 1157 } | 1155 } |
| 1158 | 1156 |
| 1159 } // namespace ui | 1157 } // namespace ui |
| OLD | NEW |