Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: ui/chromeos/touch_exploration_controller.cc

Issue 2378773011: Only exclude workarea from touch-exploration with active shell-surface (Closed)
Patch Set: resolved merge issues in unittest Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 void TouchExplorationController::SetTouchAccessibilityAnchorPoint( 57 void TouchExplorationController::SetTouchAccessibilityAnchorPoint(
58 const gfx::Point& anchor_point) { 58 const gfx::Point& anchor_point) {
59 gfx::Point native_point = anchor_point; 59 gfx::Point native_point = anchor_point;
60 root_window_->GetHost()->ConvertPointToNativeScreen(&native_point); 60 root_window_->GetHost()->ConvertPointToNativeScreen(&native_point);
61 61
62 anchor_point_ = gfx::PointF(native_point.x(), native_point.y()); 62 anchor_point_ = gfx::PointF(native_point.x(), native_point.y());
63 anchor_point_state_ = ANCHOR_POINT_EXPLICITLY_SET; 63 anchor_point_state_ = ANCHOR_POINT_EXPLICITLY_SET;
64 } 64 }
65 65
66 void TouchExplorationController::SetExcludeBounds(const gfx::Rect& bounds) {
67 exclude_bounds_ = bounds;
68 }
69
66 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( 70 ui::EventRewriteStatus TouchExplorationController::RewriteEvent(
67 const ui::Event& event, 71 const ui::Event& event,
68 std::unique_ptr<ui::Event>* rewritten_event) { 72 std::unique_ptr<ui::Event>* rewritten_event) {
69 if (!event.IsTouchEvent()) { 73 if (!event.IsTouchEvent()) {
70 if (event.IsKeyEvent()) { 74 if (event.IsKeyEvent()) {
71 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); 75 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event);
72 VLOG(0) << "\nKeyboard event: " << key_event.name() 76 VLOG(0) << "\nKeyboard event: " << key_event.name()
73 << "\n Key code: " << key_event.key_code() 77 << "\n Key code: " << key_event.key_code()
74 << ", Flags: " << key_event.flags() 78 << ", Flags: " << key_event.flags()
75 << ", Is char: " << key_event.is_char(); 79 << ", Is char: " << key_event.is_char();
76 } 80 }
77 return ui::EVENT_REWRITE_CONTINUE; 81 return ui::EVENT_REWRITE_CONTINUE;
78 } 82 }
79 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); 83 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event);
80 84
85 if (!exclude_bounds_.IsEmpty()) {
86 gfx::Point location = touch_event.location();
87 root_window_->GetHost()->ConvertPointFromNativeScreen(&location);
88 bool in_exclude_area = exclude_bounds_.Contains(location);
89 if (in_exclude_area) {
90 if (state_ == NO_FINGERS_DOWN)
91 return ui::EVENT_REWRITE_CONTINUE;
92 if (touch_event.type() == ui::ET_TOUCH_MOVED ||
93 touch_event.type() == ui::ET_TOUCH_PRESSED) {
94 return ui::EVENT_REWRITE_DISCARD;
95 }
96 // Otherwise, continue handling events. Basically, we want to let
97 // CANCELLED or RELEASE events through so this can get back to
98 // the NO_FINGERS_DOWN state.
99 }
100 }
101
81 // If the tap timer should have fired by now but hasn't, run it now and 102 // If the tap timer should have fired by now but hasn't, run it now and
82 // stop the timer. This is important so that behavior is consistent with 103 // stop the timer. This is important so that behavior is consistent with
83 // the timestamps of the events, and not dependent on the granularity of 104 // the timestamps of the events, and not dependent on the granularity of
84 // the timer. 105 // the timer.
85 if (tap_timer_.IsRunning() && 106 if (tap_timer_.IsRunning() &&
86 touch_event.time_stamp() - initial_press_->time_stamp() > 107 touch_event.time_stamp() - initial_press_->time_stamp() >
87 gesture_detector_config_.double_tap_timeout) { 108 gesture_detector_config_.double_tap_timeout) {
88 tap_timer_.Stop(); 109 tap_timer_.Stop();
89 OnTapTimerFired(); 110 OnTapTimerFired();
90 // Note: this may change the state. We should now continue and process 111 // Note: this may change the state. We should now continue and process
(...skipping 13 matching lines...) Expand all
104 125
105 // Always update touch ids and touch locations, so we can use those 126 // Always update touch ids and touch locations, so we can use those
106 // no matter what state we're in. 127 // no matter what state we're in.
107 if (type == ui::ET_TOUCH_PRESSED) { 128 if (type == ui::ET_TOUCH_PRESSED) {
108 current_touch_ids_.push_back(touch_id); 129 current_touch_ids_.push_back(touch_id);
109 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location)); 130 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location));
110 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { 131 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
111 std::vector<int>::iterator it = std::find( 132 std::vector<int>::iterator it = std::find(
112 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id); 133 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id);
113 134
114 // Can happen if touch exploration is enabled while fingers were down. 135 // Can happen if touch exploration is enabled while fingers were down
136 // or if an additional press occurred within the exclusion bounds.
115 if (it == current_touch_ids_.end()) 137 if (it == current_touch_ids_.end())
116 return ui::EVENT_REWRITE_CONTINUE; 138 return ui::EVENT_REWRITE_CONTINUE;
117 139
118 current_touch_ids_.erase(it); 140 current_touch_ids_.erase(it);
119 touch_locations_.erase(touch_id); 141 touch_locations_.erase(touch_id);
120 } else if (type == ui::ET_TOUCH_MOVED) { 142 } else if (type == ui::ET_TOUCH_MOVED) {
121 std::vector<int>::iterator it = std::find( 143 std::vector<int>::iterator it = std::find(
122 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id); 144 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id);
123 145
124 // Can happen if touch exploration is enabled while fingers were down. 146 // Can happen if touch exploration is enabled while fingers were down.
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 return "TWO_FINGER_TAP"; 1182 return "TWO_FINGER_TAP";
1161 } 1183 }
1162 return "Not a state"; 1184 return "Not a state";
1163 } 1185 }
1164 1186
1165 float TouchExplorationController::GetSplitTapTouchSlop() { 1187 float TouchExplorationController::GetSplitTapTouchSlop() {
1166 return gesture_detector_config_.touch_slop * 3; 1188 return gesture_detector_config_.touch_slop * 3;
1167 } 1189 }
1168 1190
1169 } // namespace ui 1191 } // namespace ui
OLDNEW
« no previous file with comments | « ui/chromeos/touch_exploration_controller.h ('k') | ui/chromeos/touch_exploration_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698