Chromium Code Reviews| 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" |
| 11 #include "ui/aura/window_event_dispatcher.h" | 11 #include "ui/aura/window_event_dispatcher.h" |
| 12 #include "ui/aura/window_tree_host.h" | 12 #include "ui/aura/window_tree_host.h" |
| 13 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
| 14 #include "ui/events/event_processor.h" | 14 #include "ui/events/event_processor.h" |
| 15 | 15 |
| 16 #define VLOG_STATE() if (VLOG_IS_ON(0)) VlogState(__func__) | 16 #define VLOG_STATE() if (VLOG_IS_ON(0)) VlogState(__func__) |
| 17 #define VLOG_EVENT(event) if (VLOG_IS_ON(0)) VlogEvent(event, __func__) | 17 #define VLOG_EVENT(event) if (VLOG_IS_ON(0)) VlogEvent(event, __func__) |
| 18 | 18 |
| 19 namespace ui { | 19 namespace ui { |
| 20 | 20 |
| 21 TouchExplorationController::TouchExplorationController( | 21 TouchExplorationController::TouchExplorationController( |
| 22 aura::Window* root_window) | 22 aura::Window* root_window) |
| 23 : root_window_(root_window), | 23 : root_window_(root_window), |
| 24 state_(NO_FINGERS_DOWN), | 24 state_(NO_FINGERS_DOWN), |
| 25 event_handler_for_testing_(NULL), | 25 event_handler_for_testing_(NULL), |
| 26 prev_state_(NO_FINGERS_DOWN) { | 26 prev_state_(NO_FINGERS_DOWN), |
| 27 VLOG_on_(true) { | |
| 27 CHECK(root_window); | 28 CHECK(root_window); |
| 28 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 29 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
| 29 } | 30 } |
| 30 | 31 |
| 31 | 32 |
| 32 TouchExplorationController::~TouchExplorationController() { | 33 TouchExplorationController::~TouchExplorationController() { |
| 33 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 34 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
| 34 } | 35 } |
| 35 | 36 |
| 36 void TouchExplorationController::CallTapTimerNowForTesting() { | 37 void TouchExplorationController::CallTapTimerNowForTesting() { |
| 37 DCHECK(tap_timer_.IsRunning()); | 38 DCHECK(tap_timer_.IsRunning()); |
| 38 tap_timer_.Stop(); | 39 tap_timer_.Stop(); |
| 39 OnTapTimerFired(); | 40 OnTapTimerFired(); |
| 40 } | 41 } |
| 41 | 42 |
| 43 void TouchExplorationController::CallTapTimerNowIfRunningForTesting() { | |
| 44 if (tap_timer_.IsRunning()) { | |
| 45 tap_timer_.Stop(); | |
| 46 OnTapTimerFired(); | |
| 47 } | |
| 48 } | |
| 49 | |
| 50 void TouchExplorationController::SwitchVLOG(bool turn_on) { | |
| 51 if (turn_on) | |
|
dmazzoni
2014/07/02 23:05:57
You can just say VLOG_on_ = turn_on, no "if" neede
evy
2014/07/02 23:16:03
Done.
| |
| 52 VLOG_on_ = true; | |
| 53 else | |
| 54 VLOG_on_ = false; | |
| 55 } | |
| 56 | |
| 42 void TouchExplorationController::SetEventHandlerForTesting( | 57 void TouchExplorationController::SetEventHandlerForTesting( |
| 43 ui::EventHandler* event_handler_for_testing) { | 58 ui::EventHandler* event_handler_for_testing) { |
| 44 event_handler_for_testing_ = event_handler_for_testing; | 59 event_handler_for_testing_ = event_handler_for_testing; |
| 45 } | 60 } |
| 46 | 61 |
| 47 bool TouchExplorationController::IsInNoFingersDownStateForTesting() const { | 62 bool TouchExplorationController::IsInNoFingersDownStateForTesting() const { |
| 48 return state_ == NO_FINGERS_DOWN; | 63 return state_ == NO_FINGERS_DOWN; |
| 49 } | 64 } |
| 50 | 65 |
| 51 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( | 66 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
| 52 const ui::Event& event, | 67 const ui::Event& event, |
| 53 scoped_ptr<ui::Event>* rewritten_event) { | 68 scoped_ptr<ui::Event>* rewritten_event) { |
| 54 if (!event.IsTouchEvent()) { | 69 if (!event.IsTouchEvent()) { |
| 55 if (event.IsKeyEvent()) { | 70 if (event.IsKeyEvent()) { |
| 56 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | 71 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); |
| 57 VLOG(0) << "\nKeyboard event: " << key_event.name() << "\n" | 72 VLOG(0) << "\nKeyboard event: " << key_event.name() |
| 58 << " Key code: " << key_event.key_code() | 73 << "\n Key code: " << key_event.key_code() |
| 59 << ", Flags: " << key_event.flags() | 74 << ", Flags: " << key_event.flags() |
| 60 << ", Is char: " << key_event.is_char(); | 75 << ", Is char: " << key_event.is_char(); |
| 61 } | 76 } |
| 62 if(event.IsGestureEvent()){ | 77 if(event.IsGestureEvent()){ |
| 63 VLOG(0) << "\n Gesture event " << event.name(); | 78 VLOG(0) << "\n Gesture event " << event.name(); |
| 64 } | 79 } |
| 65 return ui::EVENT_REWRITE_CONTINUE; | 80 return ui::EVENT_REWRITE_CONTINUE; |
| 66 } | 81 } |
| 67 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); | 82 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); |
| 68 | 83 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 initial_press_.reset(new TouchEvent(event)); | 164 initial_press_.reset(new TouchEvent(event)); |
| 150 last_unused_finger_event_.reset(new TouchEvent(event)); | 165 last_unused_finger_event_.reset(new TouchEvent(event)); |
| 151 tap_timer_.Start(FROM_HERE, | 166 tap_timer_.Start(FROM_HERE, |
| 152 gesture_detector_config_.double_tap_timeout, | 167 gesture_detector_config_.double_tap_timeout, |
| 153 this, | 168 this, |
| 154 &TouchExplorationController::OnTapTimerFired); | 169 &TouchExplorationController::OnTapTimerFired); |
| 155 state_ = SINGLE_TAP_PRESSED; | 170 state_ = SINGLE_TAP_PRESSED; |
| 156 VLOG_STATE(); | 171 VLOG_STATE(); |
| 157 return ui::EVENT_REWRITE_DISCARD; | 172 return ui::EVENT_REWRITE_DISCARD; |
| 158 } | 173 } |
| 159 NOTREACHED() << "Unexpected event type received."; | 174 NOTREACHED() << "Unexpected event type received: " << event.name();; |
| 160 return ui::EVENT_REWRITE_CONTINUE; | 175 return ui::EVENT_REWRITE_CONTINUE; |
| 161 } | 176 } |
| 162 | 177 |
| 163 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( | 178 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( |
| 164 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 179 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
| 165 const ui::EventType type = event.type(); | 180 const ui::EventType type = event.type(); |
| 166 | 181 |
| 167 if (type == ui::ET_TOUCH_PRESSED) { | 182 if (type == ui::ET_TOUCH_PRESSED) { |
| 168 // Adding a second finger within the timeout period switches to | 183 // Adding a second finger within the timeout period switches to |
| 169 // passing through every event from the second finger and none form the | 184 // passing through every event from the second finger and none form the |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 189 // high enough, and touch exploration if the velocity is lower. | 204 // high enough, and touch exploration if the velocity is lower. |
| 190 float delta = (event.location() - initial_press_->location()).Length(); | 205 float delta = (event.location() - initial_press_->location()).Length(); |
| 191 if (delta > gesture_detector_config_.touch_slop) { | 206 if (delta > gesture_detector_config_.touch_slop) { |
| 192 EnterTouchToMouseMode(); | 207 EnterTouchToMouseMode(); |
| 193 state_ = TOUCH_EXPLORATION; | 208 state_ = TOUCH_EXPLORATION; |
| 194 VLOG_STATE(); | 209 VLOG_STATE(); |
| 195 return InTouchExploration(event, rewritten_event); | 210 return InTouchExploration(event, rewritten_event); |
| 196 } | 211 } |
| 197 return EVENT_REWRITE_DISCARD; | 212 return EVENT_REWRITE_DISCARD; |
| 198 } | 213 } |
| 199 NOTREACHED() << "Unexpected event type received."; | 214 NOTREACHED() << "Unexpected event type received: " << event.name();; |
| 200 return ui::EVENT_REWRITE_CONTINUE; | 215 return ui::EVENT_REWRITE_CONTINUE; |
| 201 } | 216 } |
| 202 | 217 |
| 203 ui::EventRewriteStatus | 218 ui::EventRewriteStatus |
| 204 TouchExplorationController::InSingleTapOrTouchExploreReleased( | 219 TouchExplorationController::InSingleTapOrTouchExploreReleased( |
| 205 const ui::TouchEvent& event, | 220 const ui::TouchEvent& event, |
| 206 scoped_ptr<ui::Event>* rewritten_event) { | 221 scoped_ptr<ui::Event>* rewritten_event) { |
| 207 const ui::EventType type = event.type(); | 222 const ui::EventType type = event.type(); |
| 208 if (type == ui::ET_TOUCH_PRESSED) { | 223 if (type == ui::ET_TOUCH_PRESSED) { |
| 209 // This is the second tap in a double-tap (or double tap-hold). | 224 // This is the second tap in a double-tap (or double tap-hold). |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 221 state_ = DOUBLE_TAP_PRESSED; | 236 state_ = DOUBLE_TAP_PRESSED; |
| 222 VLOG_STATE(); | 237 VLOG_STATE(); |
| 223 return ui::EVENT_REWRITE_REWRITTEN; | 238 return ui::EVENT_REWRITE_REWRITTEN; |
| 224 } else if (type == ui::ET_TOUCH_RELEASED && !last_touch_exploration_) { | 239 } else if (type == ui::ET_TOUCH_RELEASED && !last_touch_exploration_) { |
| 225 // If the previous press was discarded, we need to also handle its | 240 // If the previous press was discarded, we need to also handle its |
| 226 // release. | 241 // release. |
| 227 if (current_touch_ids_.size() == 0) { | 242 if (current_touch_ids_.size() == 0) { |
| 228 ResetToNoFingersDown(); | 243 ResetToNoFingersDown(); |
| 229 } | 244 } |
| 230 return ui::EVENT_REWRITE_DISCARD; | 245 return ui::EVENT_REWRITE_DISCARD; |
| 246 } else if (type == ui::ET_TOUCH_MOVED){ | |
| 247 return ui::EVENT_REWRITE_DISCARD; | |
| 231 } | 248 } |
| 232 NOTREACHED() << "Unexpected event type received."; | 249 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 233 return ui::EVENT_REWRITE_CONTINUE; | 250 return ui::EVENT_REWRITE_CONTINUE; |
| 234 } | 251 } |
| 235 | 252 |
| 236 ui::EventRewriteStatus TouchExplorationController::InDoubleTapPressed( | 253 ui::EventRewriteStatus TouchExplorationController::InDoubleTapPressed( |
| 237 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { | 254 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) { |
| 238 const ui::EventType type = event.type(); | 255 const ui::EventType type = event.type(); |
| 239 if (type == ui::ET_TOUCH_PRESSED) { | 256 if (type == ui::ET_TOUCH_PRESSED) { |
| 240 return ui::EVENT_REWRITE_DISCARD; | 257 return ui::EVENT_REWRITE_DISCARD; |
| 241 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 258 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
| 242 if (current_touch_ids_.size() != 0) | 259 if (current_touch_ids_.size() != 0) |
| 243 return EVENT_REWRITE_DISCARD; | 260 return EVENT_REWRITE_DISCARD; |
| 244 | 261 |
| 245 // Rewrite release at location of last touch exploration with the same | 262 // Rewrite release at location of last touch exploration with the same |
| 246 // id as the prevoius press. | 263 // id as the prevoius press. |
| 247 rewritten_event->reset( | 264 rewritten_event->reset( |
| 248 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, | 265 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, |
| 249 last_touch_exploration_->location(), | 266 last_touch_exploration_->location(), |
| 250 initial_press_->touch_id(), | 267 initial_press_->touch_id(), |
| 251 event.time_stamp())); | 268 event.time_stamp())); |
| 252 (*rewritten_event)->set_flags(event.flags()); | 269 (*rewritten_event)->set_flags(event.flags()); |
| 253 ResetToNoFingersDown(); | 270 ResetToNoFingersDown(); |
| 254 return ui::EVENT_REWRITE_REWRITTEN; | 271 return ui::EVENT_REWRITE_REWRITTEN; |
| 255 } else if (type == ui::ET_TOUCH_MOVED) { | 272 } else if (type == ui::ET_TOUCH_MOVED) { |
| 256 return ui::EVENT_REWRITE_DISCARD; | 273 return ui::EVENT_REWRITE_DISCARD; |
| 257 } | 274 } |
| 258 NOTREACHED() << "Unexpected event type received."; | 275 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 259 return ui::EVENT_REWRITE_CONTINUE; | 276 return ui::EVENT_REWRITE_CONTINUE; |
| 260 } | 277 } |
| 261 | 278 |
| 262 ui::EventRewriteStatus TouchExplorationController::InTouchExploration( | 279 ui::EventRewriteStatus TouchExplorationController::InTouchExploration( |
| 263 const ui::TouchEvent& event, | 280 const ui::TouchEvent& event, |
| 264 scoped_ptr<ui::Event>* rewritten_event) { | 281 scoped_ptr<ui::Event>* rewritten_event) { |
| 265 const ui::EventType type = event.type(); | 282 const ui::EventType type = event.type(); |
| 266 if (type == ui::ET_TOUCH_PRESSED) { | 283 if (type == ui::ET_TOUCH_PRESSED) { |
| 267 // Handle split-tap. | 284 // Handle split-tap. |
| 268 initial_press_.reset(new TouchEvent(event)); | 285 initial_press_.reset(new TouchEvent(event)); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 279 return ui::EVENT_REWRITE_REWRITTEN; | 296 return ui::EVENT_REWRITE_REWRITTEN; |
| 280 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 297 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
| 281 initial_press_.reset(new TouchEvent(event)); | 298 initial_press_.reset(new TouchEvent(event)); |
| 282 tap_timer_.Start(FROM_HERE, | 299 tap_timer_.Start(FROM_HERE, |
| 283 gesture_detector_config_.double_tap_timeout, | 300 gesture_detector_config_.double_tap_timeout, |
| 284 this, | 301 this, |
| 285 &TouchExplorationController::OnTapTimerFired); | 302 &TouchExplorationController::OnTapTimerFired); |
| 286 state_ = TOUCH_EXPLORE_RELEASED; | 303 state_ = TOUCH_EXPLORE_RELEASED; |
| 287 VLOG_STATE(); | 304 VLOG_STATE(); |
| 288 } else if (type != ui::ET_TOUCH_MOVED) { | 305 } else if (type != ui::ET_TOUCH_MOVED) { |
| 289 NOTREACHED() << "Unexpected event type received."; | 306 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 290 return ui::EVENT_REWRITE_CONTINUE; | 307 return ui::EVENT_REWRITE_CONTINUE; |
| 291 } | 308 } |
| 292 | 309 |
| 293 // Rewrite as a mouse-move event. | 310 // Rewrite as a mouse-move event. |
| 294 *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags()); | 311 *rewritten_event = CreateMouseMoveEvent(event.location(), event.flags()); |
| 295 last_touch_exploration_.reset(new TouchEvent(event)); | 312 last_touch_exploration_.reset(new TouchEvent(event)); |
| 296 return ui::EVENT_REWRITE_REWRITTEN; | 313 return ui::EVENT_REWRITE_REWRITTEN; |
| 297 } | 314 } |
| 298 | 315 |
| 299 | |
| 300 ui::EventRewriteStatus TouchExplorationController::InTwoToOneFinger( | 316 ui::EventRewriteStatus TouchExplorationController::InTwoToOneFinger( |
| 301 const ui::TouchEvent& event, | 317 const ui::TouchEvent& event, |
| 302 scoped_ptr<ui::Event>* rewritten_event) { | 318 scoped_ptr<ui::Event>* rewritten_event) { |
| 303 // The user should only ever be in TWO_TO_ONE_FINGER with two fingers down. | 319 // The user should only ever be in TWO_TO_ONE_FINGER with two fingers down. |
| 304 // If the user added or removed a finger, the state is changed. | 320 // If the user added or removed a finger, the state is changed. |
| 305 ui::EventType type = event.type(); | 321 ui::EventType type = event.type(); |
| 306 if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 322 if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
| 307 DCHECK(current_touch_ids_.size() == 1); | 323 DCHECK(current_touch_ids_.size() == 1); |
| 308 // Stop passing through the second finger and go to the wait state. | 324 // Stop passing through the second finger and go to the wait state. |
| 309 if (current_touch_ids_.size() == 1) { | 325 if (current_touch_ids_.size() == 1) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 if (event.touch_id() == last_two_to_one_->touch_id()) { | 364 if (event.touch_id() == last_two_to_one_->touch_id()) { |
| 349 last_two_to_one_.reset(new TouchEvent(event)); | 365 last_two_to_one_.reset(new TouchEvent(event)); |
| 350 rewritten_event->reset(new ui::TouchEvent(ui::ET_TOUCH_MOVED, | 366 rewritten_event->reset(new ui::TouchEvent(ui::ET_TOUCH_MOVED, |
| 351 event.location(), | 367 event.location(), |
| 352 event.touch_id(), | 368 event.touch_id(), |
| 353 event.time_stamp())); | 369 event.time_stamp())); |
| 354 (*rewritten_event)->set_flags(event.flags()); | 370 (*rewritten_event)->set_flags(event.flags()); |
| 355 return ui::EVENT_REWRITE_REWRITTEN; | 371 return ui::EVENT_REWRITE_REWRITTEN; |
| 356 } | 372 } |
| 357 } | 373 } |
| 358 NOTREACHED() << "Unexpected event type received"; | 374 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 359 return ui::EVENT_REWRITE_CONTINUE; | 375 return ui::EVENT_REWRITE_CONTINUE; |
| 360 } | 376 } |
| 361 | 377 |
| 362 ui::EventRewriteStatus TouchExplorationController::InPassthrough( | 378 ui::EventRewriteStatus TouchExplorationController::InPassthrough( |
| 363 const ui::TouchEvent& event, | 379 const ui::TouchEvent& event, |
| 364 scoped_ptr<ui::Event>* rewritten_event) { | 380 scoped_ptr<ui::Event>* rewritten_event) { |
| 365 ui::EventType type = event.type(); | 381 ui::EventType type = event.type(); |
| 366 | 382 |
| 367 if (!(type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED || | 383 if (!(type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED || |
| 368 type == ui::ET_TOUCH_MOVED || type == ui::ET_TOUCH_PRESSED)) { | 384 type == ui::ET_TOUCH_MOVED || type == ui::ET_TOUCH_PRESSED)) { |
| 369 NOTREACHED() << "Unexpected event type received."; | 385 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 370 return ui::EVENT_REWRITE_CONTINUE; | 386 return ui::EVENT_REWRITE_CONTINUE; |
| 371 } | 387 } |
| 372 | 388 |
| 373 rewritten_event->reset(new ui::TouchEvent( | 389 rewritten_event->reset(new ui::TouchEvent( |
| 374 type, event.location(), event.touch_id(), event.time_stamp())); | 390 type, event.location(), event.touch_id(), event.time_stamp())); |
| 375 (*rewritten_event)->set_flags(event.flags()); | 391 (*rewritten_event)->set_flags(event.flags()); |
| 376 | 392 |
| 377 if (current_touch_ids_.size() == 0) { | 393 if (current_touch_ids_.size() == 0) { |
| 378 ResetToNoFingersDown(); | 394 ResetToNoFingersDown(); |
| 379 } | 395 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 rewritten_event->reset( | 427 rewritten_event->reset( |
| 412 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, | 428 new ui::TouchEvent(ui::ET_TOUCH_RELEASED, |
| 413 last_touch_exploration_->location(), | 429 last_touch_exploration_->location(), |
| 414 initial_press_->touch_id(), | 430 initial_press_->touch_id(), |
| 415 event.time_stamp())); | 431 event.time_stamp())); |
| 416 (*rewritten_event)->set_flags(event.flags()); | 432 (*rewritten_event)->set_flags(event.flags()); |
| 417 state_ = TOUCH_EXPLORATION; | 433 state_ = TOUCH_EXPLORATION; |
| 418 VLOG_STATE(); | 434 VLOG_STATE(); |
| 419 return ui::EVENT_REWRITE_REWRITTEN; | 435 return ui::EVENT_REWRITE_REWRITTEN; |
| 420 } | 436 } |
| 421 NOTREACHED() << "Unexpected event type received."; | 437 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 422 return ui::EVENT_REWRITE_CONTINUE; | 438 return ui::EVENT_REWRITE_CONTINUE; |
| 423 } | 439 } |
| 424 | 440 |
| 425 ui::EventRewriteStatus TouchExplorationController::InWaitForRelease( | 441 ui::EventRewriteStatus TouchExplorationController::InWaitForRelease( |
| 426 const ui::TouchEvent& event, | 442 const ui::TouchEvent& event, |
| 427 scoped_ptr<ui::Event>* rewritten_event) { | 443 scoped_ptr<ui::Event>* rewritten_event) { |
| 428 ui::EventType type = event.type(); | 444 ui::EventType type = event.type(); |
| 429 if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED || | 445 if (!(type == ui::ET_TOUCH_PRESSED || type == ui::ET_TOUCH_MOVED || |
| 430 type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) { | 446 type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED)) { |
| 431 NOTREACHED() << "Unexpected event type received."; | 447 NOTREACHED() << "Unexpected event type received: " << event.name(); |
| 432 return ui::EVENT_REWRITE_CONTINUE; | 448 return ui::EVENT_REWRITE_CONTINUE; |
| 433 } | 449 } |
| 434 if (current_touch_ids_.size() == 0) { | 450 if (current_touch_ids_.size() == 0) { |
| 435 state_ = NO_FINGERS_DOWN; | 451 state_ = NO_FINGERS_DOWN; |
| 436 ResetToNoFingersDown(); | 452 ResetToNoFingersDown(); |
| 437 } | 453 } |
| 438 return EVENT_REWRITE_DISCARD; | 454 return EVENT_REWRITE_DISCARD; |
| 439 } | 455 } |
| 440 | 456 |
| 441 void TouchExplorationController::OnTapTimerFired() { | 457 void TouchExplorationController::OnTapTimerFired() { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 } | 509 } |
| 494 | 510 |
| 495 void TouchExplorationController::ResetToNoFingersDown() { | 511 void TouchExplorationController::ResetToNoFingersDown() { |
| 496 state_ = NO_FINGERS_DOWN; | 512 state_ = NO_FINGERS_DOWN; |
| 497 VLOG_STATE(); | 513 VLOG_STATE(); |
| 498 if (tap_timer_.IsRunning()) | 514 if (tap_timer_.IsRunning()) |
| 499 tap_timer_.Stop(); | 515 tap_timer_.Stop(); |
| 500 } | 516 } |
| 501 | 517 |
| 502 void TouchExplorationController::VlogState(const char* function_name) { | 518 void TouchExplorationController::VlogState(const char* function_name) { |
| 519 if (!VLOG_on_) | |
| 520 return; | |
| 503 if (prev_state_ == state_) | 521 if (prev_state_ == state_) |
| 504 return; | 522 return; |
| 505 prev_state_ = state_; | 523 prev_state_ = state_; |
| 506 const char* state_string = EnumStateToString(state_); | 524 const char* state_string = EnumStateToString(state_); |
| 507 VLOG(0) << "\n Function name: " << function_name | 525 VLOG(0) << "\n Function name: " << function_name |
| 508 << "\n State: " << state_string; | 526 << "\n State: " << state_string; |
| 509 } | 527 } |
| 510 | 528 |
| 511 void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event, | 529 void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event, |
| 512 const char* function_name) { | 530 const char* function_name) { |
| 531 if (!VLOG_on_) | |
| 532 return; | |
| 533 | |
| 513 CHECK(touch_event.IsTouchEvent()); | 534 CHECK(touch_event.IsTouchEvent()); |
| 514 if (prev_event_ != NULL && | 535 if (prev_event_ != NULL && |
| 515 prev_event_->type() == touch_event.type() && | 536 prev_event_->type() == touch_event.type() && |
| 516 prev_event_->touch_id() == touch_event.touch_id()){ | 537 prev_event_->touch_id() == touch_event.touch_id()){ |
| 517 return; | 538 return; |
| 518 } | 539 } |
| 519 // The above statement prevents events of the same type and id from being | 540 // The above statement prevents events of the same type and id from being |
| 520 // printed in a row. However, if two fingers are down, they would both be | 541 // printed in a row. However, if two fingers are down, they would both be |
| 521 // moving and alternating printing move events unless we check for this. | 542 // moving and alternating printing move events unless we check for this. |
| 522 if (prev_event_ != NULL && | 543 if (prev_event_ != NULL && |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 return "TWO_TO_ONE_FINGER"; | 576 return "TWO_TO_ONE_FINGER"; |
| 556 case PASSTHROUGH: | 577 case PASSTHROUGH: |
| 557 return "PASSTHROUGH"; | 578 return "PASSTHROUGH"; |
| 558 case WAIT_FOR_RELEASE: | 579 case WAIT_FOR_RELEASE: |
| 559 return "WAIT_FOR_RELEASE"; | 580 return "WAIT_FOR_RELEASE"; |
| 560 } | 581 } |
| 561 return "Not a state"; | 582 return "Not a state"; |
| 562 } | 583 } |
| 563 | 584 |
| 564 } // namespace ui | 585 } // namespace ui |
| OLD | NEW |