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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/aura/client/cursor_client.h" | 8 #include "ui/aura/client/cursor_client.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_event_dispatcher.h" | |
10 #include "ui/aura/window_tree_host.h" | 11 #include "ui/aura/window_tree_host.h" |
11 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
13 #include "ui/events/event_processor.h" | |
12 | 14 |
13 namespace ui { | 15 namespace ui { |
14 | 16 |
15 TouchExplorationController::TouchExplorationController( | 17 TouchExplorationController::TouchExplorationController( |
16 aura::Window* root_window) | 18 aura::Window* root_window) |
17 : root_window_(root_window) { | 19 : root_window_(root_window), |
20 state_(NO_FINGERS_DOWN) { | |
18 CHECK(root_window); | 21 CHECK(root_window); |
19 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 22 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
20 } | 23 } |
21 | 24 |
22 TouchExplorationController::~TouchExplorationController() { | 25 TouchExplorationController::~TouchExplorationController() { |
23 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 26 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
24 } | 27 } |
25 | 28 |
26 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( | 29 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
27 const ui::Event& event, | 30 const ui::Event& event, |
28 scoped_ptr<ui::Event>* rewritten_event) { | 31 scoped_ptr<ui::Event>* rewritten_event) { |
29 if (!event.IsTouchEvent()) | 32 if (!event.IsTouchEvent()) |
30 return ui::EVENT_REWRITE_CONTINUE; | 33 return ui::EVENT_REWRITE_CONTINUE; |
31 | 34 |
32 const ui::TouchEvent& touch_event = | 35 const ui::TouchEvent& touch_event = |
33 static_cast<const ui::TouchEvent&>(event); | 36 static_cast<const ui::TouchEvent&>(event); |
34 const ui::EventType type = touch_event.type(); | 37 const ui::EventType type = touch_event.type(); |
35 const gfx::PointF& location = touch_event.location_f(); | 38 const gfx::PointF& location = touch_event.location_f(); |
36 const int touch_id = touch_event.touch_id(); | 39 const int touch_id = touch_event.touch_id(); |
37 const int flags = touch_event.flags(); | 40 |
38 | 41 // Always update touch ids and touch locations, so we can use those |
42 // no matter what state we're in. | |
39 if (type == ui::ET_TOUCH_PRESSED) { | 43 if (type == ui::ET_TOUCH_PRESSED) { |
40 touch_ids_.push_back(touch_id); | 44 touch_ids_.push_back(touch_id); |
41 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location)); | 45 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location)); |
42 // If this is the first and only finger touching - rewrite the touch as a | |
43 // mouse move. Otherwise let the it go through as is. | |
44 if (touch_ids_.size() == 1) { | |
45 *rewritten_event = CreateMouseMoveEvent(location, flags); | |
46 EnterTouchToMouseMode(); | |
47 return ui::EVENT_REWRITE_REWRITTEN; | |
48 } | |
49 return ui::EVENT_REWRITE_CONTINUE; | |
50 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 46 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
51 std::vector<int>::iterator it = | 47 std::vector<int>::iterator it = |
52 std::find(touch_ids_.begin(), touch_ids_.end(), touch_id); | 48 std::find(touch_ids_.begin(), touch_ids_.end(), touch_id); |
53 // We may fail to find the finger if the exploration mode was turned on | 49 |
54 // while the user had some fingers touching the screen. We simply ignore | 50 // Can happen if touch exploration is enabled while fingers were down. |
55 // those fingers for the purposes of event transformation. | |
56 if (it == touch_ids_.end()) | 51 if (it == touch_ids_.end()) |
57 return ui::EVENT_REWRITE_CONTINUE; | 52 return ui::EVENT_REWRITE_CONTINUE; |
58 const bool first_finger_released = it == touch_ids_.begin(); | 53 |
59 touch_ids_.erase(it); | 54 touch_ids_.erase(it); |
60 int num_erased = touch_locations_.erase(touch_id); | 55 touch_locations_.erase(touch_id); |
61 DCHECK_EQ(num_erased, 1); | |
62 const int num_fingers_remaining = touch_ids_.size(); | |
63 | |
64 if (num_fingers_remaining == 0) { | |
65 *rewritten_event = CreateMouseMoveEvent(location, flags); | |
66 return ui::EVENT_REWRITE_REWRITTEN; | |
67 } | |
68 | |
69 // If we are left with one finger - enter the mouse move mode. | |
70 const bool enter_mouse_move_mode = num_fingers_remaining == 1; | |
71 | |
72 if (!enter_mouse_move_mode && !first_finger_released) { | |
73 // No special handling needed. | |
74 return ui::EVENT_REWRITE_CONTINUE; | |
75 } | |
76 | |
77 // If the finger which was released was the first one, - we need to rewrite | |
78 // the release event as a release of the was second / now first finger. | |
79 // This is the finger which will now be getting "substracted". | |
80 if (first_finger_released) { | |
81 int rewritten_release_id = touch_ids_[0]; | |
82 const gfx::PointF& rewritten_release_location = | |
83 touch_locations_[rewritten_release_id]; | |
84 ui::TouchEvent* rewritten_release_event = new ui::TouchEvent( | |
85 ui::ET_TOUCH_RELEASED, | |
86 rewritten_release_location, | |
87 rewritten_release_id, | |
88 event.time_stamp()); | |
89 rewritten_release_event->set_flags(touch_event.flags()); | |
90 rewritten_event->reset(rewritten_release_event); | |
91 } else if (enter_mouse_move_mode) { | |
92 // Dispatch the release event as is. | |
93 // TODO(mfomitchev): We can get rid of this clause once we have | |
94 // EVENT_REWRITE_DISPATCH_ANOTHER working without having to set | |
95 // rewritten_event. | |
96 rewritten_event->reset(new ui::TouchEvent(touch_event)); | |
97 } | |
98 | |
99 if (enter_mouse_move_mode) { | |
100 // Since we are entering the mouse move mode - also dispatch a mouse move | |
101 // event at the location of the one remaining finger. (num_fingers == 1) | |
102 const gfx::PointF& mouse_move_location = touch_locations_[touch_ids_[0]]; | |
103 next_dispatch_event_ = | |
104 CreateMouseMoveEvent(mouse_move_location, flags).Pass(); | |
105 return ui::EVENT_REWRITE_DISPATCH_ANOTHER; | |
106 } | |
107 return ui::EVENT_REWRITE_REWRITTEN; | |
108 } else if (type == ui::ET_TOUCH_MOVED) { | 56 } else if (type == ui::ET_TOUCH_MOVED) { |
109 std::vector<int>::iterator it = | 57 std::vector<int>::iterator it = |
110 std::find(touch_ids_.begin(), touch_ids_.end(), touch_id); | 58 std::find(touch_ids_.begin(), touch_ids_.end(), touch_id); |
111 // We may fail to find the finger if the exploration mode was turned on | 59 |
112 // while the user had some fingers touching the screen. We simply ignore | 60 // Can happen if touch exploration is enabled while fingers were down. |
113 // those fingers for the purposes of event transformation. | |
114 if (it == touch_ids_.end()) | 61 if (it == touch_ids_.end()) |
115 return ui::EVENT_REWRITE_CONTINUE; | 62 return ui::EVENT_REWRITE_CONTINUE; |
63 | |
116 touch_locations_[*it] = location; | 64 touch_locations_[*it] = location; |
117 if (touch_ids_.size() == 1) { | 65 } |
118 // Touch moves are rewritten as mouse moves when there's only one finger | 66 |
119 // touching the screen. | 67 // The rest of the processing depends on what state we're in. |
mfomitchev
2014/05/28 17:47:45
I really like how you've broken it up into multipl
dmazzoni
2014/05/31 06:53:24
Thanks!
| |
120 *rewritten_event = CreateMouseMoveEvent(location, flags).Pass(); | 68 switch(state_) { |
121 return ui::EVENT_REWRITE_REWRITTEN; | 69 case NO_FINGERS_DOWN: |
70 return OnNoFingersDown(touch_event, rewritten_event); | |
71 case GRACE_PERIOD: | |
72 return OnGracePeriod(touch_event, rewritten_event); | |
73 case TOUCH_EXPLORATION: | |
74 return OnTouchExploration(touch_event, rewritten_event); | |
75 case SINGLE_TAP_PENDING: | |
76 return OnSingleTapPending(touch_event, rewritten_event); | |
77 case DOUBLE_TAP_PRESSED: | |
78 return OnDoubleTapPressed(touch_event, rewritten_event); | |
79 case PASSTHROUGH_MINUS_ONE: | |
80 return OnPassthroughMinusOne(touch_event, rewritten_event); | |
81 } | |
82 | |
83 NOTREACHED(); | |
84 return ui::EVENT_REWRITE_CONTINUE; | |
85 } | |
86 | |
87 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent( | |
88 const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) { | |
89 NOTREACHED(); | |
90 return ui::EVENT_REWRITE_CONTINUE; | |
91 } | |
92 | |
93 ui::EventRewriteStatus TouchExplorationController::OnNoFingersDown( | |
94 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | |
95 const ui::EventType type = event.type(); | |
96 if (type == ui::ET_TOUCH_PRESSED) { | |
97 initial_press_.reset(new TouchEvent(event)); | |
mfomitchev
2014/05/28 17:47:45
Why create a new event instead of using the one we
dmazzoni
2014/05/31 06:53:24
We don't have ownership of the event passed in, we
mfomitchev
2014/06/02 23:12:18
Done.
| |
98 tap_timer_.Start(FROM_HERE, | |
mfomitchev
2014/05/28 17:47:45
We should probably Stop() the timer as we transiti
dmazzoni
2014/05/31 06:53:24
Starting the timer again does what it should - it
mfomitchev
2014/06/02 23:12:18
Yes, makes sense.
| |
99 gesture_detector_config_.double_tap_timeout, | |
100 this, | |
101 &TouchExplorationController::OnTapTimerFired); | |
102 state_ = GRACE_PERIOD; | |
103 return ui::EVENT_REWRITE_DISCARD; | |
104 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | |
105 // Can happen if touch exploration is enabled while fingers were down. | |
106 return ui::EVENT_REWRITE_DISCARD; | |
mfomitchev
2014/05/28 17:47:45
I don't think we can get here since we'd have no t
dmazzoni
2014/05/31 06:53:24
I agree that it shouldn't happen, so I added a NOT
| |
107 } else if (type == ui::ET_TOUCH_MOVED) { | |
108 // Can happen if touch exploration is enabled while fingers were down. | |
109 return ui::EVENT_REWRITE_DISCARD; | |
mfomitchev
2014/05/28 17:47:45
Same as above
dmazzoni
2014/05/31 06:53:24
Done.
| |
110 } | |
111 NOTREACHED() << "Unexpected event type received."; | |
112 return ui::EVENT_REWRITE_CONTINUE; | |
113 } | |
114 | |
115 ui::EventRewriteStatus TouchExplorationController::OnGracePeriod( | |
116 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | |
117 const ui::EventType type = event.type(); | |
118 if (event.time_stamp() - initial_press_->time_stamp() > | |
119 gesture_detector_config_.double_tap_timeout) { | |
120 EnterTouchToMouseMode(); | |
121 state_ = TOUCH_EXPLORATION; | |
mfomitchev
2014/05/28 17:47:45
I think you need to somehow dispatch the mouse mov
dmazzoni
2014/05/31 06:53:24
If this is a mouse move, calling OnTouchExploratio
| |
122 return OnTouchExploration(event, rewritten_event); | |
123 } | |
124 | |
125 if (type == ui::ET_TOUCH_PRESSED) { | |
126 // Adding a second finger within the timeout period switches to | |
127 // passthrough. | |
128 state_ = PASSTHROUGH_MINUS_ONE; | |
129 return OnPassthroughMinusOne(event, rewritten_event); | |
130 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | |
131 if (touch_ids_.size() == 0) | |
mfomitchev
2014/05/28 17:47:45
Isn't this if superflous? Should this be a DCHECK(
dmazzoni
2014/05/31 06:53:24
Agreed.
| |
132 state_ = SINGLE_TAP_PENDING; | |
133 | |
134 return EVENT_REWRITE_DISCARD; | |
135 } else if (type == ui::ET_TOUCH_MOVED) { | |
136 // If the user moves far enough from the initial touch location (outside | |
mfomitchev
2014/05/28 17:47:45
When we write the code to determine if this is a s
dmazzoni
2014/05/31 06:53:24
Sounds good.
| |
137 // the "slop" region, jump to the touch exploration mode early. Note that | |
138 // when we add gesture recognition, we should probably jump to gesture | |
139 // mode here if the velocity is high enough, and touch exploration if | |
140 // the velocity is lower. | |
141 float delta = (event.location() - initial_press_->location()).Length(); | |
142 if (delta > gesture_detector_config_.touch_slop) { | |
143 EnterTouchToMouseMode(); | |
144 state_ = TOUCH_EXPLORATION; | |
145 return OnTouchExploration(event, rewritten_event); | |
122 } | 146 } |
123 if (touch_id == touch_ids_.front()) { | 147 |
124 // Touch moves of the first finger are discarded when there's more than | 148 return EVENT_REWRITE_DISCARD; |
125 // one finger touching. | 149 } |
150 NOTREACHED() << "Unexpected event type received."; | |
151 return ui::EVENT_REWRITE_CONTINUE; | |
152 } | |
153 | |
154 ui::EventRewriteStatus TouchExplorationController::OnTouchExploration( | |
155 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | |
156 const ui::EventType type = event.type(); | |
157 if (type == ui::ET_TOUCH_PRESSED) { | |
158 // Ignore any additional fingers when we're already in touch exploration | |
mfomitchev
2014/05/28 17:47:45
That's not how Android works. I guess we are okay
dmazzoni
2014/05/31 06:53:24
I think I prefer this for now, but we'll do some u
| |
159 // mode. Later, we should support "split-tap". | |
160 return ui::EVENT_REWRITE_DISCARD; | |
161 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | |
162 if (touch_ids_.size() == 0) { | |
163 state_ = NO_FINGERS_DOWN; | |
126 return ui::EVENT_REWRITE_DISCARD; | 164 return ui::EVENT_REWRITE_DISCARD; |
mfomitchev
2014/05/28 17:47:45
We used to generate a mouse move for the release i
dmazzoni
2014/05/31 06:53:24
Agreed, I changed the logic to generate a mouse mo
| |
127 } | 165 } |
166 } else if (type == ui::ET_TOUCH_MOVED) { | |
167 // Rewrite as a mouse-move event. | |
168 *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags()); | |
169 last_touch_exploration_location_ = event.location(); | |
170 return ui::EVENT_REWRITE_REWRITTEN; | |
mfomitchev
2014/05/28 17:47:45
This would get a bit nuts if you are moving multip
dmazzoni
2014/05/31 06:53:24
I'm tempted to not worry about this case for now b
| |
171 } | |
172 NOTREACHED() << "Unexpected event type received."; | |
173 return ui::EVENT_REWRITE_CONTINUE; | |
174 } | |
175 | |
176 ui::EventRewriteStatus TouchExplorationController::OnSingleTapPending( | |
177 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | |
178 const ui::EventType type = event.type(); | |
179 if (type == ui::ET_TOUCH_PRESSED) { | |
180 // Rewrite at location of last touch exploration. | |
181 ui::TouchEvent* rewritten_release_event = new ui::TouchEvent( | |
182 ui::ET_TOUCH_PRESSED, | |
183 last_touch_exploration_location_, | |
184 event.touch_id(), | |
185 event.time_stamp()); | |
186 rewritten_release_event->set_flags(event.flags()); | |
187 rewritten_event->reset(rewritten_release_event); | |
188 state_ = DOUBLE_TAP_PRESSED; | |
189 return ui::EVENT_REWRITE_REWRITTEN; | |
190 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | |
191 // Can happen if touch exploration is enabled while fingers were down. | |
mfomitchev
2014/05/28 17:47:45
I think this is NOTREACHED() as we have code to ca
dmazzoni
2014/05/31 06:53:24
Done.
| |
128 return ui::EVENT_REWRITE_CONTINUE; | 192 return ui::EVENT_REWRITE_CONTINUE; |
129 } | 193 } else if (type == ui::ET_TOUCH_MOVED) { |
130 NOTREACHED() << "Unexpected event type received."; | 194 // Can happen if touch exploration is enabled while fingers were down. |
131 return ui::EVENT_REWRITE_CONTINUE; | 195 return ui::EVENT_REWRITE_CONTINUE; |
mfomitchev
2014/05/28 17:47:45
Same
dmazzoni
2014/05/31 06:53:24
Done.
| |
132 } | 196 } |
133 | 197 NOTREACHED() << "Unexpected event type received."; |
134 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent( | 198 return ui::EVENT_REWRITE_CONTINUE; |
135 const ui::Event& last_event, | 199 } |
136 scoped_ptr<ui::Event>* new_event) { | 200 |
137 CHECK(next_dispatch_event_); | 201 ui::EventRewriteStatus TouchExplorationController::OnDoubleTapPressed( |
138 DCHECK(last_event.IsTouchEvent()); | 202 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
139 *new_event = next_dispatch_event_.Pass(); | 203 const ui::EventType type = event.type(); |
140 // Enter the mouse move mode if needed | 204 if (type == ui::ET_TOUCH_PRESSED) { |
141 if ((*new_event)->IsMouseEvent()) | 205 return ui::EVENT_REWRITE_DISCARD; |
142 EnterTouchToMouseMode(); | 206 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
207 if (touch_ids_.size() != 0) | |
208 return EVENT_REWRITE_DISCARD; | |
209 | |
210 // Rewrite at location of last touch exploration. | |
211 ui::TouchEvent* rewritten_release_event = new ui::TouchEvent( | |
212 ui::ET_TOUCH_RELEASED, | |
213 last_touch_exploration_location_, | |
214 event.touch_id(), | |
215 event.time_stamp()); | |
216 rewritten_release_event->set_flags(event.flags()); | |
217 rewritten_event->reset(rewritten_release_event); | |
218 state_ = NO_FINGERS_DOWN; | |
219 return ui::EVENT_REWRITE_REWRITTEN; | |
220 } else if (type == ui::ET_TOUCH_MOVED) { | |
221 return ui::EVENT_REWRITE_DISCARD; | |
222 } | |
223 NOTREACHED() << "Unexpected event type received."; | |
224 return ui::EVENT_REWRITE_CONTINUE; | |
225 } | |
226 | |
227 ui::EventRewriteStatus TouchExplorationController::OnPassthroughMinusOne( | |
228 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | |
229 ui::EventType type = event.type(); | |
230 if (type == ui::ET_TOUCH_PRESSED) { | |
231 // As each new finger is pressed, we map its touch id to itself. | |
232 // Any finger not in this map will be ignored. | |
233 touch_id_map_[event.touch_id()] = event.touch_id(); | |
234 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | |
235 if (touch_ids_.size() == 0) | |
236 state_ = NO_FINGERS_DOWN; | |
237 | |
238 // If removing a finger that was passed through, and another finger | |
mfomitchev
2014/05/28 17:47:45
Ok, so this means you can release any finger, not
dmazzoni
2014/05/31 06:53:24
Yes, that's the idea
| |
239 // was not being passed through, remap the not-passed-through finger | |
240 // to the id of the finger that's just being released from now on. | |
241 int releasing_id = event.touch_id(); | |
mfomitchev
2014/05/28 17:47:45
I think this code would become a lot simpler if we
dmazzoni
2014/05/31 06:53:24
Good idea. We don't even need a map now, just the
| |
242 if (touch_id_map_.find(releasing_id) != touch_id_map_.end()) { | |
243 for (size_t i = 0; i < touch_ids_.size(); ++i) { | |
244 int still_down_id = touch_ids_[i]; | |
245 if (touch_id_map_.find(still_down_id) == touch_id_map_.end()) { | |
246 touch_id_map_[still_down_id] = touch_id_map_[releasing_id]; | |
247 type = ui::ET_TOUCH_MOVED; | |
mfomitchev
2014/05/28 17:47:45
We are changing the type here, so I assume we want
dmazzoni
2014/05/31 06:53:24
Good catch, done.
| |
248 break; | |
249 } | |
250 } | |
251 } | |
252 touch_id_map_.erase(releasing_id); | |
253 } else if (type != ui::ET_TOUCH_MOVED) { | |
254 NOTREACHED() << "Unexpected event type received."; | |
255 return ui::EVENT_REWRITE_CONTINUE; | |
256 } | |
257 | |
258 if (touch_id_map_.find(event.touch_id()) == touch_id_map_.end()) | |
259 return ui::EVENT_REWRITE_DISCARD; | |
mfomitchev
2014/05/28 17:47:45
I don't realluy understand why is this needed - se
| |
260 | |
261 ui::TouchEvent* rewritten_passthrough_event = new ui::TouchEvent( | |
mfomitchev
2014/05/28 17:47:45
It seems suboptimal to rewrite the event every tim
dmazzoni
2014/05/31 06:53:24
Done.
| |
262 type, | |
263 event.location(), | |
264 touch_id_map_[event.touch_id()], | |
265 event.time_stamp()); | |
266 rewritten_passthrough_event->set_flags(event.flags()); | |
267 rewritten_event->reset(rewritten_passthrough_event); | |
143 return ui::EVENT_REWRITE_REWRITTEN; | 268 return ui::EVENT_REWRITE_REWRITTEN; |
144 } | 269 } |
145 | 270 |
271 void TouchExplorationController::OnTapTimerFired() { | |
272 if (state_ != SINGLE_TAP_PENDING) | |
mfomitchev
2014/05/28 17:47:45
Don't we need to dispatch a mouse move if we are i
dmazzoni
2014/05/31 06:53:24
Done.
| |
273 return; | |
274 | |
275 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, | |
mfomitchev
2014/05/28 17:47:45
Why not use CreateMouseMoveEvent() here?
dmazzoni
2014/05/31 06:53:24
Done.
| |
276 initial_press_->location(), | |
277 initial_press_->location(), | |
278 ui::EF_IS_SYNTHESIZED, | |
279 0); | |
280 ui::EventDispatchDetails result ALLOW_UNUSED = | |
281 root_window_->GetHost()->dispatcher()->OnEventFromSource(&mouse_move); | |
282 last_touch_exploration_location_ = initial_press_->location(); | |
283 state_ = NO_FINGERS_DOWN; | |
284 } | |
285 | |
146 scoped_ptr<ui::Event> TouchExplorationController::CreateMouseMoveEvent( | 286 scoped_ptr<ui::Event> TouchExplorationController::CreateMouseMoveEvent( |
147 const gfx::PointF& location, | 287 const gfx::PointF& location, |
148 int flags) { | 288 int flags) { |
149 return scoped_ptr<ui::Event>( | 289 return scoped_ptr<ui::Event>( |
150 new ui::MouseEvent(ui::ET_MOUSE_MOVED, | 290 new ui::MouseEvent(ui::ET_MOUSE_MOVED, |
151 location, | 291 location, |
152 location, | 292 location, |
153 flags | ui::EF_IS_SYNTHESIZED | ui::EF_FROM_TOUCH, | 293 flags | ui::EF_IS_SYNTHESIZED, |
154 0)); | 294 0)); |
155 } | 295 } |
156 | 296 |
157 void TouchExplorationController::EnterTouchToMouseMode() { | 297 void TouchExplorationController::EnterTouchToMouseMode() { |
158 aura::client::CursorClient* cursor_client = | 298 aura::client::CursorClient* cursor_client = |
159 aura::client::GetCursorClient(root_window_); | 299 aura::client::GetCursorClient(root_window_); |
160 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) | 300 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) |
161 cursor_client->EnableMouseEvents(); | 301 cursor_client->EnableMouseEvents(); |
162 if (cursor_client && cursor_client->IsCursorVisible()) | 302 if (cursor_client && cursor_client->IsCursorVisible()) |
163 cursor_client->HideCursor(); | 303 cursor_client->HideCursor(); |
164 } | 304 } |
165 | 305 |
166 } // namespace ui | 306 } // namespace ui |
OLD | NEW |