| 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" |
| 11 #include "ui/accessibility/ax_enums.h" | 11 #include "ui/accessibility/ax_enums.h" |
| 12 #include "ui/aura/client/cursor_client.h" | 12 #include "ui/aura/client/cursor_client.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
| 15 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
| 16 #include "ui/chromeos/touch_accessibility_enabler.h" |
| 16 #include "ui/events/event.h" | 17 #include "ui/events/event.h" |
| 17 #include "ui/events/event_processor.h" | 18 #include "ui/events/event_processor.h" |
| 18 #include "ui/events/event_utils.h" | 19 #include "ui/events/event_utils.h" |
| 19 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 20 | 21 |
| 21 #define SET_STATE(state) SetState(state, __func__) | 22 #define SET_STATE(state) SetState(state, __func__) |
| 22 #define VLOG_EVENT(event) \ | 23 #define VLOG_EVENT(event) \ |
| 23 if (VLOG_IS_ON(1)) \ | 24 if (VLOG_IS_ON(1)) \ |
| 24 VlogEvent(event, __func__) | 25 VlogEvent(event, __func__) |
| 25 | 26 |
| 26 namespace ui { | 27 namespace ui { |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // Delay between adjustment sounds. | 31 // Delay between adjustment sounds. |
| 31 const int kSoundDelayInMS = 150; | 32 const int kSoundDelayInMS = 150; |
| 32 | 33 |
| 33 void SetTouchAccessibilityFlag(ui::Event* event) { | 34 void SetTouchAccessibilityFlag(ui::Event* event) { |
| 34 // This flag is used to identify mouse move events that were generated from | 35 // This flag is used to identify mouse move events that were generated from |
| 35 // touch exploration in Chrome code. | 36 // touch exploration in Chrome code. |
| 36 event->set_flags(event->flags() | ui::EF_TOUCH_ACCESSIBILITY); | 37 event->set_flags(event->flags() | ui::EF_TOUCH_ACCESSIBILITY); |
| 37 } | 38 } |
| 38 | 39 |
| 39 } // namespace | 40 } // namespace |
| 40 | 41 |
| 41 TouchExplorationController::TouchExplorationController( | 42 TouchExplorationController::TouchExplorationController( |
| 42 aura::Window* root_window, | 43 aura::Window* root_window, |
| 43 TouchExplorationControllerDelegate* delegate) | 44 TouchExplorationControllerDelegate* delegate, |
| 45 TouchAccessibilityEnabler* touch_accessibility_enabler) |
| 44 : root_window_(root_window), | 46 : root_window_(root_window), |
| 45 delegate_(delegate), | 47 delegate_(delegate), |
| 46 state_(NO_FINGERS_DOWN), | 48 state_(NO_FINGERS_DOWN), |
| 47 anchor_point_state_(ANCHOR_POINT_NONE), | 49 anchor_point_state_(ANCHOR_POINT_NONE), |
| 48 gesture_provider_(new GestureProviderAura(this, this)), | 50 gesture_provider_(new GestureProviderAura(this, this)), |
| 49 prev_state_(NO_FINGERS_DOWN), | 51 prev_state_(NO_FINGERS_DOWN), |
| 50 VLOG_on_(true) { | 52 VLOG_on_(true), |
| 53 touch_accessibility_enabler_(touch_accessibility_enabler) { |
| 51 DCHECK(root_window); | 54 DCHECK(root_window); |
| 52 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 55 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
| 53 } | 56 } |
| 54 | 57 |
| 55 TouchExplorationController::~TouchExplorationController() { | 58 TouchExplorationController::~TouchExplorationController() { |
| 56 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 59 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
| 57 } | 60 } |
| 58 | 61 |
| 59 void TouchExplorationController::SetTouchAccessibilityAnchorPoint( | 62 void TouchExplorationController::SetTouchAccessibilityAnchorPoint( |
| 60 const gfx::Point& anchor_point) { | 63 const gfx::Point& anchor_point) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 77 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | 80 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); |
| 78 VLOG(1) << "\nKeyboard event: " << key_event.name() | 81 VLOG(1) << "\nKeyboard event: " << key_event.name() |
| 79 << "\n Key code: " << key_event.key_code() | 82 << "\n Key code: " << key_event.key_code() |
| 80 << ", Flags: " << key_event.flags() | 83 << ", Flags: " << key_event.flags() |
| 81 << ", Is char: " << key_event.is_char(); | 84 << ", Is char: " << key_event.is_char(); |
| 82 } | 85 } |
| 83 return ui::EVENT_REWRITE_CONTINUE; | 86 return ui::EVENT_REWRITE_CONTINUE; |
| 84 } | 87 } |
| 85 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); | 88 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); |
| 86 | 89 |
| 90 // Let TouchAccessibilityEnabler process the unrewritten event. |
| 91 if (touch_accessibility_enabler_) |
| 92 touch_accessibility_enabler_->HandleTouchEvent(touch_event); |
| 93 |
| 87 if (!exclude_bounds_.IsEmpty()) { | 94 if (!exclude_bounds_.IsEmpty()) { |
| 88 gfx::Point location = touch_event.location(); | 95 gfx::Point location = touch_event.location(); |
| 89 root_window_->GetHost()->ConvertPointFromNativeScreen(&location); | 96 root_window_->GetHost()->ConvertPointFromNativeScreen(&location); |
| 90 bool in_exclude_area = exclude_bounds_.Contains(location); | 97 bool in_exclude_area = exclude_bounds_.Contains(location); |
| 91 if (in_exclude_area) { | 98 if (in_exclude_area) { |
| 92 if (state_ == NO_FINGERS_DOWN) | 99 if (state_ == NO_FINGERS_DOWN) |
| 93 return ui::EVENT_REWRITE_CONTINUE; | 100 return ui::EVENT_REWRITE_CONTINUE; |
| 94 if (touch_event.type() == ui::ET_TOUCH_MOVED || | 101 if (touch_event.type() == ui::ET_TOUCH_MOVED || |
| 95 touch_event.type() == ui::ET_TOUCH_PRESSED) { | 102 touch_event.type() == ui::ET_TOUCH_PRESSED) { |
| 96 return ui::EVENT_REWRITE_DISCARD; | 103 return ui::EVENT_REWRITE_DISCARD; |
| (...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 return "TWO_FINGER_TAP"; | 1190 return "TWO_FINGER_TAP"; |
| 1184 } | 1191 } |
| 1185 return "Not a state"; | 1192 return "Not a state"; |
| 1186 } | 1193 } |
| 1187 | 1194 |
| 1188 float TouchExplorationController::GetSplitTapTouchSlop() { | 1195 float TouchExplorationController::GetSplitTapTouchSlop() { |
| 1189 return gesture_detector_config_.touch_slop * 3; | 1196 return gesture_detector_config_.touch_slop * 3; |
| 1190 } | 1197 } |
| 1191 | 1198 |
| 1192 } // namespace ui | 1199 } // namespace ui |
| OLD | NEW |