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

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, 7 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/blink/blink_event_util.cc ('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>
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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 // This value matches GTK+ wheel scroll amount. 504 // This value matches GTK+ wheel scroll amount.
509 const int MouseWheelEvent::kWheelDelta = 53; 505 const int MouseWheelEvent::kWheelDelta = 53;
510 #endif 506 #endif
511 507
512 //////////////////////////////////////////////////////////////////////////////// 508 ////////////////////////////////////////////////////////////////////////////////
513 // TouchEvent 509 // TouchEvent
514 510
515 TouchEvent::TouchEvent(const base::NativeEvent& native_event) 511 TouchEvent::TouchEvent(const base::NativeEvent& native_event)
516 : LocatedEvent(native_event), 512 : LocatedEvent(native_event),
517 touch_id_(GetTouchId(native_event)), 513 touch_id_(GetTouchId(native_event)),
518 unique_event_id_(get_next_touch_event_id()), 514 unique_event_id_(ui::GetNextTouchEventId()),
519 radius_x_(GetTouchRadiusX(native_event)), 515 radius_x_(GetTouchRadiusX(native_event)),
520 radius_y_(GetTouchRadiusY(native_event)), 516 radius_y_(GetTouchRadiusY(native_event)),
521 rotation_angle_(GetTouchAngle(native_event)), 517 rotation_angle_(GetTouchAngle(native_event)),
522 force_(GetTouchForce(native_event)), 518 force_(GetTouchForce(native_event)),
523 may_cause_scrolling_(false), 519 may_cause_scrolling_(false),
524 should_remove_native_touch_id_mapping_(false) { 520 should_remove_native_touch_id_mapping_(false) {
525 latency()->AddLatencyNumberWithTimestamp( 521 latency()->AddLatencyNumberWithTimestamp(
526 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, 522 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
527 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1); 523 base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
528 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 524 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
529 525
530 FixRotationAngle(); 526 FixRotationAngle();
531 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED) 527 if (type() == ET_TOUCH_RELEASED || type() == ET_TOUCH_CANCELLED)
532 should_remove_native_touch_id_mapping_ = true; 528 should_remove_native_touch_id_mapping_ = true;
533 } 529 }
534 530
535 TouchEvent::TouchEvent(EventType type, 531 TouchEvent::TouchEvent(EventType type,
536 const gfx::PointF& location, 532 const gfx::PointF& location,
537 int touch_id, 533 int touch_id,
538 base::TimeDelta time_stamp) 534 base::TimeDelta time_stamp)
539 : LocatedEvent(type, location, location, time_stamp, 0), 535 : LocatedEvent(type, location, location, time_stamp, 0),
540 touch_id_(touch_id), 536 touch_id_(touch_id),
541 unique_event_id_(get_next_touch_event_id()), 537 unique_event_id_(ui::GetNextTouchEventId()),
542 radius_x_(0.0f), 538 radius_x_(0.0f),
543 radius_y_(0.0f), 539 radius_y_(0.0f),
544 rotation_angle_(0.0f), 540 rotation_angle_(0.0f),
545 force_(0.0f), 541 force_(0.0f),
546 may_cause_scrolling_(false), 542 may_cause_scrolling_(false),
547 should_remove_native_touch_id_mapping_(false) { 543 should_remove_native_touch_id_mapping_(false) {
548 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 544 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
549 } 545 }
550 546
551 TouchEvent::TouchEvent(EventType type, 547 TouchEvent::TouchEvent(EventType type,
552 const gfx::PointF& location, 548 const gfx::PointF& location,
553 int flags, 549 int flags,
554 int touch_id, 550 int touch_id,
555 base::TimeDelta time_stamp, 551 base::TimeDelta time_stamp,
556 float radius_x, 552 float radius_x,
557 float radius_y, 553 float radius_y,
558 float angle, 554 float angle,
559 float force) 555 float force)
560 : LocatedEvent(type, location, location, time_stamp, flags), 556 : LocatedEvent(type, location, location, time_stamp, flags),
561 touch_id_(touch_id), 557 touch_id_(touch_id),
562 unique_event_id_(get_next_touch_event_id()), 558 unique_event_id_(ui::GetNextTouchEventId()),
563 radius_x_(radius_x), 559 radius_x_(radius_x),
564 radius_y_(radius_y), 560 radius_y_(radius_y),
565 rotation_angle_(angle), 561 rotation_angle_(angle),
566 force_(force), 562 force_(force),
567 may_cause_scrolling_(false), 563 may_cause_scrolling_(false),
568 should_remove_native_touch_id_mapping_(false) { 564 should_remove_native_touch_id_mapping_(false) {
569 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 565 latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
570 FixRotationAngle(); 566 FixRotationAngle();
571 } 567 }
572 568
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 gfx::PointF(x, y), 1001 gfx::PointF(x, y),
1006 time_stamp, 1002 time_stamp,
1007 flags | EF_FROM_TOUCH), 1003 flags | EF_FROM_TOUCH),
1008 details_(details) { 1004 details_(details) {
1009 } 1005 }
1010 1006
1011 GestureEvent::~GestureEvent() { 1007 GestureEvent::~GestureEvent() {
1012 } 1008 }
1013 1009
1014 } // namespace ui 1010 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/blink/blink_event_util.cc ('k') | ui/events/event_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698