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

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

Issue 999423003: Set the unique_event_id when converting from TouchEvent to WebTouchEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 (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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask | 104 Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask |
105 Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask | ShiftMask | 105 Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask | ShiftMask |
106 LockMask | ControlMask | AnyModifier; 106 LockMask | ControlMask | AnyModifier;
107 return event && (event->xkey.state & ~kAllStateMask) != 0; 107 return event && (event->xkey.state & ~kAllStateMask) != 0;
108 #else 108 #else
109 return false; 109 return false;
110 #endif 110 #endif
111 } 111 }
112 112
113 unsigned long long get_next_touch_event_id() { 113 unsigned long long get_next_touch_event_id() {
114 static unsigned long long id = 0; 114 // Set the first touch_event_id to 1 because we set id to 0 for other types
115 // of events.
116 static unsigned long long id = 1;
115 return id++; 117 return id++;
tdresser 2015/03/16 12:24:12 We should check if id has wrapped around, and set
lanwei 2015/03/16 19:06:07 Done.
116 } 118 }
117 119
118 } // namespace 120 } // namespace
119 121
120 namespace ui { 122 namespace ui {
121 123
122 //////////////////////////////////////////////////////////////////////////////// 124 ////////////////////////////////////////////////////////////////////////////////
123 // Event 125 // Event
124 126
125 // static 127 // static
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 gfx::ToRoundedInt(SkMScalarToFloat(offset_.y() * decomp.scale[1]))); 522 gfx::ToRoundedInt(SkMScalarToFloat(offset_.y() * decomp.scale[1])));
521 } 523 }
522 } 524 }
523 525
524 //////////////////////////////////////////////////////////////////////////////// 526 ////////////////////////////////////////////////////////////////////////////////
525 // TouchEvent 527 // TouchEvent
526 528
527 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 529 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
528 : LocatedEvent(native_event), 530 : LocatedEvent(native_event),
529 touch_id_(GetTouchId(native_event)), 531 touch_id_(GetTouchId(native_event)),
530 unique_event_id_(get_next_touch_event_id()), 532 unique_touch_event_id_(get_next_touch_event_id()),
531 radius_x_(GetTouchRadiusX(native_event)), 533 radius_x_(GetTouchRadiusX(native_event)),
532 radius_y_(GetTouchRadiusY(native_event)), 534 radius_y_(GetTouchRadiusY(native_event)),
533 rotation_angle_(GetTouchAngle(native_event)), 535 rotation_angle_(GetTouchAngle(native_event)),
534 force_(GetTouchForce(native_event)), 536 force_(GetTouchForce(native_event)),
535 may_cause_scrolling_(false), 537 may_cause_scrolling_(false),
536 should_remove_native_touch_id_mapping_(false) { 538 should_remove_native_touch_id_mapping_(false) {
537 latency()->AddLatencyNumberWithTimestamp( 539 latency()->AddLatencyNumberWithTimestamp(
538 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, 540 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
539 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); 541 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
540 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 542 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
541 543
542 FixRotationAngle(); 544 FixRotationAngle();
543 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) 545 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
544 should_remove_native_touch_id_mapping_ = true; 546 should_remove_native_touch_id_mapping_ = true;
545 } 547 }
546 548
547 TouchEvent::TouchEvent(EventType type, 549 TouchEvent::TouchEvent(EventType type,
548 const gfx::PointF& location, 550 const gfx::PointF& location,
549 int touch_id, 551 int touch_id,
550 base::TimeDelta time_stamp) 552 base::TimeDelta time_stamp)
551 : LocatedEvent(type, location, location, time_stamp, 0), 553 : LocatedEvent(type, location, location, time_stamp, 0),
552 touch_id_(touch_id), 554 touch_id_(touch_id),
553 unique_event_id_(get_next_touch_event_id()), 555 unique_touch_event_id_(get_next_touch_event_id()),
554 radius_x_(0.0f), 556 radius_x_(0.0f),
555 radius_y_(0.0f), 557 radius_y_(0.0f),
556 rotation_angle_(0.0f), 558 rotation_angle_(0.0f),
557 force_(0.0f), 559 force_(0.0f),
558 may_cause_scrolling_(false), 560 may_cause_scrolling_(false),
559 should_remove_native_touch_id_mapping_(false) { 561 should_remove_native_touch_id_mapping_(false) {
560 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 562 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
561 } 563 }
562 564
563 TouchEvent::TouchEvent(EventType type, 565 TouchEvent::TouchEvent(EventType type,
564 const gfx::PointF& location, 566 const gfx::PointF& location,
565 int flags, 567 int flags,
566 int touch_id, 568 int touch_id,
567 base::TimeDelta time_stamp, 569 base::TimeDelta time_stamp,
568 float radius_x, 570 float radius_x,
569 float radius_y, 571 float radius_y,
570 float angle, 572 float angle,
571 float force) 573 float force)
572 : LocatedEvent(type, location, location, time_stamp, flags), 574 : LocatedEvent(type, location, location, time_stamp, flags),
573 touch_id_(touch_id), 575 touch_id_(touch_id),
574 unique_event_id_(get_next_touch_event_id()), 576 unique_touch_event_id_(get_next_touch_event_id()),
575 radius_x_(radius_x), 577 radius_x_(radius_x),
576 radius_y_(radius_y), 578 radius_y_(radius_y),
577 rotation_angle_(angle), 579 rotation_angle_(angle),
578 force_(force), 580 force_(force),
579 may_cause_scrolling_(false), 581 may_cause_scrolling_(false),
580 should_remove_native_touch_id_mapping_(false) { 582 should_remove_native_touch_id_mapping_(false) {
581 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 583 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
582 FixRotationAngle(); 584 FixRotationAngle();
583 } 585 }
584 586
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 gfx::PointF(x, y), 983 gfx::PointF(x, y),
982 time_stamp, 984 time_stamp,
983 flags | EF_FROM_TOUCH), 985 flags | EF_FROM_TOUCH),
984 details_(details) { 986 details_(details) {
985 } 987 }
986 988
987 GestureEvent::~GestureEvent() { 989 GestureEvent::~GestureEvent() {
988 } 990 }
989 991
990 } // namespace ui 992 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698