Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: ui/chromeos/touch_exploration_controller.cc

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

Powered by Google App Engine
This is Rietveld 408576698