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

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, 8 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>
11 #endif 11 #endif
12 12
13 #include <cmath> 13 #include <cmath>
14 #include <cstring> 14 #include <cstring>
15 15
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "ui/events/base_event_utils.h"
18 #include "ui/events/event_utils.h" 19 #include "ui/events/event_utils.h"
19 #include "ui/events/keycodes/dom3/dom_code.h" 20 #include "ui/events/keycodes/dom3/dom_code.h"
20 #include "ui/events/keycodes/dom3/dom_key.h" 21 #include "ui/events/keycodes/dom3/dom_key.h"
21 #include "ui/events/keycodes/dom4/keycode_converter.h" 22 #include "ui/events/keycodes/dom4/keycode_converter.h"
22 #include "ui/events/keycodes/keyboard_code_conversion.h" 23 #include "ui/events/keycodes/keyboard_code_conversion.h"
23 #include "ui/gfx/geometry/point3_f.h" 24 #include "ui/gfx/geometry/point3_f.h"
24 #include "ui/gfx/geometry/point_conversions.h" 25 #include "ui/gfx/geometry/point_conversions.h"
25 #include "ui/gfx/geometry/safe_integer_conversions.h" 26 #include "ui/gfx/geometry/safe_integer_conversions.h"
26 #include "ui/gfx/transform.h" 27 #include "ui/gfx/transform.h"
27 #include "ui/gfx/transform_util.h" 28 #include "ui/gfx/transform_util.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 const unsigned int kAllStateMask = 104 const unsigned int kAllStateMask =
104 Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask | 105 Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask |
105 Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask | ShiftMask | 106 Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask | ShiftMask |
106 LockMask | ControlMask | AnyModifier; 107 LockMask | ControlMask | AnyModifier;
107 return event && (event->xkey.state & ~kAllStateMask) != 0; 108 return event && (event->xkey.state & ~kAllStateMask) != 0;
108 #else 109 #else
109 return false; 110 return false;
110 #endif 111 #endif
111 } 112 }
112 113
113 unsigned long long get_next_touch_event_id() {
114 static unsigned long long id = 0;
115 return id++;
116 }
117
118 } // namespace 114 } // namespace
119 115
120 namespace ui { 116 namespace ui {
121 117
122 //////////////////////////////////////////////////////////////////////////////// 118 ////////////////////////////////////////////////////////////////////////////////
123 // Event 119 // Event
124 120
125 // static 121 // static
126 scoped_ptr<Event> Event::Clone(const Event& event) { 122 scoped_ptr<Event> Event::Clone(const Event& event) {
127 if (event.IsKeyEvent()) { 123 if (event.IsKeyEvent()) {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // This value matches GTK+ wheel scroll amount. 508 // This value matches GTK+ wheel scroll amount.
513 const int MouseWheelEvent::kWheelDelta = 53; 509 const int MouseWheelEvent::kWheelDelta = 53;
514 #endif 510 #endif
515 511
516 //////////////////////////////////////////////////////////////////////////////// 512 ////////////////////////////////////////////////////////////////////////////////
517 // TouchEvent 513 // TouchEvent
518 514
519 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 515 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
520 : LocatedEvent(native_event), 516 : LocatedEvent(native_event),
521 touch_id_(GetTouchId(native_event)), 517 touch_id_(GetTouchId(native_event)),
522 unique_event_id_(get_next_touch_event_id()), 518 unique_event_id_(ui::GetNextTouchEventId()),
523 radius_x_(GetTouchRadiusX(native_event)), 519 radius_x_(GetTouchRadiusX(native_event)),
524 radius_y_(GetTouchRadiusY(native_event)), 520 radius_y_(GetTouchRadiusY(native_event)),
525 rotation_angle_(GetTouchAngle(native_event)), 521 rotation_angle_(GetTouchAngle(native_event)),
526 force_(GetTouchForce(native_event)), 522 force_(GetTouchForce(native_event)),
527 may_cause_scrolling_(false), 523 may_cause_scrolling_(false),
528 should_remove_native_touch_id_mapping_(false) { 524 should_remove_native_touch_id_mapping_(false) {
529 latency()->AddLatencyNumberWithTimestamp( 525 latency()->AddLatencyNumberWithTimestamp(
530 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, 526 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
531 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); 527 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
532 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 528 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
533 529
534 FixRotationAngle(); 530 FixRotationAngle();
535 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) 531 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
536 should_remove_native_touch_id_mapping_ = true; 532 should_remove_native_touch_id_mapping_ = true;
537 } 533 }
538 534
539 TouchEvent::TouchEvent(EventType type, 535 TouchEvent::TouchEvent(EventType type,
540 const gfx::PointF& location, 536 const gfx::PointF& location,
541 int touch_id, 537 int touch_id,
542 base::TimeDelta time_stamp) 538 base::TimeDelta time_stamp)
543 : LocatedEvent(type, location, location, time_stamp, 0), 539 : LocatedEvent(type, location, location, time_stamp, 0),
544 touch_id_(touch_id), 540 touch_id_(touch_id),
545 unique_event_id_(get_next_touch_event_id()), 541 unique_event_id_(ui::GetNextTouchEventId()),
546 radius_x_(0.0f), 542 radius_x_(0.0f),
547 radius_y_(0.0f), 543 radius_y_(0.0f),
548 rotation_angle_(0.0f), 544 rotation_angle_(0.0f),
549 force_(0.0f), 545 force_(0.0f),
550 may_cause_scrolling_(false), 546 may_cause_scrolling_(false),
551 should_remove_native_touch_id_mapping_(false) { 547 should_remove_native_touch_id_mapping_(false) {
552 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 548 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
553 } 549 }
554 550
555 TouchEvent::TouchEvent(EventType type, 551 TouchEvent::TouchEvent(EventType type,
556 const gfx::PointF& location, 552 const gfx::PointF& location,
557 int flags, 553 int flags,
558 int touch_id, 554 int touch_id,
559 base::TimeDelta time_stamp, 555 base::TimeDelta time_stamp,
560 float radius_x, 556 float radius_x,
561 float radius_y, 557 float radius_y,
562 float angle, 558 float angle,
563 float force) 559 float force)
564 : LocatedEvent(type, location, location, time_stamp, flags), 560 : LocatedEvent(type, location, location, time_stamp, flags),
565 touch_id_(touch_id), 561 touch_id_(touch_id),
566 unique_event_id_(get_next_touch_event_id()), 562 unique_event_id_(ui::GetNextTouchEventId()),
567 radius_x_(radius_x), 563 radius_x_(radius_x),
568 radius_y_(radius_y), 564 radius_y_(radius_y),
569 rotation_angle_(angle), 565 rotation_angle_(angle),
570 force_(force), 566 force_(force),
571 may_cause_scrolling_(false), 567 may_cause_scrolling_(false),
572 should_remove_native_touch_id_mapping_(false) { 568 should_remove_native_touch_id_mapping_(false) {
573 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 569 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
574 FixRotationAngle(); 570 FixRotationAngle();
575 } 571 }
576 572
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 gfx::PointF(x, y), 1005 gfx::PointF(x, y),
1010 time_stamp, 1006 time_stamp,
1011 flags | EF_FROM_TOUCH), 1007 flags | EF_FROM_TOUCH),
1012 details_(details) { 1008 details_(details) {
1013 } 1009 }
1014 1010
1015 GestureEvent::~GestureEvent() { 1011 GestureEvent::~GestureEvent() {
1016 } 1012 }
1017 1013
1018 } // namespace ui 1014 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698