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

Side by Side Diff: ui/events/event.cc

Issue 680413006: Re-enable Eager Gesture Recognition on Aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments (still some tests to come) Created 6 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/events/event.h" 5 #include "ui/events/event.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/keysym.h> 10 #include <X11/keysym.h>
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 CHECK(IsGestureEvent()); 161 CHECK(IsGestureEvent());
162 return static_cast<const GestureEvent*>(this); 162 return static_cast<const GestureEvent*>(this);
163 } 163 }
164 164
165 bool Event::HasNativeEvent() const { 165 bool Event::HasNativeEvent() const {
166 base::NativeEvent null_event; 166 base::NativeEvent null_event;
167 std::memset(&null_event, 0, sizeof(null_event)); 167 std::memset(&null_event, 0, sizeof(null_event));
168 return !!std::memcmp(&native_event_, &null_event, sizeof(null_event)); 168 return !!std::memcmp(&native_event_, &null_event, sizeof(null_event));
169 } 169 }
170 170
171 void Event::DisableSynchronousHandling() {
172 result_ = static_cast<EventResult>(result_ | ER_DISABLE_SYNC_HANDLING);
173 }
174
171 void Event::StopPropagation() { 175 void Event::StopPropagation() {
172 // TODO(sad): Re-enable these checks once View uses dispatcher to dispatch 176 // TODO(sad): Re-enable these checks once View uses dispatcher to dispatch
173 // events. 177 // events.
174 // CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH); 178 // CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH);
175 CHECK(cancelable_); 179 CHECK(cancelable_);
176 result_ = static_cast<EventResult>(result_ | ER_CONSUMED); 180 result_ = static_cast<EventResult>(result_ | ER_CONSUMED);
177 } 181 }
178 182
179 void Event::SetHandled() { 183 void Event::SetHandled() {
180 // TODO(sad): Re-enable these checks once View uses dispatcher to dispatch 184 // TODO(sad): Re-enable these checks once View uses dispatcher to dispatch
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 gfx::ToRoundedInt(SkMScalarToFloat(offset_.y() * decomp.scale[1]))); 509 gfx::ToRoundedInt(SkMScalarToFloat(offset_.y() * decomp.scale[1])));
506 } 510 }
507 } 511 }
508 512
509 //////////////////////////////////////////////////////////////////////////////// 513 ////////////////////////////////////////////////////////////////////////////////
510 // TouchEvent 514 // TouchEvent
511 515
512 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 516 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
513 : LocatedEvent(native_event), 517 : LocatedEvent(native_event),
514 touch_id_(GetTouchId(native_event)), 518 touch_id_(GetTouchId(native_event)),
519 touch_event_id_(get_next_touch_event_id()),
515 radius_x_(GetTouchRadiusX(native_event)), 520 radius_x_(GetTouchRadiusX(native_event)),
516 radius_y_(GetTouchRadiusY(native_event)), 521 radius_y_(GetTouchRadiusY(native_event)),
517 rotation_angle_(GetTouchAngle(native_event)), 522 rotation_angle_(GetTouchAngle(native_event)),
518 force_(GetTouchForce(native_event)) { 523 force_(GetTouchForce(native_event)) {
519 latency()->AddLatencyNumberWithTimestamp( 524 latency()->AddLatencyNumberWithTimestamp(
520 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 525 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
521 0, 526 0,
522 0, 527 0,
523 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 528 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()),
524 1); 529 1);
525 530
526 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 531 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
527 532
528 if (type() == ET_TOUCH_PRESSED) 533 if (type() == ET_TOUCH_PRESSED)
529 IncrementTouchIdRefCount(native_event); 534 IncrementTouchIdRefCount(native_event);
530 } 535 }
531 536
532 TouchEvent::TouchEvent(EventType type, 537 TouchEvent::TouchEvent(EventType type,
533 const gfx::PointF& location, 538 const gfx::PointF& location,
534 int touch_id, 539 int touch_id,
535 base::TimeDelta time_stamp) 540 base::TimeDelta time_stamp)
536 : LocatedEvent(type, location, location, time_stamp, 0), 541 : LocatedEvent(type, location, location, time_stamp, 0),
537 touch_id_(touch_id), 542 touch_id_(touch_id),
543 touch_event_id_(get_next_touch_event_id()),
538 radius_x_(0.0f), 544 radius_x_(0.0f),
539 radius_y_(0.0f), 545 radius_y_(0.0f),
540 rotation_angle_(0.0f), 546 rotation_angle_(0.0f),
541 force_(0.0f) { 547 force_(0.0f) {
542 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 548 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
543 } 549 }
544 550
545 TouchEvent::TouchEvent(EventType type, 551 TouchEvent::TouchEvent(EventType type,
546 const gfx::PointF& location, 552 const gfx::PointF& location,
547 int flags, 553 int flags,
548 int touch_id, 554 int touch_id,
549 base::TimeDelta time_stamp, 555 base::TimeDelta time_stamp,
550 float radius_x, 556 float radius_x,
551 float radius_y, 557 float radius_y,
552 float angle, 558 float angle,
553 float force) 559 float force)
554 : LocatedEvent(type, location, location, time_stamp, flags), 560 : LocatedEvent(type, location, location, time_stamp, flags),
555 touch_id_(touch_id), 561 touch_id_(touch_id),
562 touch_event_id_(get_next_touch_event_id()),
556 radius_x_(radius_x), 563 radius_x_(radius_x),
557 radius_y_(radius_y), 564 radius_y_(radius_y),
558 rotation_angle_(angle), 565 rotation_angle_(angle),
559 force_(force) { 566 force_(force) {
560 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 567 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
561 } 568 }
562 569
563 TouchEvent::~TouchEvent() { 570 TouchEvent::~TouchEvent() {
564 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 571 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11
565 // platform setups the tracking_id to slot mapping. So in dtor here, 572 // platform setups the tracking_id to slot mapping. So in dtor here,
566 // if this touch event is a release event, we clear the mapping accordingly. 573 // if this touch event is a release event, we clear the mapping accordingly.
567 if (HasNativeEvent()) 574 if (HasNativeEvent())
568 ClearTouchIdIfReleased(native_event()); 575 ClearTouchIdIfReleased(native_event());
569 } 576 }
570 577
571 void TouchEvent::UpdateForRootTransform( 578 void TouchEvent::UpdateForRootTransform(
572 const gfx::Transform& inverted_root_transform) { 579 const gfx::Transform& inverted_root_transform) {
573 LocatedEvent::UpdateForRootTransform(inverted_root_transform); 580 LocatedEvent::UpdateForRootTransform(inverted_root_transform);
574 gfx::DecomposedTransform decomp; 581 gfx::DecomposedTransform decomp;
575 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); 582 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform);
576 DCHECK(success); 583 DCHECK(success);
577 if (decomp.scale[0]) 584 if (decomp.scale[0])
578 radius_x_ *= decomp.scale[0]; 585 radius_x_ *= decomp.scale[0];
579 if (decomp.scale[1]) 586 if (decomp.scale[1])
580 radius_y_ *= decomp.scale[1]; 587 radius_y_ *= decomp.scale[1];
581 } 588 }
582 589
590 int TouchEvent::get_next_touch_event_id() {
sadrul 2014/11/27 20:39:30 Make this an internal function in the anon namespa
tdresser 2014/11/28 18:33:37 Done.
591 static int id = 0;
592 // We shouldn't have many touch events in existence at a
593 // time. 100000 should give us plenty of headroom.
594 return id++ % 100000;
sadrul 2014/11/27 20:39:30 const int kMaxTouchEventId = 100000; But why have
tdresser 2014/11/28 18:33:37 Done.
595 }
596
583 //////////////////////////////////////////////////////////////////////////////// 597 ////////////////////////////////////////////////////////////////////////////////
584 // KeyEvent 598 // KeyEvent
585 599
586 // static 600 // static
587 KeyEvent* KeyEvent::last_key_event_ = NULL; 601 KeyEvent* KeyEvent::last_key_event_ = NULL;
588 602
589 // static 603 // static
590 bool KeyEvent::IsRepeated(const KeyEvent& event) { 604 bool KeyEvent::IsRepeated(const KeyEvent& event) {
591 // A safe guard in case if there were continous key pressed events that are 605 // A safe guard in case if there were continous key pressed events that are
592 // not auto repeat. 606 // not auto repeat.
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 gfx::PointF(x, y), 984 gfx::PointF(x, y),
971 time_stamp, 985 time_stamp,
972 flags | EF_FROM_TOUCH), 986 flags | EF_FROM_TOUCH),
973 details_(details) { 987 details_(details) {
974 } 988 }
975 989
976 GestureEvent::~GestureEvent() { 990 GestureEvent::~GestureEvent() {
977 } 991 }
978 992
979 } // namespace ui 993 } // namespace ui
OLDNEW
« ui/events/event.h ('K') | « ui/events/event.h ('k') | ui/events/event_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698