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 "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "ui/aura/client/cursor_client.h" | 9 #include "ui/aura/client/cursor_client.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 ui::EventRewriteStatus TouchExplorationController::InDoubleTapPressed( | 229 ui::EventRewriteStatus TouchExplorationController::InDoubleTapPressed( |
230 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 230 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
231 const ui::EventType type = event.type(); | 231 const ui::EventType type = event.type(); |
232 if (type == ui::ET_TOUCH_PRESSED) { | 232 if (type == ui::ET_TOUCH_PRESSED) { |
233 return ui::EVENT_REWRITE_DISCARD; | 233 return ui::EVENT_REWRITE_DISCARD; |
234 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 234 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
235 if (current_touch_ids_.size() != 0) | 235 if (current_touch_ids_.size() != 0) |
236 return EVENT_REWRITE_DISCARD; | 236 return EVENT_REWRITE_DISCARD; |
237 | 237 |
238 // Rewrite at location of last touch exploration. | 238 // Rewrite release at location of last touch exploration with the same |
| 239 // id as the prevoius press. |
239 rewritten_event->reset( | 240 rewritten_event->reset( |
240 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, | 241 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, |
241 last_touch_exploration_->location(), | 242 last_touch_exploration_->location(), |
242 event.touch_id(), | 243 initial_press_->touch_id(), |
243 event.time_stamp())); | 244 event.time_stamp())); |
244 (*rewritten_event)->set_flags(event.flags()); | 245 (*rewritten_event)->set_flags(event.flags()); |
245 ResetToNoFingersDown(); | 246 ResetToNoFingersDown(); |
246 return ui::EVENT_REWRITE_REWRITTEN; | 247 return ui::EVENT_REWRITE_REWRITTEN; |
247 } else if (type == ui::ET_TOUCH_MOVED) { | 248 } else if (type == ui::ET_TOUCH_MOVED) { |
248 return ui::EVENT_REWRITE_DISCARD; | 249 return ui::EVENT_REWRITE_DISCARD; |
249 } | 250 } |
250 NOTREACHED() << "Unexpected event type received."; | 251 NOTREACHED() << "Unexpected event type received."; |
251 return ui::EVENT_REWRITE_CONTINUE; | 252 return ui::EVENT_REWRITE_CONTINUE; |
252 } | 253 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 state_ = DOUBLE_TAP_PRESSED; | 347 state_ = DOUBLE_TAP_PRESSED; |
347 VLOG_STATE(); | 348 VLOG_STATE(); |
348 return EVENT_REWRITE_DISCARD; | 349 return EVENT_REWRITE_DISCARD; |
349 } | 350 } |
350 | 351 |
351 // Continue to release the touch only if the touch explore finger is the | 352 // Continue to release the touch only if the touch explore finger is the |
352 // only finger remaining. | 353 // only finger remaining. |
353 if (current_touch_ids_.size() != 1) | 354 if (current_touch_ids_.size() != 1) |
354 return EVENT_REWRITE_DISCARD; | 355 return EVENT_REWRITE_DISCARD; |
355 | 356 |
| 357 // Continue to release the touch only if the touch explore finger is the |
| 358 // only finger remaining. |
| 359 if (current_touch_ids_.size() != 1) |
| 360 return EVENT_REWRITE_DISCARD; |
| 361 |
356 // Rewrite at location of last touch exploration. | 362 // Rewrite at location of last touch exploration. |
357 rewritten_event->reset( | 363 rewritten_event->reset( |
358 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, | 364 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, |
359 last_touch_exploration_->location(), | 365 last_touch_exploration_->location(), |
360 initial_press_->touch_id(), | 366 initial_press_->touch_id(), |
361 event.time_stamp())); | 367 event.time_stamp())); |
362 (*rewritten_event)->set_flags(event.flags()); | 368 (*rewritten_event)->set_flags(event.flags()); |
363 state_ = TOUCH_EXPLORATION; | 369 state_ = TOUCH_EXPLORATION; |
364 VLOG_STATE(); | 370 VLOG_STATE(); |
365 return ui::EVENT_REWRITE_REWRITTEN; | 371 return ui::EVENT_REWRITE_REWRITTEN; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 CHECK(touch_event.IsTouchEvent()); | 445 CHECK(touch_event.IsTouchEvent()); |
440 if (prev_event_ == NULL || prev_event_->type() != touch_event.type() || | 446 if (prev_event_ == NULL || prev_event_->type() != touch_event.type() || |
441 prev_event_->touch_id() != touch_event.touch_id()) { | 447 prev_event_->touch_id() != touch_event.touch_id()) { |
442 const std::string type = EnumEventTypeToString(touch_event.type()); | 448 const std::string type = EnumEventTypeToString(touch_event.type()); |
443 const gfx::PointF& location = touch_event.location_f(); | 449 const gfx::PointF& location = touch_event.location_f(); |
444 const int touch_id = touch_event.touch_id(); | 450 const int touch_id = touch_event.touch_id(); |
445 | 451 |
446 VLOG(0) << "\n Function name: " << function_name | 452 VLOG(0) << "\n Function name: " << function_name |
447 << "\n Event Type: " << type | 453 << "\n Event Type: " << type |
448 << "\n Location: " << location.ToString() | 454 << "\n Location: " << location.ToString() |
449 << "\n Touch ID: " << touch_id; | 455 << "\n Touch ID: " << touch_id |
| 456 << "\n Number of fingers down: " << current_touch_ids_.size(); |
450 prev_event_.reset(new TouchEvent(touch_event)); | 457 prev_event_.reset(new TouchEvent(touch_event)); |
451 } | 458 } |
452 } | 459 } |
453 | 460 |
454 const char* TouchExplorationController::EnumStateToString(State state) { | 461 const char* TouchExplorationController::EnumStateToString(State state) { |
455 switch (state) { | 462 switch (state) { |
456 case NO_FINGERS_DOWN: | 463 case NO_FINGERS_DOWN: |
457 return "NO_FINGERS_DOWN"; | 464 return "NO_FINGERS_DOWN"; |
458 case SINGLE_TAP_PRESSED: | 465 case SINGLE_TAP_PRESSED: |
459 return "SINGLE_TAP_PRESSED"; | 466 return "SINGLE_TAP_PRESSED"; |
(...skipping 23 matching lines...) Expand all Loading... |
483 case ET_TOUCH_MOVED: | 490 case ET_TOUCH_MOVED: |
484 return "ET_TOUCH_MOVED"; | 491 return "ET_TOUCH_MOVED"; |
485 case ET_TOUCH_CANCELLED: | 492 case ET_TOUCH_CANCELLED: |
486 return "ET_TOUCH_CANCELLED"; | 493 return "ET_TOUCH_CANCELLED"; |
487 default: | 494 default: |
488 return base::IntToString(type); | 495 return base::IntToString(type); |
489 } | 496 } |
490 } | 497 } |
491 | 498 |
492 } // namespace ui | 499 } // namespace ui |
OLD | NEW |