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

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: Motion events 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 const unsigned int kAllStateMask = 103 const unsigned int kAllStateMask =
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 uint64 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 uint64 id = 1;
117 if (id==0)
118 id++;
119 DCHECK_NE(id, 0UL);
115 return id++; 120 return id++;
116 } 121 }
117 122
118 } // namespace 123 } // namespace
119 124
120 namespace ui { 125 namespace ui {
121 126
122 //////////////////////////////////////////////////////////////////////////////// 127 ////////////////////////////////////////////////////////////////////////////////
123 // Event 128 // Event
124 129
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 gfx::ToRoundedInt(SkMScalarToFloat(offset_.y() * decomp.scale[1]))); 525 gfx::ToRoundedInt(SkMScalarToFloat(offset_.y() * decomp.scale[1])));
521 } 526 }
522 } 527 }
523 528
524 //////////////////////////////////////////////////////////////////////////////// 529 ////////////////////////////////////////////////////////////////////////////////
525 // TouchEvent 530 // TouchEvent
526 531
527 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 532 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
528 : LocatedEvent(native_event), 533 : LocatedEvent(native_event),
529 touch_id_(GetTouchId(native_event)), 534 touch_id_(GetTouchId(native_event)),
530 unique_event_id_(get_next_touch_event_id()), 535 unique_touch_event_id_(get_next_touch_event_id()),
531 radius_x_(GetTouchRadiusX(native_event)), 536 radius_x_(GetTouchRadiusX(native_event)),
532 radius_y_(GetTouchRadiusY(native_event)), 537 radius_y_(GetTouchRadiusY(native_event)),
533 rotation_angle_(GetTouchAngle(native_event)), 538 rotation_angle_(GetTouchAngle(native_event)),
534 force_(GetTouchForce(native_event)), 539 force_(GetTouchForce(native_event)),
535 may_cause_scrolling_(false), 540 may_cause_scrolling_(false),
536 should_remove_native_touch_id_mapping_(false) { 541 should_remove_native_touch_id_mapping_(false) {
537 latency()->AddLatencyNumberWithTimestamp( 542 latency()->AddLatencyNumberWithTimestamp(
538 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, 543 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
539 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); 544 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
540 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 545 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
541 546
542 FixRotationAngle(); 547 FixRotationAngle();
543 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) 548 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
544 should_remove_native_touch_id_mapping_ = true; 549 should_remove_native_touch_id_mapping_ = true;
545 } 550 }
546 551
547 TouchEvent::TouchEvent(EventType type, 552 TouchEvent::TouchEvent(EventType type,
548 const gfx::PointF& location, 553 const gfx::PointF& location,
549 int touch_id, 554 int touch_id,
550 base::TimeDelta time_stamp) 555 base::TimeDelta time_stamp)
551 : LocatedEvent(type, location, location, time_stamp, 0), 556 : LocatedEvent(type, location, location, time_stamp, 0),
552 touch_id_(touch_id), 557 touch_id_(touch_id),
553 unique_event_id_(get_next_touch_event_id()), 558 unique_touch_event_id_(get_next_touch_event_id()),
554 radius_x_(0.0f), 559 radius_x_(0.0f),
555 radius_y_(0.0f), 560 radius_y_(0.0f),
556 rotation_angle_(0.0f), 561 rotation_angle_(0.0f),
557 force_(0.0f), 562 force_(0.0f),
558 may_cause_scrolling_(false), 563 may_cause_scrolling_(false),
559 should_remove_native_touch_id_mapping_(false) { 564 should_remove_native_touch_id_mapping_(false) {
560 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 565 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
561 } 566 }
562 567
563 TouchEvent::TouchEvent(EventType type, 568 TouchEvent::TouchEvent(EventType type,
564 const gfx::PointF& location, 569 const gfx::PointF& location,
565 int flags, 570 int flags,
566 int touch_id, 571 int touch_id,
567 base::TimeDelta time_stamp, 572 base::TimeDelta time_stamp,
568 float radius_x, 573 float radius_x,
569 float radius_y, 574 float radius_y,
570 float angle, 575 float angle,
571 float force) 576 float force)
572 : LocatedEvent(type, location, location, time_stamp, flags), 577 : LocatedEvent(type, location, location, time_stamp, flags),
573 touch_id_(touch_id), 578 touch_id_(touch_id),
574 unique_event_id_(get_next_touch_event_id()), 579 unique_touch_event_id_(get_next_touch_event_id()),
575 radius_x_(radius_x), 580 radius_x_(radius_x),
576 radius_y_(radius_y), 581 radius_y_(radius_y),
577 rotation_angle_(angle), 582 rotation_angle_(angle),
578 force_(force), 583 force_(force),
579 may_cause_scrolling_(false), 584 may_cause_scrolling_(false),
580 should_remove_native_touch_id_mapping_(false) { 585 should_remove_native_touch_id_mapping_(false) {
581 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 586 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
582 FixRotationAngle(); 587 FixRotationAngle();
583 } 588 }
584 589
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 gfx::PointF(x, y), 986 gfx::PointF(x, y),
982 time_stamp, 987 time_stamp,
983 flags | EF_FROM_TOUCH), 988 flags | EF_FROM_TOUCH),
984 details_(details) { 989 details_(details) {
985 } 990 }
986 991
987 GestureEvent::~GestureEvent() { 992 GestureEvent::~GestureEvent() {
988 } 993 }
989 994
990 } // namespace ui 995 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698