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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 47 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
48 InitializeSwipeGestureMaps(); | 48 InitializeSwipeGestureMaps(); |
49 } | 49 } |
50 | 50 |
51 TouchExplorationController::~TouchExplorationController() { | 51 TouchExplorationController::~TouchExplorationController() { |
52 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 52 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
53 } | 53 } |
54 | 54 |
55 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( | 55 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
56 const ui::Event& event, | 56 const ui::Event& event, |
57 scoped_ptr<ui::Event>* rewritten_event) { | 57 std::unique_ptr<ui::Event>* rewritten_event) { |
58 if (!event.IsTouchEvent()) { | 58 if (!event.IsTouchEvent()) { |
59 if (event.IsKeyEvent()) { | 59 if (event.IsKeyEvent()) { |
60 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | 60 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); |
61 VLOG(0) << "\nKeyboard event: " << key_event.name() | 61 VLOG(0) << "\nKeyboard event: " << key_event.name() |
62 << "\n Key code: " << key_event.key_code() | 62 << "\n Key code: " << key_event.key_code() |
63 << ", Flags: " << key_event.flags() | 63 << ", Flags: " << key_event.flags() |
64 << ", Is char: " << key_event.is_char(); | 64 << ", Is char: " << key_event.is_char(); |
65 } | 65 } |
66 return ui::EVENT_REWRITE_CONTINUE; | 66 return ui::EVENT_REWRITE_CONTINUE; |
67 } | 67 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 case WAIT_FOR_NO_FINGERS: | 184 case WAIT_FOR_NO_FINGERS: |
185 return InWaitForNoFingers(touch_event, rewritten_event); | 185 return InWaitForNoFingers(touch_event, rewritten_event); |
186 case TWO_FINGER_TAP: | 186 case TWO_FINGER_TAP: |
187 return InTwoFingerTap(touch_event, rewritten_event); | 187 return InTwoFingerTap(touch_event, rewritten_event); |
188 } | 188 } |
189 NOTREACHED(); | 189 NOTREACHED(); |
190 return ui::EVENT_REWRITE_CONTINUE; | 190 return ui::EVENT_REWRITE_CONTINUE; |
191 } | 191 } |
192 | 192 |
193 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent( | 193 ui::EventRewriteStatus TouchExplorationController::NextDispatchEvent( |
194 const ui::Event& last_event, scoped_ptr<ui::Event>* new_event) { | 194 const ui::Event& last_event, |
| 195 std::unique_ptr<ui::Event>* new_event) { |
195 NOTREACHED(); | 196 NOTREACHED(); |
196 return ui::EVENT_REWRITE_CONTINUE; | 197 return ui::EVENT_REWRITE_CONTINUE; |
197 } | 198 } |
198 | 199 |
199 ui::EventRewriteStatus TouchExplorationController::InNoFingersDown( | 200 ui::EventRewriteStatus TouchExplorationController::InNoFingersDown( |
200 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 201 const ui::TouchEvent& event, |
| 202 std::unique_ptr<ui::Event>* rewritten_event) { |
201 const ui::EventType type = event.type(); | 203 const ui::EventType type = event.type(); |
202 if (type != ui::ET_TOUCH_PRESSED) { | 204 if (type != ui::ET_TOUCH_PRESSED) { |
203 NOTREACHED() << "Unexpected event type received: " << event.name(); | 205 NOTREACHED() << "Unexpected event type received: " << event.name(); |
204 return ui::EVENT_REWRITE_CONTINUE; | 206 return ui::EVENT_REWRITE_CONTINUE; |
205 } | 207 } |
206 | 208 |
207 // If the user enters the screen from the edge then send an earcon. | 209 // If the user enters the screen from the edge then send an earcon. |
208 int edge = FindEdgesWithinBounds(event.location(), kLeavingScreenEdge); | 210 int edge = FindEdgesWithinBounds(event.location(), kLeavingScreenEdge); |
209 if (edge != NO_EDGE) | 211 if (edge != NO_EDGE) |
210 delegate_->PlayEnterScreenEarcon(); | 212 delegate_->PlayEnterScreenEarcon(); |
(...skipping 12 matching lines...) Expand all Loading... |
223 } | 225 } |
224 initial_press_.reset(new TouchEvent(event)); | 226 initial_press_.reset(new TouchEvent(event)); |
225 initial_presses_[event.touch_id()] = event.location(); | 227 initial_presses_[event.touch_id()] = event.location(); |
226 last_unused_finger_event_.reset(new TouchEvent(event)); | 228 last_unused_finger_event_.reset(new TouchEvent(event)); |
227 StartTapTimer(); | 229 StartTapTimer(); |
228 SET_STATE(SINGLE_TAP_PRESSED); | 230 SET_STATE(SINGLE_TAP_PRESSED); |
229 return ui::EVENT_REWRITE_DISCARD; | 231 return ui::EVENT_REWRITE_DISCARD; |
230 } | 232 } |
231 | 233 |
232 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( | 234 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( |
233 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 235 const ui::TouchEvent& event, |
| 236 std::unique_ptr<ui::Event>* rewritten_event) { |
234 const ui::EventType type = event.type(); | 237 const ui::EventType type = event.type(); |
235 | 238 |
236 int location = FindEdgesWithinBounds(event.location(), kMaxDistanceFromEdge); | 239 int location = FindEdgesWithinBounds(event.location(), kMaxDistanceFromEdge); |
237 bool in_a_bottom_corner = | 240 bool in_a_bottom_corner = |
238 (location == BOTTOM_LEFT_CORNER) || (location == BOTTOM_RIGHT_CORNER); | 241 (location == BOTTOM_LEFT_CORNER) || (location == BOTTOM_RIGHT_CORNER); |
239 // If the event is from the initial press and the location is no longer in the | 242 // If the event is from the initial press and the location is no longer in the |
240 // corner, then we are not waiting for a corner passthrough anymore. | 243 // corner, then we are not waiting for a corner passthrough anymore. |
241 if (event.touch_id() == initial_press_->touch_id() && !in_a_bottom_corner) { | 244 if (event.touch_id() == initial_press_->touch_id() && !in_a_bottom_corner) { |
242 if (passthrough_timer_.IsRunning()) { | 245 if (passthrough_timer_.IsRunning()) { |
243 passthrough_timer_.Stop(); | 246 passthrough_timer_.Stop(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 SET_STATE(TOUCH_EXPLORATION); | 302 SET_STATE(TOUCH_EXPLORATION); |
300 return InTouchExploration(event, rewritten_event); | 303 return InTouchExploration(event, rewritten_event); |
301 } | 304 } |
302 NOTREACHED(); | 305 NOTREACHED(); |
303 return ui::EVENT_REWRITE_CONTINUE; | 306 return ui::EVENT_REWRITE_CONTINUE; |
304 } | 307 } |
305 | 308 |
306 ui::EventRewriteStatus | 309 ui::EventRewriteStatus |
307 TouchExplorationController::InSingleTapOrTouchExploreReleased( | 310 TouchExplorationController::InSingleTapOrTouchExploreReleased( |
308 const ui::TouchEvent& event, | 311 const ui::TouchEvent& event, |
309 scoped_ptr<ui::Event>* rewritten_event) { | 312 std::unique_ptr<ui::Event>* rewritten_event) { |
310 const ui::EventType type = event.type(); | 313 const ui::EventType type = event.type(); |
311 // If there is more than one finger down, then discard to wait until no | 314 // If there is more than one finger down, then discard to wait until no |
312 // fingers are down. | 315 // fingers are down. |
313 if (current_touch_ids_.size() > 1) { | 316 if (current_touch_ids_.size() > 1) { |
314 SET_STATE(WAIT_FOR_NO_FINGERS); | 317 SET_STATE(WAIT_FOR_NO_FINGERS); |
315 return ui::EVENT_REWRITE_DISCARD; | 318 return ui::EVENT_REWRITE_DISCARD; |
316 } | 319 } |
317 if (type == ui::ET_TOUCH_PRESSED) { | 320 if (type == ui::ET_TOUCH_PRESSED) { |
318 // If there is no touch exploration yet, we can't send a click, so discard. | 321 // If there is no touch exploration yet, we can't send a click, so discard. |
319 if (!last_touch_exploration_) { | 322 if (!last_touch_exploration_) { |
(...skipping 22 matching lines...) Expand all Loading... |
342 return ui::EVENT_REWRITE_DISCARD; | 345 return ui::EVENT_REWRITE_DISCARD; |
343 } else if (type == ui::ET_TOUCH_MOVED) { | 346 } else if (type == ui::ET_TOUCH_MOVED) { |
344 return ui::EVENT_REWRITE_DISCARD; | 347 return ui::EVENT_REWRITE_DISCARD; |
345 } | 348 } |
346 NOTREACHED(); | 349 NOTREACHED(); |
347 return ui::EVENT_REWRITE_CONTINUE; | 350 return ui::EVENT_REWRITE_CONTINUE; |
348 } | 351 } |
349 | 352 |
350 ui::EventRewriteStatus TouchExplorationController::InDoubleTapPending( | 353 ui::EventRewriteStatus TouchExplorationController::InDoubleTapPending( |
351 const ui::TouchEvent& event, | 354 const ui::TouchEvent& event, |
352 scoped_ptr<ui::Event>* rewritten_event) { | 355 std::unique_ptr<ui::Event>* rewritten_event) { |
353 const ui::EventType type = event.type(); | 356 const ui::EventType type = event.type(); |
354 if (type == ui::ET_TOUCH_PRESSED) { | 357 if (type == ui::ET_TOUCH_PRESSED) { |
355 return ui::EVENT_REWRITE_DISCARD; | 358 return ui::EVENT_REWRITE_DISCARD; |
356 } else if (type == ui::ET_TOUCH_MOVED) { | 359 } else if (type == ui::ET_TOUCH_MOVED) { |
357 // If the user moves far enough from the initial touch location (outside | 360 // If the user moves far enough from the initial touch location (outside |
358 // the "slop" region, jump to passthrough mode early. | 361 // the "slop" region, jump to passthrough mode early. |
359 float delta = (event.location() - initial_press_->location()).Length(); | 362 float delta = (event.location() - initial_press_->location()).Length(); |
360 if (delta > gesture_detector_config_.touch_slop) { | 363 if (delta > gesture_detector_config_.touch_slop) { |
361 tap_timer_.Stop(); | 364 tap_timer_.Stop(); |
362 OnTapTimerFired(); | 365 OnTapTimerFired(); |
363 } | 366 } |
364 return EVENT_REWRITE_DISCARD; | 367 return EVENT_REWRITE_DISCARD; |
365 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 368 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
366 if (current_touch_ids_.size() != 0) | 369 if (current_touch_ids_.size() != 0) |
367 return EVENT_REWRITE_DISCARD; | 370 return EVENT_REWRITE_DISCARD; |
368 | 371 |
369 scoped_ptr<ui::TouchEvent> touch_press; | 372 std::unique_ptr<ui::TouchEvent> touch_press; |
370 touch_press.reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), | 373 touch_press.reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), |
371 initial_press_->touch_id(), | 374 initial_press_->touch_id(), |
372 event.time_stamp())); | 375 event.time_stamp())); |
373 touch_press->set_location_f(last_touch_exploration_->location_f()); | 376 touch_press->set_location_f(last_touch_exploration_->location_f()); |
374 touch_press->set_root_location_f(last_touch_exploration_->location_f()); | 377 touch_press->set_root_location_f(last_touch_exploration_->location_f()); |
375 DispatchEvent(touch_press.get()); | 378 DispatchEvent(touch_press.get()); |
376 | 379 |
377 scoped_ptr<ui::TouchEvent> new_event( | 380 std::unique_ptr<ui::TouchEvent> new_event( |
378 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), | 381 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), |
379 initial_press_->touch_id(), event.time_stamp())); | 382 initial_press_->touch_id(), event.time_stamp())); |
380 new_event->set_location_f(last_touch_exploration_->location_f()); | 383 new_event->set_location_f(last_touch_exploration_->location_f()); |
381 new_event->set_root_location_f(last_touch_exploration_->location_f()); | 384 new_event->set_root_location_f(last_touch_exploration_->location_f()); |
382 new_event->set_flags(event.flags()); | 385 new_event->set_flags(event.flags()); |
383 *rewritten_event = std::move(new_event); | 386 *rewritten_event = std::move(new_event); |
384 SET_STATE(NO_FINGERS_DOWN); | 387 SET_STATE(NO_FINGERS_DOWN); |
385 return ui::EVENT_REWRITE_REWRITTEN; | 388 return ui::EVENT_REWRITE_REWRITTEN; |
386 } | 389 } |
387 NOTREACHED(); | 390 NOTREACHED(); |
388 return ui::EVENT_REWRITE_CONTINUE; | 391 return ui::EVENT_REWRITE_CONTINUE; |
389 } | 392 } |
390 | 393 |
391 ui::EventRewriteStatus TouchExplorationController::InTouchReleasePending( | 394 ui::EventRewriteStatus TouchExplorationController::InTouchReleasePending( |
392 const ui::TouchEvent& event, | 395 const ui::TouchEvent& event, |
393 scoped_ptr<ui::Event>* rewritten_event) { | 396 std::unique_ptr<ui::Event>* rewritten_event) { |
394 const ui::EventType type = event.type(); | 397 const ui::EventType type = event.type(); |
395 if (type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED) { | 398 if (type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED) { |
396 return ui::EVENT_REWRITE_DISCARD; | 399 return ui::EVENT_REWRITE_DISCARD; |
397 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 400 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
398 if (current_touch_ids_.size() != 0) | 401 if (current_touch_ids_.size() != 0) |
399 return EVENT_REWRITE_DISCARD; | 402 return EVENT_REWRITE_DISCARD; |
400 | 403 |
401 scoped_ptr<ui::TouchEvent> new_event( | 404 std::unique_ptr<ui::TouchEvent> new_event( |
402 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), | 405 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), |
403 initial_press_->touch_id(), event.time_stamp())); | 406 initial_press_->touch_id(), event.time_stamp())); |
404 new_event->set_location_f(last_touch_exploration_->location_f()); | 407 new_event->set_location_f(last_touch_exploration_->location_f()); |
405 new_event->set_root_location_f(last_touch_exploration_->location_f()); | 408 new_event->set_root_location_f(last_touch_exploration_->location_f()); |
406 new_event->set_flags(event.flags()); | 409 new_event->set_flags(event.flags()); |
407 *rewritten_event = std::move(new_event); | 410 *rewritten_event = std::move(new_event); |
408 SET_STATE(NO_FINGERS_DOWN); | 411 SET_STATE(NO_FINGERS_DOWN); |
409 return ui::EVENT_REWRITE_REWRITTEN; | 412 return ui::EVENT_REWRITE_REWRITTEN; |
410 } | 413 } |
411 NOTREACHED(); | 414 NOTREACHED(); |
412 return ui::EVENT_REWRITE_CONTINUE; | 415 return ui::EVENT_REWRITE_CONTINUE; |
413 } | 416 } |
414 | 417 |
415 ui::EventRewriteStatus TouchExplorationController::InTouchExploration( | 418 ui::EventRewriteStatus TouchExplorationController::InTouchExploration( |
416 const ui::TouchEvent& event, | 419 const ui::TouchEvent& event, |
417 scoped_ptr<ui::Event>* rewritten_event) { | 420 std::unique_ptr<ui::Event>* rewritten_event) { |
418 const ui::EventType type = event.type(); | 421 const ui::EventType type = event.type(); |
419 if (type == ui::ET_TOUCH_PRESSED) { | 422 if (type == ui::ET_TOUCH_PRESSED) { |
420 // Handle split-tap. | 423 // Handle split-tap. |
421 initial_press_.reset(new TouchEvent(event)); | 424 initial_press_.reset(new TouchEvent(event)); |
422 tap_timer_.Stop(); | 425 tap_timer_.Stop(); |
423 scoped_ptr<ui::TouchEvent> new_event( | 426 std::unique_ptr<ui::TouchEvent> new_event( |
424 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), event.touch_id(), | 427 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), event.touch_id(), |
425 event.time_stamp())); | 428 event.time_stamp())); |
426 new_event->set_location_f(last_touch_exploration_->location_f()); | 429 new_event->set_location_f(last_touch_exploration_->location_f()); |
427 new_event->set_root_location_f(last_touch_exploration_->location_f()); | 430 new_event->set_root_location_f(last_touch_exploration_->location_f()); |
428 new_event->set_flags(event.flags()); | 431 new_event->set_flags(event.flags()); |
429 *rewritten_event = std::move(new_event); | 432 *rewritten_event = std::move(new_event); |
430 SET_STATE(TOUCH_EXPLORE_SECOND_PRESS); | 433 SET_STATE(TOUCH_EXPLORE_SECOND_PRESS); |
431 return ui::EVENT_REWRITE_REWRITTEN; | 434 return ui::EVENT_REWRITE_REWRITTEN; |
432 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 435 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
433 initial_press_.reset(new TouchEvent(event)); | 436 initial_press_.reset(new TouchEvent(event)); |
434 StartTapTimer(); | 437 StartTapTimer(); |
435 SET_STATE(TOUCH_EXPLORE_RELEASED); | 438 SET_STATE(TOUCH_EXPLORE_RELEASED); |
436 } else if (type != ui::ET_TOUCH_MOVED) { | 439 } else if (type != ui::ET_TOUCH_MOVED) { |
437 NOTREACHED(); | 440 NOTREACHED(); |
438 return ui::EVENT_REWRITE_CONTINUE; | 441 return ui::EVENT_REWRITE_CONTINUE; |
439 } | 442 } |
440 | 443 |
441 // Rewrite as a mouse-move event. | 444 // Rewrite as a mouse-move event. |
442 *rewritten_event = CreateMouseMoveEvent(event.location_f(), event.flags()); | 445 *rewritten_event = CreateMouseMoveEvent(event.location_f(), event.flags()); |
443 last_touch_exploration_.reset(new TouchEvent(event)); | 446 last_touch_exploration_.reset(new TouchEvent(event)); |
444 return ui::EVENT_REWRITE_REWRITTEN; | 447 return ui::EVENT_REWRITE_REWRITTEN; |
445 } | 448 } |
446 | 449 |
447 ui::EventRewriteStatus TouchExplorationController::InGestureInProgress( | 450 ui::EventRewriteStatus TouchExplorationController::InGestureInProgress( |
448 const ui::TouchEvent& event, | 451 const ui::TouchEvent& event, |
449 scoped_ptr<ui::Event>* rewritten_event) { | 452 std::unique_ptr<ui::Event>* rewritten_event) { |
450 // The events were sent to the gesture provider in RewriteEvent already. | 453 // The events were sent to the gesture provider in RewriteEvent already. |
451 // If no gesture is registered before the tap timer times out, the state | 454 // If no gesture is registered before the tap timer times out, the state |
452 // will change to "wait for no fingers down" or "touch exploration" depending | 455 // will change to "wait for no fingers down" or "touch exploration" depending |
453 // on the number of fingers down, and this function will stop being called. | 456 // on the number of fingers down, and this function will stop being called. |
454 if (current_touch_ids_.size() == 0) { | 457 if (current_touch_ids_.size() == 0) { |
455 SET_STATE(NO_FINGERS_DOWN); | 458 SET_STATE(NO_FINGERS_DOWN); |
456 } | 459 } |
457 return ui::EVENT_REWRITE_DISCARD; | 460 return ui::EVENT_REWRITE_DISCARD; |
458 } | 461 } |
459 | 462 |
460 ui::EventRewriteStatus TouchExplorationController::InCornerPassthrough( | 463 ui::EventRewriteStatus TouchExplorationController::InCornerPassthrough( |
461 const ui::TouchEvent& event, | 464 const ui::TouchEvent& event, |
462 scoped_ptr<ui::Event>* rewritten_event) { | 465 std::unique_ptr<ui::Event>* rewritten_event) { |
463 ui::EventType type = event.type(); | 466 ui::EventType type = event.type(); |
464 | 467 |
465 // If the first finger has left the corner, then exit passthrough. | 468 // If the first finger has left the corner, then exit passthrough. |
466 if (event.touch_id() == initial_press_->touch_id()) { | 469 if (event.touch_id() == initial_press_->touch_id()) { |
467 int edges = FindEdgesWithinBounds(event.location(), kSlopDistanceFromEdge); | 470 int edges = FindEdgesWithinBounds(event.location(), kSlopDistanceFromEdge); |
468 bool in_a_bottom_corner = (edges == BOTTOM_LEFT_CORNER) || | 471 bool in_a_bottom_corner = (edges == BOTTOM_LEFT_CORNER) || |
469 (edges == BOTTOM_RIGHT_CORNER); | 472 (edges == BOTTOM_RIGHT_CORNER); |
470 if (type == ui::ET_TOUCH_MOVED && in_a_bottom_corner) | 473 if (type == ui::ET_TOUCH_MOVED && in_a_bottom_corner) |
471 return ui::EVENT_REWRITE_DISCARD; | 474 return ui::EVENT_REWRITE_DISCARD; |
472 | 475 |
473 if (current_touch_ids_.size() == 0) { | 476 if (current_touch_ids_.size() == 0) { |
474 SET_STATE(NO_FINGERS_DOWN); | 477 SET_STATE(NO_FINGERS_DOWN); |
475 return ui::EVENT_REWRITE_DISCARD; | 478 return ui::EVENT_REWRITE_DISCARD; |
476 } | 479 } |
477 SET_STATE(WAIT_FOR_NO_FINGERS); | 480 SET_STATE(WAIT_FOR_NO_FINGERS); |
478 return ui::EVENT_REWRITE_DISCARD; | 481 return ui::EVENT_REWRITE_DISCARD; |
479 } | 482 } |
480 | 483 |
481 scoped_ptr<ui::TouchEvent> new_event(new ui::TouchEvent( | 484 std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent( |
482 type, gfx::Point(), event.touch_id(), event.time_stamp())); | 485 type, gfx::Point(), event.touch_id(), event.time_stamp())); |
483 new_event->set_location_f(event.location_f()); | 486 new_event->set_location_f(event.location_f()); |
484 new_event->set_root_location_f(event.location_f()); | 487 new_event->set_root_location_f(event.location_f()); |
485 new_event->set_flags(event.flags()); | 488 new_event->set_flags(event.flags()); |
486 *rewritten_event = std::move(new_event); | 489 *rewritten_event = std::move(new_event); |
487 | 490 |
488 if (current_touch_ids_.size() == 0) | 491 if (current_touch_ids_.size() == 0) |
489 SET_STATE(NO_FINGERS_DOWN); | 492 SET_STATE(NO_FINGERS_DOWN); |
490 | 493 |
491 return ui::EVENT_REWRITE_REWRITTEN; | 494 return ui::EVENT_REWRITE_REWRITTEN; |
492 } | 495 } |
493 | 496 |
494 ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough( | 497 ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough( |
495 const ui::TouchEvent& event, | 498 const ui::TouchEvent& event, |
496 scoped_ptr<ui::Event>* rewritten_event) { | 499 std::unique_ptr<ui::Event>* rewritten_event) { |
497 if (event.touch_id() != initial_press_->touch_id()) { | 500 if (event.touch_id() != initial_press_->touch_id()) { |
498 if (current_touch_ids_.size() == 0) { | 501 if (current_touch_ids_.size() == 0) { |
499 SET_STATE(NO_FINGERS_DOWN); | 502 SET_STATE(NO_FINGERS_DOWN); |
500 } | 503 } |
501 return ui::EVENT_REWRITE_DISCARD; | 504 return ui::EVENT_REWRITE_DISCARD; |
502 } | 505 } |
503 scoped_ptr<ui::TouchEvent> new_event(new ui::TouchEvent( | 506 std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent( |
504 event.type(), gfx::Point(), event.touch_id(), event.time_stamp())); | 507 event.type(), gfx::Point(), event.touch_id(), event.time_stamp())); |
505 new_event->set_location_f(event.location_f() - passthrough_offset_); | 508 new_event->set_location_f(event.location_f() - passthrough_offset_); |
506 new_event->set_root_location_f(event.location_f() - passthrough_offset_); | 509 new_event->set_root_location_f(event.location_f() - passthrough_offset_); |
507 new_event->set_flags(event.flags()); | 510 new_event->set_flags(event.flags()); |
508 *rewritten_event = std::move(new_event); | 511 *rewritten_event = std::move(new_event); |
509 if (current_touch_ids_.size() == 0) { | 512 if (current_touch_ids_.size() == 0) { |
510 SET_STATE(NO_FINGERS_DOWN); | 513 SET_STATE(NO_FINGERS_DOWN); |
511 } | 514 } |
512 return ui::EVENT_REWRITE_REWRITTEN; | 515 return ui::EVENT_REWRITE_REWRITTEN; |
513 } | 516 } |
514 | 517 |
515 ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress( | 518 ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress( |
516 const ui::TouchEvent& event, | 519 const ui::TouchEvent& event, |
517 scoped_ptr<ui::Event>* rewritten_event) { | 520 std::unique_ptr<ui::Event>* rewritten_event) { |
518 ui::EventType type = event.type(); | 521 ui::EventType type = event.type(); |
519 gfx::PointF location = event.location_f(); | 522 gfx::PointF location = event.location_f(); |
520 if (type == ui::ET_TOUCH_PRESSED) { | 523 if (type == ui::ET_TOUCH_PRESSED) { |
521 // A third finger being pressed means that a split tap can no longer go | 524 // A third finger being pressed means that a split tap can no longer go |
522 // through. The user enters the wait state, Since there has already been | 525 // through. The user enters the wait state, Since there has already been |
523 // a press dispatched when split tap began, the touch needs to be | 526 // a press dispatched when split tap began, the touch needs to be |
524 // cancelled. | 527 // cancelled. |
525 scoped_ptr<ui::TouchEvent> new_event( | 528 std::unique_ptr<ui::TouchEvent> new_event( |
526 new ui::TouchEvent(ui::ET_TOUCH_CANCELLED, gfx::Point(), | 529 new ui::TouchEvent(ui::ET_TOUCH_CANCELLED, gfx::Point(), |
527 initial_press_->touch_id(), event.time_stamp())); | 530 initial_press_->touch_id(), event.time_stamp())); |
528 new_event->set_location_f(last_touch_exploration_->location_f()); | 531 new_event->set_location_f(last_touch_exploration_->location_f()); |
529 new_event->set_root_location_f(last_touch_exploration_->location_f()); | 532 new_event->set_root_location_f(last_touch_exploration_->location_f()); |
530 new_event->set_flags(event.flags()); | 533 new_event->set_flags(event.flags()); |
531 *rewritten_event = std::move(new_event); | 534 *rewritten_event = std::move(new_event); |
532 SET_STATE(WAIT_FOR_NO_FINGERS); | 535 SET_STATE(WAIT_FOR_NO_FINGERS); |
533 return ui::EVENT_REWRITE_REWRITTEN; | 536 return ui::EVENT_REWRITE_REWRITTEN; |
534 } else if (type == ui::ET_TOUCH_MOVED) { | 537 } else if (type == ui::ET_TOUCH_MOVED) { |
535 // If the fingers have moved too far from their original locations, | 538 // If the fingers have moved too far from their original locations, |
536 // the user can no longer split tap. | 539 // the user can no longer split tap. |
537 ui::TouchEvent* original_touch; | 540 ui::TouchEvent* original_touch; |
538 if (event.touch_id() == last_touch_exploration_->touch_id()) { | 541 if (event.touch_id() == last_touch_exploration_->touch_id()) { |
539 original_touch = last_touch_exploration_.get(); | 542 original_touch = last_touch_exploration_.get(); |
540 } else if (event.touch_id() == initial_press_->touch_id()) { | 543 } else if (event.touch_id() == initial_press_->touch_id()) { |
541 original_touch = initial_press_.get(); | 544 original_touch = initial_press_.get(); |
542 } else { | 545 } else { |
543 NOTREACHED(); | 546 NOTREACHED(); |
544 SET_STATE(WAIT_FOR_NO_FINGERS); | 547 SET_STATE(WAIT_FOR_NO_FINGERS); |
545 return ui::EVENT_REWRITE_DISCARD; | 548 return ui::EVENT_REWRITE_DISCARD; |
546 } | 549 } |
547 // Check the distance between the current finger location and the original | 550 // Check the distance between the current finger location and the original |
548 // location. The slop for this is a bit more generous since keeping two | 551 // location. The slop for this is a bit more generous since keeping two |
549 // fingers in place is a bit harder. If the user has left the slop, the | 552 // fingers in place is a bit harder. If the user has left the slop, the |
550 // split tap press (which was previous dispatched) is lifted with a touch | 553 // split tap press (which was previous dispatched) is lifted with a touch |
551 // cancelled, and the user enters the wait state. | 554 // cancelled, and the user enters the wait state. |
552 if ((event.location_f() - original_touch->location_f()).Length() > | 555 if ((event.location_f() - original_touch->location_f()).Length() > |
553 GetSplitTapTouchSlop()) { | 556 GetSplitTapTouchSlop()) { |
554 scoped_ptr<ui::TouchEvent> new_event( | 557 std::unique_ptr<ui::TouchEvent> new_event( |
555 new ui::TouchEvent(ui::ET_TOUCH_CANCELLED, gfx::Point(), | 558 new ui::TouchEvent(ui::ET_TOUCH_CANCELLED, gfx::Point(), |
556 initial_press_->touch_id(), event.time_stamp())); | 559 initial_press_->touch_id(), event.time_stamp())); |
557 new_event->set_location_f(last_touch_exploration_->location_f()); | 560 new_event->set_location_f(last_touch_exploration_->location_f()); |
558 new_event->set_root_location_f(last_touch_exploration_->location_f()); | 561 new_event->set_root_location_f(last_touch_exploration_->location_f()); |
559 new_event->set_flags(event.flags()); | 562 new_event->set_flags(event.flags()); |
560 *rewritten_event = std::move(new_event); | 563 *rewritten_event = std::move(new_event); |
561 SET_STATE(WAIT_FOR_NO_FINGERS); | 564 SET_STATE(WAIT_FOR_NO_FINGERS); |
562 return ui::EVENT_REWRITE_REWRITTEN; | 565 return ui::EVENT_REWRITE_REWRITTEN; |
563 } | 566 } |
564 return ui::EVENT_REWRITE_DISCARD; | 567 return ui::EVENT_REWRITE_DISCARD; |
565 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 568 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
566 // If the touch exploration finger is lifted, there is no option to return | 569 // If the touch exploration finger is lifted, there is no option to return |
567 // to touch explore anymore. The remaining finger acts as a pending | 570 // to touch explore anymore. The remaining finger acts as a pending |
568 // tap or long tap for the last touch explore location. | 571 // tap or long tap for the last touch explore location. |
569 if (event.touch_id() == last_touch_exploration_->touch_id()) { | 572 if (event.touch_id() == last_touch_exploration_->touch_id()) { |
570 SET_STATE(TOUCH_RELEASE_PENDING); | 573 SET_STATE(TOUCH_RELEASE_PENDING); |
571 return EVENT_REWRITE_DISCARD; | 574 return EVENT_REWRITE_DISCARD; |
572 } | 575 } |
573 | 576 |
574 // Continue to release the touch only if the touch explore finger is the | 577 // Continue to release the touch only if the touch explore finger is the |
575 // only finger remaining. | 578 // only finger remaining. |
576 if (current_touch_ids_.size() != 1) | 579 if (current_touch_ids_.size() != 1) |
577 return EVENT_REWRITE_DISCARD; | 580 return EVENT_REWRITE_DISCARD; |
578 | 581 |
579 // Rewrite at location of last touch exploration. | 582 // Rewrite at location of last touch exploration. |
580 scoped_ptr<ui::TouchEvent> new_event( | 583 std::unique_ptr<ui::TouchEvent> new_event( |
581 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), | 584 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), |
582 initial_press_->touch_id(), event.time_stamp())); | 585 initial_press_->touch_id(), event.time_stamp())); |
583 new_event->set_location_f(last_touch_exploration_->location_f()); | 586 new_event->set_location_f(last_touch_exploration_->location_f()); |
584 new_event->set_root_location_f(last_touch_exploration_->location_f()); | 587 new_event->set_root_location_f(last_touch_exploration_->location_f()); |
585 new_event->set_flags(event.flags()); | 588 new_event->set_flags(event.flags()); |
586 *rewritten_event = std::move(new_event); | 589 *rewritten_event = std::move(new_event); |
587 SET_STATE(TOUCH_EXPLORATION); | 590 SET_STATE(TOUCH_EXPLORATION); |
588 EnterTouchToMouseMode(); | 591 EnterTouchToMouseMode(); |
589 return ui::EVENT_REWRITE_REWRITTEN; | 592 return ui::EVENT_REWRITE_REWRITTEN; |
590 } | 593 } |
591 NOTREACHED(); | 594 NOTREACHED(); |
592 return ui::EVENT_REWRITE_CONTINUE; | 595 return ui::EVENT_REWRITE_CONTINUE; |
593 } | 596 } |
594 | 597 |
595 ui::EventRewriteStatus TouchExplorationController::InWaitForNoFingers( | 598 ui::EventRewriteStatus TouchExplorationController::InWaitForNoFingers( |
596 const ui::TouchEvent& event, | 599 const ui::TouchEvent& event, |
597 scoped_ptr<ui::Event>* rewritten_event) { | 600 std::unique_ptr<ui::Event>* rewritten_event) { |
598 if (current_touch_ids_.size() == 0) | 601 if (current_touch_ids_.size() == 0) |
599 SET_STATE(NO_FINGERS_DOWN); | 602 SET_STATE(NO_FINGERS_DOWN); |
600 return EVENT_REWRITE_DISCARD; | 603 return EVENT_REWRITE_DISCARD; |
601 } | 604 } |
602 | 605 |
603 void TouchExplorationController::PlaySoundForTimer() { | 606 void TouchExplorationController::PlaySoundForTimer() { |
604 delegate_->PlayVolumeAdjustEarcon(); | 607 delegate_->PlayVolumeAdjustEarcon(); |
605 } | 608 } |
606 | 609 |
607 ui::EventRewriteStatus TouchExplorationController::InSlideGesture( | 610 ui::EventRewriteStatus TouchExplorationController::InSlideGesture( |
608 const ui::TouchEvent& event, | 611 const ui::TouchEvent& event, |
609 scoped_ptr<ui::Event>* rewritten_event) { | 612 std::unique_ptr<ui::Event>* rewritten_event) { |
610 // The timer should not fire when sliding. | 613 // The timer should not fire when sliding. |
611 tap_timer_.Stop(); | 614 tap_timer_.Stop(); |
612 | 615 |
613 ui::EventType type = event.type(); | 616 ui::EventType type = event.type(); |
614 // If additional fingers are added before a swipe gesture has been registered, | 617 // If additional fingers are added before a swipe gesture has been registered, |
615 // then wait until all fingers have been lifted. | 618 // then wait until all fingers have been lifted. |
616 if (type == ui::ET_TOUCH_PRESSED || | 619 if (type == ui::ET_TOUCH_PRESSED || |
617 event.touch_id() != initial_press_->touch_id()) { | 620 event.touch_id() != initial_press_->touch_id()) { |
618 if (sound_timer_.IsRunning()) | 621 if (sound_timer_.IsRunning()) |
619 sound_timer_.Stop(); | 622 sound_timer_.Stop(); |
(...skipping 24 matching lines...) Expand all Loading... |
644 } | 647 } |
645 | 648 |
646 if (current_touch_ids_.size() == 0) { | 649 if (current_touch_ids_.size() == 0) { |
647 SET_STATE(NO_FINGERS_DOWN); | 650 SET_STATE(NO_FINGERS_DOWN); |
648 } | 651 } |
649 return ui::EVENT_REWRITE_DISCARD; | 652 return ui::EVENT_REWRITE_DISCARD; |
650 } | 653 } |
651 | 654 |
652 ui::EventRewriteStatus TouchExplorationController::InTwoFingerTap( | 655 ui::EventRewriteStatus TouchExplorationController::InTwoFingerTap( |
653 const ui::TouchEvent& event, | 656 const ui::TouchEvent& event, |
654 scoped_ptr<ui::Event>* rewritten_event) { | 657 std::unique_ptr<ui::Event>* rewritten_event) { |
655 ui::EventType type = event.type(); | 658 ui::EventType type = event.type(); |
656 if (type == ui::ET_TOUCH_PRESSED) { | 659 if (type == ui::ET_TOUCH_PRESSED) { |
657 // This is now a three finger gesture. | 660 // This is now a three finger gesture. |
658 SET_STATE(GESTURE_IN_PROGRESS); | 661 SET_STATE(GESTURE_IN_PROGRESS); |
659 return ui::EVENT_REWRITE_DISCARD; | 662 return ui::EVENT_REWRITE_DISCARD; |
660 } | 663 } |
661 | 664 |
662 if (type == ui::ET_TOUCH_MOVED) { | 665 if (type == ui::ET_TOUCH_MOVED) { |
663 // Determine if it was a swipe. | 666 // Determine if it was a swipe. |
664 gfx::Point original_location = initial_presses_[event.touch_id()]; | 667 gfx::Point original_location = initial_presses_[event.touch_id()]; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 SET_STATE(NO_FINGERS_DOWN); | 714 SET_STATE(NO_FINGERS_DOWN); |
712 break; | 715 break; |
713 case TOUCH_EXPLORE_RELEASED: | 716 case TOUCH_EXPLORE_RELEASED: |
714 SET_STATE(NO_FINGERS_DOWN); | 717 SET_STATE(NO_FINGERS_DOWN); |
715 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 718 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); |
716 return; | 719 return; |
717 case DOUBLE_TAP_PENDING: { | 720 case DOUBLE_TAP_PENDING: { |
718 SET_STATE(ONE_FINGER_PASSTHROUGH); | 721 SET_STATE(ONE_FINGER_PASSTHROUGH); |
719 passthrough_offset_ = last_unused_finger_event_->location_f() - | 722 passthrough_offset_ = last_unused_finger_event_->location_f() - |
720 last_touch_exploration_->location_f(); | 723 last_touch_exploration_->location_f(); |
721 scoped_ptr<ui::TouchEvent> passthrough_press( | 724 std::unique_ptr<ui::TouchEvent> passthrough_press( |
722 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), | 725 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), |
723 last_unused_finger_event_->touch_id(), Now())); | 726 last_unused_finger_event_->touch_id(), Now())); |
724 passthrough_press->set_location_f(last_touch_exploration_->location_f()); | 727 passthrough_press->set_location_f(last_touch_exploration_->location_f()); |
725 passthrough_press->set_root_location_f( | 728 passthrough_press->set_root_location_f( |
726 last_touch_exploration_->location_f()); | 729 last_touch_exploration_->location_f()); |
727 DispatchEvent(passthrough_press.get()); | 730 DispatchEvent(passthrough_press.get()); |
728 return; | 731 return; |
729 } | 732 } |
730 case SINGLE_TAP_PRESSED: | 733 case SINGLE_TAP_PRESSED: |
731 if (passthrough_timer_.IsRunning()) | 734 if (passthrough_timer_.IsRunning()) |
732 return; | 735 return; |
733 case GESTURE_IN_PROGRESS: | 736 case GESTURE_IN_PROGRESS: |
734 // If only one finger is down, go into touch exploration. | 737 // If only one finger is down, go into touch exploration. |
735 if (current_touch_ids_.size() == 1) { | 738 if (current_touch_ids_.size() == 1) { |
736 EnterTouchToMouseMode(); | 739 EnterTouchToMouseMode(); |
737 SET_STATE(TOUCH_EXPLORATION); | 740 SET_STATE(TOUCH_EXPLORATION); |
738 break; | 741 break; |
739 } | 742 } |
740 // Otherwise wait for all fingers to be lifted. | 743 // Otherwise wait for all fingers to be lifted. |
741 SET_STATE(WAIT_FOR_NO_FINGERS); | 744 SET_STATE(WAIT_FOR_NO_FINGERS); |
742 return; | 745 return; |
743 case TWO_FINGER_TAP: | 746 case TWO_FINGER_TAP: |
744 SET_STATE(WAIT_FOR_NO_FINGERS); | 747 SET_STATE(WAIT_FOR_NO_FINGERS); |
745 break; | 748 break; |
746 default: | 749 default: |
747 return; | 750 return; |
748 } | 751 } |
749 EnterTouchToMouseMode(); | 752 EnterTouchToMouseMode(); |
750 scoped_ptr<ui::Event> mouse_move = CreateMouseMoveEvent( | 753 std::unique_ptr<ui::Event> mouse_move = CreateMouseMoveEvent( |
751 initial_press_->location_f(), initial_press_->flags()); | 754 initial_press_->location_f(), initial_press_->flags()); |
752 DispatchEvent(mouse_move.get()); | 755 DispatchEvent(mouse_move.get()); |
753 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 756 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); |
754 } | 757 } |
755 | 758 |
756 void TouchExplorationController::OnPassthroughTimerFired() { | 759 void TouchExplorationController::OnPassthroughTimerFired() { |
757 // The passthrough timer will only fire if if the user has held a finger in | 760 // The passthrough timer will only fire if if the user has held a finger in |
758 // one of the passthrough corners for the duration of the passthrough timeout. | 761 // one of the passthrough corners for the duration of the passthrough timeout. |
759 | 762 |
760 // Check that initial press isn't null. Also a check that if the initial | 763 // Check that initial press isn't null. Also a check that if the initial |
(...skipping 24 matching lines...) Expand all Loading... |
785 | 788 |
786 // This is an override for a function that is only called for timer-based events | 789 // This is an override for a function that is only called for timer-based events |
787 // like long press. Events that are created synchronously as a result of | 790 // like long press. Events that are created synchronously as a result of |
788 // certain touch events are added to the vector accessible via | 791 // certain touch events are added to the vector accessible via |
789 // GetAndResetPendingGestures(). We only care about swipes (which are created | 792 // GetAndResetPendingGestures(). We only care about swipes (which are created |
790 // synchronously), so we ignore this callback. | 793 // synchronously), so we ignore this callback. |
791 void TouchExplorationController::OnGestureEvent(ui::GestureConsumer* consumer, | 794 void TouchExplorationController::OnGestureEvent(ui::GestureConsumer* consumer, |
792 ui::GestureEvent* gesture) {} | 795 ui::GestureEvent* gesture) {} |
793 | 796 |
794 void TouchExplorationController::ProcessGestureEvents() { | 797 void TouchExplorationController::ProcessGestureEvents() { |
795 scoped_ptr<ScopedVector<ui::GestureEvent> > gestures( | 798 std::unique_ptr<ScopedVector<ui::GestureEvent>> gestures( |
796 gesture_provider_->GetAndResetPendingGestures()); | 799 gesture_provider_->GetAndResetPendingGestures()); |
797 if (gestures) { | 800 if (gestures) { |
798 for (ScopedVector<GestureEvent>::iterator i = gestures->begin(); | 801 for (ScopedVector<GestureEvent>::iterator i = gestures->begin(); |
799 i != gestures->end(); | 802 i != gestures->end(); |
800 ++i) { | 803 ++i) { |
801 if ((*i)->type() == ui::ET_GESTURE_SWIPE && | 804 if ((*i)->type() == ui::ET_GESTURE_SWIPE && |
802 state_ == GESTURE_IN_PROGRESS) { | 805 state_ == GESTURE_IN_PROGRESS) { |
803 OnSwipeEvent(*i); | 806 OnSwipeEvent(*i); |
804 // The tap timer to leave gesture state is ended, and we now wait for | 807 // The tap timer to leave gesture state is ended, and we now wait for |
805 // all fingers to be released. | 808 // all fingers to be released. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 | 968 |
966 base::Closure TouchExplorationController::BindKeyEventWithFlags( | 969 base::Closure TouchExplorationController::BindKeyEventWithFlags( |
967 const ui::KeyboardCode key, | 970 const ui::KeyboardCode key, |
968 int flags) { | 971 int flags) { |
969 return base::Bind(&TouchExplorationController::DispatchKeyWithFlags, | 972 return base::Bind(&TouchExplorationController::DispatchKeyWithFlags, |
970 base::Unretained(this), | 973 base::Unretained(this), |
971 key, | 974 key, |
972 flags); | 975 flags); |
973 } | 976 } |
974 | 977 |
975 scoped_ptr<ui::MouseEvent> TouchExplorationController::CreateMouseMoveEvent( | 978 std::unique_ptr<ui::MouseEvent> |
976 const gfx::PointF& location, | 979 TouchExplorationController::CreateMouseMoveEvent(const gfx::PointF& location, |
977 int flags) { | 980 int flags) { |
978 // The "synthesized" flag should be set on all events that don't have a | 981 // The "synthesized" flag should be set on all events that don't have a |
979 // backing native event. | 982 // backing native event. |
980 flags |= ui::EF_IS_SYNTHESIZED; | 983 flags |= ui::EF_IS_SYNTHESIZED; |
981 | 984 |
982 // This flag is used to identify mouse move events that were generated from | 985 // This flag is used to identify mouse move events that were generated from |
983 // touch exploration in Chrome code. | 986 // touch exploration in Chrome code. |
984 flags |= ui::EF_TOUCH_ACCESSIBILITY; | 987 flags |= ui::EF_TOUCH_ACCESSIBILITY; |
985 | 988 |
986 // TODO(dmazzoni) http://crbug.com/391008 - get rid of this hack. | 989 // TODO(dmazzoni) http://crbug.com/391008 - get rid of this hack. |
987 // This is a short-term workaround for the limitation that we're using | 990 // This is a short-term workaround for the limitation that we're using |
988 // the ChromeVox content script to process touch exploration events, but | 991 // the ChromeVox content script to process touch exploration events, but |
989 // ChromeVox needs a way to distinguish between a real mouse move and a | 992 // ChromeVox needs a way to distinguish between a real mouse move and a |
990 // mouse move generated from touch exploration, so we have touch exploration | 993 // mouse move generated from touch exploration, so we have touch exploration |
991 // pretend that the command key was down (which becomes the "meta" key in | 994 // pretend that the command key was down (which becomes the "meta" key in |
992 // JavaScript). We can remove this hack when the ChromeVox content script | 995 // JavaScript). We can remove this hack when the ChromeVox content script |
993 // goes away and native accessibility code sends a touch exploration | 996 // goes away and native accessibility code sends a touch exploration |
994 // event to the new ChromeVox background page via the automation api. | 997 // event to the new ChromeVox background page via the automation api. |
995 flags |= ui::EF_COMMAND_DOWN; | 998 flags |= ui::EF_COMMAND_DOWN; |
996 | 999 |
997 scoped_ptr<ui::MouseEvent> event( | 1000 std::unique_ptr<ui::MouseEvent> event( |
998 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 1001 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), |
999 ui::EventTimeForNow(), flags, 0)); | 1002 ui::EventTimeForNow(), flags, 0)); |
1000 event->set_location_f(location); | 1003 event->set_location_f(location); |
1001 event->set_root_location_f(location); | 1004 event->set_root_location_f(location); |
1002 return event; | 1005 return event; |
1003 } | 1006 } |
1004 | 1007 |
1005 void TouchExplorationController::EnterTouchToMouseMode() { | 1008 void TouchExplorationController::EnterTouchToMouseMode() { |
1006 aura::client::CursorClient* cursor_client = | 1009 aura::client::CursorClient* cursor_client = |
1007 aura::client::GetCursorClient(root_window_); | 1010 aura::client::GetCursorClient(root_window_); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 up_swipe_gestures_[4] = BindKeyEventWithFlags(VKEY_BROWSER_HOME, ui::EF_NONE); | 1163 up_swipe_gestures_[4] = BindKeyEventWithFlags(VKEY_BROWSER_HOME, ui::EF_NONE); |
1161 down_swipe_gestures_[4] = | 1164 down_swipe_gestures_[4] = |
1162 BindKeyEventWithFlags(VKEY_BROWSER_REFRESH, ui::EF_NONE); | 1165 BindKeyEventWithFlags(VKEY_BROWSER_REFRESH, ui::EF_NONE); |
1163 } | 1166 } |
1164 | 1167 |
1165 float TouchExplorationController::GetSplitTapTouchSlop() { | 1168 float TouchExplorationController::GetSplitTapTouchSlop() { |
1166 return gesture_detector_config_.touch_slop * 3; | 1169 return gesture_detector_config_.touch_slop * 3; |
1167 } | 1170 } |
1168 | 1171 |
1169 } // namespace ui | 1172 } // namespace ui |
OLD | NEW |