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