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

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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // This value matches GTK+ wheel scroll amount. 500 // This value matches GTK+ wheel scroll amount.
505 const int MouseWheelEvent::kWheelDelta = 53; 501 const int MouseWheelEvent::kWheelDelta = 53;
506 #endif 502 #endif
507 503
508 //////////////////////////////////////////////////////////////////////////////// 504 ////////////////////////////////////////////////////////////////////////////////
509 // TouchEvent 505 // TouchEvent
510 506
511 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 507 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
512 : LocatedEvent(native_event), 508 : LocatedEvent(native_event),
513 touch_id_(GetTouchId(native_event)), 509 touch_id_(GetTouchId(native_event)),
514 unique_event_id_(get_next_touch_event_id()), 510 unique_event_id_(ui::GetNextTouchEventId()),
515 radius_x_(GetTouchRadiusX(native_event)), 511 radius_x_(GetTouchRadiusX(native_event)),
516 radius_y_(GetTouchRadiusY(native_event)), 512 radius_y_(GetTouchRadiusY(native_event)),
517 rotation_angle_(GetTouchAngle(native_event)), 513 rotation_angle_(GetTouchAngle(native_event)),
518 force_(GetTouchForce(native_event)), 514 force_(GetTouchForce(native_event)),
519 may_cause_scrolling_(false), 515 may_cause_scrolling_(false),
520 should_remove_native_touch_id_mapping_(false) { 516 should_remove_native_touch_id_mapping_(false) {
521 latency()->AddLatencyNumberWithTimestamp( 517 latency()->AddLatencyNumberWithTimestamp(
522 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, 518 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
523 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); 519 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
524 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 520 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
525 521
526 FixRotationAngle(); 522 FixRotationAngle();
527 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) 523 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
528 should_remove_native_touch_id_mapping_ = true; 524 should_remove_native_touch_id_mapping_ = true;
529 } 525 }
530 526
531 TouchEvent::TouchEvent(EventType type, 527 TouchEvent::TouchEvent(EventType type,
532 const gfx::PointF& location, 528 const gfx::PointF& location,
533 int touch_id, 529 int touch_id,
534 base::TimeDelta time_stamp) 530 base::TimeDelta time_stamp)
535 : LocatedEvent(type, location, location, time_stamp, 0), 531 : LocatedEvent(type, location, location, time_stamp, 0),
536 touch_id_(touch_id), 532 touch_id_(touch_id),
537 unique_event_id_(get_next_touch_event_id()), 533 unique_event_id_(ui::GetNextTouchEventId()),
538 radius_x_(0.0f), 534 radius_x_(0.0f),
539 radius_y_(0.0f), 535 radius_y_(0.0f),
540 rotation_angle_(0.0f), 536 rotation_angle_(0.0f),
541 force_(0.0f), 537 force_(0.0f),
542 may_cause_scrolling_(false), 538 may_cause_scrolling_(false),
543 should_remove_native_touch_id_mapping_(false) { 539 should_remove_native_touch_id_mapping_(false) {
544 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 540 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
545 } 541 }
546 542
547 TouchEvent::TouchEvent(EventType type, 543 TouchEvent::TouchEvent(EventType type,
548 const gfx::PointF& location, 544 const gfx::PointF& location,
549 int flags, 545 int flags,
550 int touch_id, 546 int touch_id,
551 base::TimeDelta time_stamp, 547 base::TimeDelta time_stamp,
552 float radius_x, 548 float radius_x,
553 float radius_y, 549 float radius_y,
554 float angle, 550 float angle,
555 float force) 551 float force)
556 : LocatedEvent(type, location, location, time_stamp, flags), 552 : LocatedEvent(type, location, location, time_stamp, flags),
557 touch_id_(touch_id), 553 touch_id_(touch_id),
558 unique_event_id_(get_next_touch_event_id()), 554 unique_event_id_(ui::GetNextTouchEventId()),
559 radius_x_(radius_x), 555 radius_x_(radius_x),
560 radius_y_(radius_y), 556 radius_y_(radius_y),
561 rotation_angle_(angle), 557 rotation_angle_(angle),
562 force_(force), 558 force_(force),
563 may_cause_scrolling_(false), 559 may_cause_scrolling_(false),
564 should_remove_native_touch_id_mapping_(false) { 560 should_remove_native_touch_id_mapping_(false) {
565 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 561 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
566 FixRotationAngle(); 562 FixRotationAngle();
567 } 563 }
568 564
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 gfx::PointF(x, y), 980 gfx::PointF(x, y),
985 time_stamp, 981 time_stamp,
986 flags | EF_FROM_TOUCH), 982 flags | EF_FROM_TOUCH),
987 details_(details) { 983 details_(details) {
988 } 984 }
989 985
990 GestureEvent::~GestureEvent() { 986 GestureEvent::~GestureEvent() {
991 } 987 }
992 988
993 } // namespace ui 989 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698