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

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

Issue 869433007: Revert of Don't refcount tracking id -> slot id mapping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/keysym.h> 9 #include <X11/keysym.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 // TouchEvent 519 // TouchEvent
520 520
521 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 521 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
522 : LocatedEvent(native_event), 522 : LocatedEvent(native_event),
523 touch_id_(GetTouchId(native_event)), 523 touch_id_(GetTouchId(native_event)),
524 unique_event_id_(get_next_touch_event_id()), 524 unique_event_id_(get_next_touch_event_id()),
525 radius_x_(GetTouchRadiusX(native_event)), 525 radius_x_(GetTouchRadiusX(native_event)),
526 radius_y_(GetTouchRadiusY(native_event)), 526 radius_y_(GetTouchRadiusY(native_event)),
527 rotation_angle_(GetTouchAngle(native_event)), 527 rotation_angle_(GetTouchAngle(native_event)),
528 force_(GetTouchForce(native_event)), 528 force_(GetTouchForce(native_event)),
529 should_remove_native_touch_id_mapping_(false) { 529 may_cause_scrolling_(false) {
530 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) 530 latency()->AddLatencyNumberWithTimestamp(
531 should_remove_native_touch_id_mapping_ = true; 531 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
532 0,
533 0,
534 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()),
535 1);
532 536
533 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 537 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
534 FixRotationAngle(); 538 fixRotationAngle();
535 539
536 latency()->AddLatencyNumberWithTimestamp( 540 if (type() == ET_TOUCH_PRESSED)
537 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, 541 IncrementTouchIdRefCount(native_event);
538 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
539 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
540 } 542 }
541 543
542 TouchEvent::TouchEvent(EventType type, 544 TouchEvent::TouchEvent(EventType type,
543 const gfx::PointF& location, 545 const gfx::PointF& location,
544 int touch_id, 546 int touch_id,
545 base::TimeDelta time_stamp) 547 base::TimeDelta time_stamp)
546 : LocatedEvent(type, location, location, time_stamp, 0), 548 : LocatedEvent(type, location, location, time_stamp, 0),
547 touch_id_(touch_id), 549 touch_id_(touch_id),
548 unique_event_id_(get_next_touch_event_id()), 550 unique_event_id_(get_next_touch_event_id()),
549 radius_x_(0.0f), 551 radius_x_(0.0f),
550 radius_y_(0.0f), 552 radius_y_(0.0f),
551 rotation_angle_(0.0f), 553 rotation_angle_(0.0f),
552 force_(0.0f), 554 force_(0.0f),
553 should_remove_native_touch_id_mapping_(false) { 555 may_cause_scrolling_(false) {
554 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 556 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
555 } 557 }
556 558
557 TouchEvent::TouchEvent(EventType type, 559 TouchEvent::TouchEvent(EventType type,
558 const gfx::PointF& location, 560 const gfx::PointF& location,
559 int flags, 561 int flags,
560 int touch_id, 562 int touch_id,
561 base::TimeDelta time_stamp, 563 base::TimeDelta time_stamp,
562 float radius_x, 564 float radius_x,
563 float radius_y, 565 float radius_y,
564 float angle, 566 float angle,
565 float force) 567 float force)
566 : LocatedEvent(type, location, location, time_stamp, flags), 568 : LocatedEvent(type, location, location, time_stamp, flags),
567 touch_id_(touch_id), 569 touch_id_(touch_id),
568 unique_event_id_(get_next_touch_event_id()), 570 unique_event_id_(get_next_touch_event_id()),
569 radius_x_(radius_x), 571 radius_x_(radius_x),
570 radius_y_(radius_y), 572 radius_y_(radius_y),
571 rotation_angle_(angle), 573 rotation_angle_(angle),
572 force_(force), 574 force_(force),
573 should_remove_native_touch_id_mapping_(false) { 575 may_cause_scrolling_(false) {
574 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 576 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
575 FixRotationAngle(); 577 fixRotationAngle();
576 } 578 }
577 579
578 TouchEvent::~TouchEvent() { 580 TouchEvent::~TouchEvent() {
579 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11 581 // In ctor TouchEvent(native_event) we call GetTouchId() which in X11
580 // platform setups the tracking_id to slot mapping. So in dtor here, 582 // platform setups the tracking_id to slot mapping. So in dtor here,
581 // if this touch event is a release event, we clear the mapping accordingly. 583 // if this touch event is a release event, we clear the mapping accordingly.
582 if (should_remove_native_touch_id_mapping_) { 584 if (HasNativeEvent())
583 DCHECK(type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED); 585 ClearTouchIdIfReleased(native_event());
584 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
585 ClearTouchIdIfReleased(native_event());
586 }
587 } 586 }
588 587
589 void TouchEvent::UpdateForRootTransform( 588 void TouchEvent::UpdateForRootTransform(
590 const gfx::Transform& inverted_root_transform) { 589 const gfx::Transform& inverted_root_transform) {
591 LocatedEvent::UpdateForRootTransform(inverted_root_transform); 590 LocatedEvent::UpdateForRootTransform(inverted_root_transform);
592 gfx::DecomposedTransform decomp; 591 gfx::DecomposedTransform decomp;
593 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); 592 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform);
594 DCHECK(success); 593 DCHECK(success);
595 if (decomp.scale[0]) 594 if (decomp.scale[0])
596 radius_x_ *= decomp.scale[0]; 595 radius_x_ *= decomp.scale[0];
597 if (decomp.scale[1]) 596 if (decomp.scale[1])
598 radius_y_ *= decomp.scale[1]; 597 radius_y_ *= decomp.scale[1];
599 } 598 }
600 599
601 void TouchEvent::DisableSynchronousHandling() { 600 void TouchEvent::DisableSynchronousHandling() {
602 DispatcherApi dispatcher_api(this); 601 DispatcherApi dispatcher_api(this);
603 dispatcher_api.set_result( 602 dispatcher_api.set_result(
604 static_cast<EventResult>(result() | ER_DISABLE_SYNC_HANDLING)); 603 static_cast<EventResult>(result() | ER_DISABLE_SYNC_HANDLING));
605 } 604 }
606 605
607 void TouchEvent::FixRotationAngle() { 606 void TouchEvent::fixRotationAngle() {
608 while (rotation_angle_ < 0) 607 while (rotation_angle_ < 0)
609 rotation_angle_ += 180; 608 rotation_angle_ += 180;
610 while (rotation_angle_ >= 180) 609 while (rotation_angle_ >= 180)
611 rotation_angle_ -= 180; 610 rotation_angle_ -= 180;
612 } 611 }
613 612
614 //////////////////////////////////////////////////////////////////////////////// 613 ////////////////////////////////////////////////////////////////////////////////
615 // KeyEvent 614 // KeyEvent
616 615
617 // static 616 // static
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 gfx::PointF(x, y), 973 gfx::PointF(x, y),
975 time_stamp, 974 time_stamp,
976 flags | EF_FROM_TOUCH), 975 flags | EF_FROM_TOUCH),
977 details_(details) { 976 details_(details) {
978 } 977 }
979 978
980 GestureEvent::~GestureEvent() { 979 GestureEvent::~GestureEvent() {
981 } 980 }
982 981
983 } // namespace ui 982 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event.h ('k') | ui/events/event_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698