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

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: 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 void TouchExplorationController::SetTouchAccessibilityAnchorPoint( 51 void TouchExplorationController::SetTouchAccessibilityAnchorPoint(
52 const gfx::Point& anchor_point) { 52 const gfx::Point& anchor_point) {
53 gfx::Point native_point = anchor_point; 53 gfx::Point native_point = anchor_point;
54 root_window_->GetHost()->ConvertPointToNativeScreen(&native_point); 54 root_window_->GetHost()->ConvertPointToNativeScreen(&native_point);
55 55
56 anchor_point_ = gfx::PointF(native_point.x(), native_point.y()); 56 anchor_point_ = gfx::PointF(native_point.x(), native_point.y());
57 anchor_point_state_ = ANCHOR_POINT_EXPLICITLY_SET; 57 anchor_point_state_ = ANCHOR_POINT_EXPLICITLY_SET;
58 } 58 }
59 59
60 void TouchExplorationController::SetExcludeBounds(const gfx::Rect& bounds) {
61 exclude_bounds_ = bounds;
62 }
63
60 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( 64 ui::EventRewriteStatus TouchExplorationController::RewriteEvent(
61 const ui::Event& event, 65 const ui::Event& event,
62 std::unique_ptr<ui::Event>* rewritten_event) { 66 std::unique_ptr<ui::Event>* rewritten_event) {
63 if (!event.IsTouchEvent()) { 67 if (!event.IsTouchEvent()) {
64 if (event.IsKeyEvent()) { 68 if (event.IsKeyEvent()) {
65 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); 69 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event);
66 VLOG(0) << "\nKeyboard event: " << key_event.name() 70 VLOG(0) << "\nKeyboard event: " << key_event.name()
67 << "\n Key code: " << key_event.key_code() 71 << "\n Key code: " << key_event.key_code()
68 << ", Flags: " << key_event.flags() 72 << ", Flags: " << key_event.flags()
69 << ", Is char: " << key_event.is_char(); 73 << ", Is char: " << key_event.is_char();
70 } 74 }
71 return ui::EVENT_REWRITE_CONTINUE; 75 return ui::EVENT_REWRITE_CONTINUE;
72 } 76 }
73 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); 77 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event);
74 78
79 if (!exclude_bounds_.IsEmpty()) {
80 gfx::Point location = touch_event.location();
81 root_window_->GetHost()->ConvertPointFromNativeScreen(&location);
82 bool in_exclude_area = exclude_bounds_.Contains(location);
83 if (in_exclude_area) {
84 if (state_ == NO_FINGERS_DOWN)
85 return ui::EVENT_REWRITE_CONTINUE;
86 if (touch_event.type() == ui::ET_TOUCH_MOVED ||
87 touch_event.type() == ui::ET_TOUCH_PRESSED) {
88 return ui::EVENT_REWRITE_DISCARD;
89 }
90 // Otherwise, continue handling events. Basically, we want to let
91 // CANCELLED or RELEASE events through so this can get back to
92 // the NO_FINGERS_DOWN state.
93 }
94 }
95
75 // If the tap timer should have fired by now but hasn't, run it now and 96 // If the tap timer should have fired by now but hasn't, run it now and
76 // stop the timer. This is important so that behavior is consistent with 97 // stop the timer. This is important so that behavior is consistent with
77 // the timestamps of the events, and not dependent on the granularity of 98 // the timestamps of the events, and not dependent on the granularity of
78 // the timer. 99 // the timer.
79 if (tap_timer_.IsRunning() && 100 if (tap_timer_.IsRunning() &&
80 touch_event.time_stamp() - initial_press_->time_stamp() > 101 touch_event.time_stamp() - initial_press_->time_stamp() >
81 gesture_detector_config_.double_tap_timeout) { 102 gesture_detector_config_.double_tap_timeout) {
82 tap_timer_.Stop(); 103 tap_timer_.Stop();
83 OnTapTimerFired(); 104 OnTapTimerFired();
84 // Note: this may change the state. We should now continue and process 105 // Note: this may change the state. We should now continue and process
(...skipping 13 matching lines...) Expand all
98 119
99 // Always update touch ids and touch locations, so we can use those 120 // Always update touch ids and touch locations, so we can use those
100 // no matter what state we're in. 121 // no matter what state we're in.
101 if (type == ui::ET_TOUCH_PRESSED) { 122 if (type == ui::ET_TOUCH_PRESSED) {
102 current_touch_ids_.push_back(touch_id); 123 current_touch_ids_.push_back(touch_id);
103 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location)); 124 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location));
104 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { 125 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
105 std::vector<int>::iterator it = std::find( 126 std::vector<int>::iterator it = std::find(
106 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id); 127 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id);
107 128
108 // Can happen if touch exploration is enabled while fingers were down. 129 // Can happen if touch exploration is enabled while fingers were down
130 // or if an additional press occurred within the exclusion bounds.
109 if (it == current_touch_ids_.end()) 131 if (it == current_touch_ids_.end())
110 return ui::EVENT_REWRITE_CONTINUE; 132 return ui::EVENT_REWRITE_CONTINUE;
111 133
112 current_touch_ids_.erase(it); 134 current_touch_ids_.erase(it);
113 touch_locations_.erase(touch_id); 135 touch_locations_.erase(touch_id);
114 } else if (type == ui::ET_TOUCH_MOVED) { 136 } else if (type == ui::ET_TOUCH_MOVED) {
115 std::vector<int>::iterator it = std::find( 137 std::vector<int>::iterator it = std::find(
116 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id); 138 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id);
117 139
118 // Can happen if touch exploration is enabled while fingers were down. 140 // Can happen if touch exploration is enabled while fingers were down.
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 return "TWO_FINGER_TAP"; 1162 return "TWO_FINGER_TAP";
1141 } 1163 }
1142 return "Not a state"; 1164 return "Not a state";
1143 } 1165 }
1144 1166
1145 float TouchExplorationController::GetSplitTapTouchSlop() { 1167 float TouchExplorationController::GetSplitTapTouchSlop() {
1146 return gesture_detector_config_.touch_slop * 3; 1168 return gesture_detector_config_.touch_slop * 3;
1147 } 1169 }
1148 1170
1149 } // namespace ui 1171 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698