| 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 11 matching lines...) Expand all Loading... |
| 22 // In ChromeOS, VKEY_LWIN is synonymous for the search key. | 22 // In ChromeOS, VKEY_LWIN is synonymous for the search key. |
| 23 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN; | 23 const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN; |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 TouchExplorationController::TouchExplorationController( | 26 TouchExplorationController::TouchExplorationController( |
| 27 aura::Window* root_window) | 27 aura::Window* root_window) |
| 28 : root_window_(root_window), | 28 : root_window_(root_window), |
| 29 state_(NO_FINGERS_DOWN), | 29 state_(NO_FINGERS_DOWN), |
| 30 event_handler_for_testing_(NULL), | 30 event_handler_for_testing_(NULL), |
| 31 gesture_provider_(this), | 31 gesture_provider_(this), |
| 32 prev_state_(NO_FINGERS_DOWN) { | 32 prev_state_(NO_FINGERS_DOWN), |
| 33 VLOG_on_(true) { |
| 33 CHECK(root_window); | 34 CHECK(root_window); |
| 34 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 35 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
| 35 } | 36 } |
| 36 | 37 |
| 37 | 38 |
| 38 TouchExplorationController::~TouchExplorationController() { | 39 TouchExplorationController::~TouchExplorationController() { |
| 39 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 40 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
| 40 } | 41 } |
| 41 | 42 |
| 42 void TouchExplorationController::CallTapTimerNowForTesting() { | 43 void TouchExplorationController::CallTapTimerNowForTesting() { |
| 43 DCHECK(tap_timer_.IsRunning()); | 44 DCHECK(tap_timer_.IsRunning()); |
| 44 tap_timer_.Stop(); | 45 tap_timer_.Stop(); |
| 45 OnTapTimerFired(); | 46 OnTapTimerFired(); |
| 46 } | 47 } |
| 47 | 48 |
| 49 void TouchExplorationController::CallTapTimerNowIfRunningForTesting() { |
| 50 if (tap_timer_.IsRunning()) { |
| 51 tap_timer_.Stop(); |
| 52 OnTapTimerFired(); |
| 53 } |
| 54 } |
| 55 |
| 48 void TouchExplorationController::SetEventHandlerForTesting( | 56 void TouchExplorationController::SetEventHandlerForTesting( |
| 49 ui::EventHandler* event_handler_for_testing) { | 57 ui::EventHandler* event_handler_for_testing) { |
| 50 event_handler_for_testing_ = event_handler_for_testing; | 58 event_handler_for_testing_ = event_handler_for_testing; |
| 51 } | 59 } |
| 52 | 60 |
| 53 bool TouchExplorationController::IsInNoFingersDownStateForTesting() const { | 61 bool TouchExplorationController::IsInNoFingersDownStateForTesting() const { |
| 54 return state_ == NO_FINGERS_DOWN; | 62 return state_ == NO_FINGERS_DOWN; |
| 55 } | 63 } |
| 56 | 64 |
| 57 bool TouchExplorationController::IsInGestureInProgressStateForTesting() const { | 65 bool TouchExplorationController::IsInGestureInProgressStateForTesting() const { |
| 58 return state_ == GESTURE_IN_PROGRESS; | 66 return state_ == GESTURE_IN_PROGRESS; |
| 59 } | 67 } |
| 60 | 68 |
| 69 void TouchExplorationController::SuppressVLOGsForTesting(bool suppress) { |
| 70 VLOG_on_ = !suppress; |
| 71 } |
| 72 |
| 61 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( | 73 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
| 62 const ui::Event& event, | 74 const ui::Event& event, |
| 63 scoped_ptr<ui::Event>* rewritten_event) { | 75 scoped_ptr<ui::Event>* rewritten_event) { |
| 64 if (!event.IsTouchEvent()) { | 76 if (!event.IsTouchEvent()) { |
| 65 if (event.IsKeyEvent()) { | 77 if (event.IsKeyEvent()) { |
| 66 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | 78 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); |
| 67 VLOG(0) << "\nKeyboard event: " << key_event.name() << "\n" | 79 VLOG(0) << "\nKeyboard event: " << key_event.name() |
| 68 << " Key code: " << key_event.key_code() | 80 << "\n Key code: " << key_event.key_code() |
| 69 << ", Flags: " << key_event.flags() | 81 << ", Flags: " << key_event.flags() |
| 70 << ", Is char: " << key_event.is_char(); | 82 << ", Is char: " << key_event.is_char(); |
| 71 } | 83 } |
| 72 return ui::EVENT_REWRITE_CONTINUE; | 84 return ui::EVENT_REWRITE_CONTINUE; |
| 73 } | 85 } |
| 74 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); | 86 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); |
| 75 | 87 |
| 76 // If the tap timer should have fired by now but hasn't, run it now and | 88 // If the tap timer should have fired by now but hasn't, run it now and |
| 77 // stop the timer. This is important so that behavior is consistent with | 89 // stop the timer. This is important so that behavior is consistent with |
| 78 // the timestamps of the events, and not dependent on the granularity of | 90 // the timestamps of the events, and not dependent on the granularity of |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 gesture_detector_config_.double_tap_timeout, | 173 gesture_detector_config_.double_tap_timeout, |
| 162 this, | 174 this, |
| 163 &TouchExplorationController::OnTapTimerFired); | 175 &TouchExplorationController::OnTapTimerFired); |
| 164 gesture_provider_.OnTouchEvent(event); | 176 gesture_provider_.OnTouchEvent(event); |
| 165 gesture_provider_.OnTouchEventAck(false); | 177 gesture_provider_.OnTouchEventAck(false); |
| 166 ProcessGestureEvents(); | 178 ProcessGestureEvents(); |
| 167 state_ = SINGLE_TAP_PRESSED; | 179 state_ = SINGLE_TAP_PRESSED; |
| 168 VLOG_STATE(); | 180 VLOG_STATE(); |
| 169 return ui::EVENT_REWRITE_DISCARD; | 181 return ui::EVENT_REWRITE_DISCARD; |
| 170 } | 182 } |
| 171 NOTREACHED() << "Unexpected event type received."; | 183 NOTREACHED() << "Unexpected event type received: " << event.name();; |
| 172 return ui::EVENT_REWRITE_CONTINUE; | 184 return ui::EVENT_REWRITE_CONTINUE; |
| 173 } | 185 } |
| 174 | 186 |
| 175 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( | 187 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( |
| 176 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 188 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
| 177 const ui::EventType type = event.type(); | 189 const ui::EventType type = event.type(); |
| 178 | 190 |
| 179 if (type == ui::ET_TOUCH_PRESSED) { | 191 if (type == ui::ET_TOUCH_PRESSED) { |
| 180 // Adding a second finger within the timeout period switches to | 192 // Adding a second finger within the timeout period switches to |
| 181 // passing through every event from the second finger and none form the | 193 // passing through every event from the second finger and none form the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (velocity > gesture_detector_config_.minimum_swipe_velocity) { | 227 if (velocity > gesture_detector_config_.minimum_swipe_velocity) { |
| 216 state_ = GESTURE_IN_PROGRESS; | 228 state_ = GESTURE_IN_PROGRESS; |
| 217 VLOG_STATE(); | 229 VLOG_STATE(); |
| 218 return InGestureInProgress(event, rewritten_event); | 230 return InGestureInProgress(event, rewritten_event); |
| 219 } | 231 } |
| 220 EnterTouchToMouseMode(); | 232 EnterTouchToMouseMode(); |
| 221 state_ = TOUCH_EXPLORATION; | 233 state_ = TOUCH_EXPLORATION; |
| 222 VLOG_STATE(); | 234 VLOG_STATE(); |
| 223 return InTouchExploration(event, rewritten_event); | 235 return InTouchExploration(event, rewritten_event); |
| 224 } | 236 } |
| 225 NOTREACHED() << "Unexpected event type received."; | 237 NOTREACHED() << "Unexpected event type received: " << event.name();; |
| 226 return ui::EVENT_REWRITE_CONTINUE; | 238 return ui::EVENT_REWRITE_CONTINUE; |
| 227 } | 239 } |
| 228 | 240 |
| 229 ui::EventRewriteStatus | 241 ui::EventRewriteStatus |
| 230 TouchExplorationController::InSingleTapOrTouchExploreReleased( | 242 TouchExplorationController::InSingleTapOrTouchExploreReleased( |
| 231 const ui::TouchEvent& event, | 243 const ui::TouchEvent& event, |
| 232 scoped_ptr<ui::Event>* rewritten_event) { | 244 scoped_ptr<ui::Event>* rewritten_event) { |
| 233 const ui::EventType type = event.type(); | 245 const ui::EventType type = event.type(); |
| 234 // If there is more than one finger down, then discard to wait until only one | 246 // If there is more than one finger down, then discard to wait until only one |
| 235 // finger is or no fingers are down. | 247 // finger is or no fingers are down. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 250 // Rewrite at location of last touch exploration. | 262 // Rewrite at location of last touch exploration. |
| 251 rewritten_event->reset( | 263 rewritten_event->reset( |
| 252 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, | 264 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, |
| 253 last_touch_exploration_->location(), | 265 last_touch_exploration_->location(), |
| 254 event.touch_id(), | 266 event.touch_id(), |
| 255 event.time_stamp())); | 267 event.time_stamp())); |
| 256 (*rewritten_event)->set_flags(event.flags()); | 268 (*rewritten_event)->set_flags(event.flags()); |
| 257 state_ = DOUBLE_TAP_PRESSED; | 269 state_ = DOUBLE_TAP_PRESSED; |
| 258 VLOG_STATE(); | 270 VLOG_STATE(); |
| 259 return ui::EVENT_REWRITE_REWRITTEN; | 271 return ui::EVENT_REWRITE_REWRITTEN; |
| 272 } else if (type == ui::ET_TOUCH_RELEASED && !last_touch_exploration_) { |
| 273 // If the previous press was discarded, we need to also handle its |
| 274 // release. |
| 275 if (current_touch_ids_.size() == 0) { |
| 276 ResetToNoFingersDown(); |
| 277 } |
| 278 return ui::EVENT_REWRITE_DISCARD; |
| 279 } else if (type == ui::ET_TOUCH_MOVED){ |
| 280 return ui::EVENT_REWRITE_DISCARD; |
| 260 } | 281 } |
| 261 NOTREACHED() << "Unexpected event type received."; | 282 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 262 return ui::EVENT_REWRITE_CONTINUE; | 283 return ui::EVENT_REWRITE_CONTINUE; |
| 263 } | 284 } |
| 264 | 285 |
| 265 ui::EventRewriteStatus TouchExplorationController::InDoubleTapPressed( | 286 ui::EventRewriteStatus TouchExplorationController::InDoubleTapPressed( |
| 266 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 287 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
| 267 const ui::EventType type = event.type(); | 288 const ui::EventType type = event.type(); |
| 268 if (type == ui::ET_TOUCH_PRESSED) { | 289 if (type == ui::ET_TOUCH_PRESSED) { |
| 269 return ui::EVENT_REWRITE_DISCARD; | 290 return ui::EVENT_REWRITE_DISCARD; |
| 270 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 291 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
| 271 if (current_touch_ids_.size() != 0) | 292 if (current_touch_ids_.size() != 0) |
| 272 return EVENT_REWRITE_DISCARD; | 293 return EVENT_REWRITE_DISCARD; |
| 273 | 294 |
| 274 // Rewrite release at location of last touch exploration with the same | 295 // Rewrite release at location of last touch exploration with the same |
| 275 // id as the previous press. | 296 // id as the previous press. |
| 276 rewritten_event->reset( | 297 rewritten_event->reset( |
| 277 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, | 298 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, |
| 278 last_touch_exploration_->location(), | 299 last_touch_exploration_->location(), |
| 279 initial_press_->touch_id(), | 300 initial_press_->touch_id(), |
| 280 event.time_stamp())); | 301 event.time_stamp())); |
| 281 (*rewritten_event)->set_flags(event.flags()); | 302 (*rewritten_event)->set_flags(event.flags()); |
| 282 ResetToNoFingersDown(); | 303 ResetToNoFingersDown(); |
| 283 return ui::EVENT_REWRITE_REWRITTEN; | 304 return ui::EVENT_REWRITE_REWRITTEN; |
| 284 } else if (type == ui::ET_TOUCH_MOVED) { | 305 } else if (type == ui::ET_TOUCH_MOVED) { |
| 285 return ui::EVENT_REWRITE_DISCARD; | 306 return ui::EVENT_REWRITE_DISCARD; |
| 286 } | 307 } |
| 287 NOTREACHED() << "Unexpected event type received."; | 308 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 288 return ui::EVENT_REWRITE_CONTINUE; | 309 return ui::EVENT_REWRITE_CONTINUE; |
| 289 } | 310 } |
| 290 | 311 |
| 291 ui::EventRewriteStatus TouchExplorationController::InTouchExploration( | 312 ui::EventRewriteStatus TouchExplorationController::InTouchExploration( |
| 292 const ui::TouchEvent& event, | 313 const ui::TouchEvent& event, |
| 293 scoped_ptr<ui::Event>* rewritten_event) { | 314 scoped_ptr<ui::Event>* rewritten_event) { |
| 294 const ui::EventType type = event.type(); | 315 const ui::EventType type = event.type(); |
| 295 if (type == ui::ET_TOUCH_PRESSED) { | 316 if (type == ui::ET_TOUCH_PRESSED) { |
| 296 // Handle split-tap. | 317 // Handle split-tap. |
| 297 initial_press_.reset(new TouchEvent(event)); | 318 initial_press_.reset(new TouchEvent(event)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 308 return ui::EVENT_REWRITE_REWRITTEN; | 329 return ui::EVENT_REWRITE_REWRITTEN; |
| 309 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 330 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
| 310 initial_press_.reset(new TouchEvent(event)); | 331 initial_press_.reset(new TouchEvent(event)); |
| 311 tap_timer_.Start(FROM_HERE, | 332 tap_timer_.Start(FROM_HERE, |
| 312 gesture_detector_config_.double_tap_timeout, | 333 gesture_detector_config_.double_tap_timeout, |
| 313 this, | 334 this, |
| 314 &TouchExplorationController::OnTapTimerFired); | 335 &TouchExplorationController::OnTapTimerFired); |
| 315 state_ = TOUCH_EXPLORE_RELEASED; | 336 state_ = TOUCH_EXPLORE_RELEASED; |
| 316 VLOG_STATE(); | 337 VLOG_STATE(); |
| 317 } else if (type != ui::ET_TOUCH_MOVED) { | 338 } else if (type != ui::ET_TOUCH_MOVED) { |
| 318 NOTREACHED() << "Unexpected event type received."; | 339 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 319 return ui::EVENT_REWRITE_CONTINUE; | 340 return ui::EVENT_REWRITE_CONTINUE; |
| 320 } | 341 } |
| 321 | 342 |
| 322 // Rewrite as a mouse-move event. | 343 // Rewrite as a mouse-move event. |
| 323 *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags()); | 344 *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags()); |
| 324 last_touch_exploration_.reset(new TouchEvent(event)); | 345 last_touch_exploration_.reset(new TouchEvent(event)); |
| 325 return ui::EVENT_REWRITE_REWRITTEN; | 346 return ui::EVENT_REWRITE_REWRITTEN; |
| 326 } | 347 } |
| 327 | 348 |
| 328 ui::EventRewriteStatus TouchExplorationController::InGestureInProgress( | 349 ui::EventRewriteStatus TouchExplorationController::InGestureInProgress( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 if (event.touch_id() == last_two_to_one_->touch_id()) { | 436 if (event.touch_id() == last_two_to_one_->touch_id()) { |
| 416 last_two_to_one_.reset(new TouchEvent(event)); | 437 last_two_to_one_.reset(new TouchEvent(event)); |
| 417 rewritten_event->reset(new ui::TouchEvent(ui::ET_TOUCH_MOVED, | 438 rewritten_event->reset(new ui::TouchEvent(ui::ET_TOUCH_MOVED, |
| 418 event.location(), | 439 event.location(), |
| 419 event.touch_id(), | 440 event.touch_id(), |
| 420 event.time_stamp())); | 441 event.time_stamp())); |
| 421 (*rewritten_event)->set_flags(event.flags()); | 442 (*rewritten_event)->set_flags(event.flags()); |
| 422 return ui::EVENT_REWRITE_REWRITTEN; | 443 return ui::EVENT_REWRITE_REWRITTEN; |
| 423 } | 444 } |
| 424 } | 445 } |
| 425 NOTREACHED() << "Unexpected event type received"; | 446 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 426 return ui::EVENT_REWRITE_CONTINUE; | 447 return ui::EVENT_REWRITE_CONTINUE; |
| 427 } | 448 } |
| 428 | 449 |
| 429 ui::EventRewriteStatus TouchExplorationController::InPassthrough( | 450 ui::EventRewriteStatus TouchExplorationController::InPassthrough( |
| 430 const ui::TouchEvent& event, | 451 const ui::TouchEvent& event, |
| 431 scoped_ptr<ui::Event>* rewritten_event) { | 452 scoped_ptr<ui::Event>* rewritten_event) { |
| 432 ui::EventType type = event.type(); | 453 ui::EventType type = event.type(); |
| 433 | 454 |
| 434 if (!(type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED || | 455 if (!(type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED || |
| 435 type == ui::ET_TOUCH_MOVED || type == ui::ET_TOUCH_PRESSED)) { | 456 type == ui::ET_TOUCH_MOVED || type == ui::ET_TOUCH_PRESSED)) { |
| 436 NOTREACHED() << "Unexpected event type received."; | 457 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 437 return ui::EVENT_REWRITE_CONTINUE; | 458 return ui::EVENT_REWRITE_CONTINUE; |
| 438 } | 459 } |
| 439 | 460 |
| 440 rewritten_event->reset(new ui::TouchEvent( | 461 rewritten_event->reset(new ui::TouchEvent( |
| 441 type, event.location(), event.touch_id(), event.time_stamp())); | 462 type, event.location(), event.touch_id(), event.time_stamp())); |
| 442 (*rewritten_event)->set_flags(event.flags()); | 463 (*rewritten_event)->set_flags(event.flags()); |
| 443 | 464 |
| 444 if (current_touch_ids_.size() == 0) { | 465 if (current_touch_ids_.size() == 0) { |
| 445 ResetToNoFingersDown(); | 466 ResetToNoFingersDown(); |
| 446 } | 467 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, | 500 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, |
| 480 last_touch_exploration_->location(), | 501 last_touch_exploration_->location(), |
| 481 initial_press_->touch_id(), | 502 initial_press_->touch_id(), |
| 482 event.time_stamp())); | 503 event.time_stamp())); |
| 483 (*rewritten_event)->set_flags(event.flags()); | 504 (*rewritten_event)->set_flags(event.flags()); |
| 484 EnterTouchToMouseMode(); | 505 EnterTouchToMouseMode(); |
| 485 state_ = TOUCH_EXPLORATION; | 506 state_ = TOUCH_EXPLORATION; |
| 486 VLOG_STATE(); | 507 VLOG_STATE(); |
| 487 return ui::EVENT_REWRITE_REWRITTEN; | 508 return ui::EVENT_REWRITE_REWRITTEN; |
| 488 } | 509 } |
| 489 NOTREACHED() << "Unexpected event type received."; | 510 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 490 return ui::EVENT_REWRITE_CONTINUE; | 511 return ui::EVENT_REWRITE_CONTINUE; |
| 491 } | 512 } |
| 492 | 513 |
| 493 ui::EventRewriteStatus TouchExplorationController::InWaitForRelease( | 514 ui::EventRewriteStatus TouchExplorationController::InWaitForRelease( |
| 494 const ui::TouchEvent& event, | 515 const ui::TouchEvent& event, |
| 495 scoped_ptr<ui::Event>* rewritten_event) { | 516 scoped_ptr<ui::Event>* rewritten_event) { |
| 496 ui::EventType type = event.type(); | 517 ui::EventType type = event.type(); |
| 497 if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED || | 518 if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED || |
| 498 type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) { | 519 type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) { |
| 499 NOTREACHED() << "Unexpected event type received."; | 520 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 500 return ui::EVENT_REWRITE_CONTINUE; | 521 return ui::EVENT_REWRITE_CONTINUE; |
| 501 } | 522 } |
| 502 if (current_touch_ids_.size() == 0) { | 523 if (current_touch_ids_.size() == 0) { |
| 503 state_ = NO_FINGERS_DOWN; | 524 state_ = NO_FINGERS_DOWN; |
| 504 VLOG_STATE(); | 525 VLOG_STATE(); |
| 505 ResetToNoFingersDown(); | 526 ResetToNoFingersDown(); |
| 506 } | 527 } |
| 507 return EVENT_REWRITE_DISCARD; | 528 return EVENT_REWRITE_DISCARD; |
| 508 } | 529 } |
| 509 | 530 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 } | 654 } |
| 634 | 655 |
| 635 void TouchExplorationController::ResetToNoFingersDown() { | 656 void TouchExplorationController::ResetToNoFingersDown() { |
| 636 state_ = NO_FINGERS_DOWN; | 657 state_ = NO_FINGERS_DOWN; |
| 637 VLOG_STATE(); | 658 VLOG_STATE(); |
| 638 if (tap_timer_.IsRunning()) | 659 if (tap_timer_.IsRunning()) |
| 639 tap_timer_.Stop(); | 660 tap_timer_.Stop(); |
| 640 } | 661 } |
| 641 | 662 |
| 642 void TouchExplorationController::VlogState(const char* function_name) { | 663 void TouchExplorationController::VlogState(const char* function_name) { |
| 664 if (!VLOG_on_) |
| 665 return; |
| 643 if (prev_state_ == state_) | 666 if (prev_state_ == state_) |
| 644 return; | 667 return; |
| 645 prev_state_ = state_; | 668 prev_state_ = state_; |
| 646 const char* state_string = EnumStateToString(state_); | 669 const char* state_string = EnumStateToString(state_); |
| 647 VLOG(0) << "\n Function name: " << function_name | 670 VLOG(0) << "\n Function name: " << function_name |
| 648 << "\n State: " << state_string; | 671 << "\n State: " << state_string; |
| 649 } | 672 } |
| 650 | 673 |
| 651 void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event, | 674 void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event, |
| 652 const char* function_name) { | 675 const char* function_name) { |
| 676 if (!VLOG_on_) |
| 677 return; |
| 678 |
| 653 CHECK(touch_event.IsTouchEvent()); | 679 CHECK(touch_event.IsTouchEvent()); |
| 654 if (prev_event_ != NULL && | 680 if (prev_event_ != NULL && |
| 655 prev_event_->type() == touch_event.type() && | 681 prev_event_->type() == touch_event.type() && |
| 656 prev_event_->touch_id() == touch_event.touch_id()){ | 682 prev_event_->touch_id() == touch_event.touch_id()){ |
| 657 return; | 683 return; |
| 658 } | 684 } |
| 659 // The above statement prevents events of the same type and id from being | 685 // The above statement prevents events of the same type and id from being |
| 660 // printed in a row. However, if two fingers are down, they would both be | 686 // printed in a row. However, if two fingers are down, they would both be |
| 661 // moving and alternating printing move events unless we check for this. | 687 // moving and alternating printing move events unless we check for this. |
| 662 if (prev_event_ != NULL && | 688 if (prev_event_ != NULL && |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 return "TWO_TO_ONE_FINGER"; | 723 return "TWO_TO_ONE_FINGER"; |
| 698 case PASSTHROUGH: | 724 case PASSTHROUGH: |
| 699 return "PASSTHROUGH"; | 725 return "PASSTHROUGH"; |
| 700 case WAIT_FOR_RELEASE: | 726 case WAIT_FOR_RELEASE: |
| 701 return "WAIT_FOR_RELEASE"; | 727 return "WAIT_FOR_RELEASE"; |
| 702 } | 728 } |
| 703 return "Not a state"; | 729 return "Not a state"; |
| 704 } | 730 } |
| 705 | 731 |
| 706 } // namespace ui | 732 } // namespace ui |
| OLD | NEW |