OLD | NEW |
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/base/event.h" | 5 #include "ui/base/event.h" |
6 | 6 |
7 #if defined(USE_X11) | 7 #if defined(USE_X11) |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 void LocatedEvent::UpdateForRootTransform(const Transform& root_transform) { | 118 void LocatedEvent::UpdateForRootTransform(const Transform& root_transform) { |
119 // Transform has to be done at root level. | 119 // Transform has to be done at root level. |
120 DCHECK_EQ(root_location_.x(), location_.x()); | 120 DCHECK_EQ(root_location_.x(), location_.x()); |
121 DCHECK_EQ(root_location_.y(), location_.y()); | 121 DCHECK_EQ(root_location_.y(), location_.y()); |
122 gfx::Point3f p(location_); | 122 gfx::Point3f p(location_); |
123 root_transform.TransformPointReverse(p); | 123 root_transform.TransformPointReverse(p); |
124 root_location_ = location_ = p.AsPoint(); | 124 root_location_ = location_ = p.AsPoint(); |
125 } | 125 } |
126 | 126 |
127 MouseEvent::MouseEvent(const base::NativeEvent& native_event) | 127 MouseEvent::MouseEvent(const base::NativeEvent& native_event) |
128 : LocatedEvent(native_event) { | 128 : LocatedEvent(native_event), |
| 129 changed_button_flags_( |
| 130 GetChangedMouseButtonFlagsFromNative(native_event)) { |
129 if (type() == ET_MOUSE_PRESSED) | 131 if (type() == ET_MOUSE_PRESSED) |
130 SetClickCount(GetRepeatCount(*this)); | 132 SetClickCount(GetRepeatCount(*this)); |
131 } | 133 } |
132 | 134 |
133 MouseEvent::MouseEvent(EventType type, | 135 MouseEvent::MouseEvent(EventType type, |
134 const gfx::Point& location, | 136 const gfx::Point& location, |
135 const gfx::Point& root_location, | 137 const gfx::Point& root_location, |
136 int flags) | 138 int flags) |
137 : LocatedEvent(type, location, root_location, flags) { | 139 : LocatedEvent(type, location, root_location, flags), |
| 140 changed_button_flags_(0) { |
138 } | 141 } |
139 | 142 |
140 // static | 143 // static |
141 bool MouseEvent::IsRepeatedClickEvent( | 144 bool MouseEvent::IsRepeatedClickEvent( |
142 const MouseEvent& event1, | 145 const MouseEvent& event1, |
143 const MouseEvent& event2) { | 146 const MouseEvent& event2) { |
144 // These values match the Windows defaults. | 147 // These values match the Windows defaults. |
145 static const int kDoubleClickTimeMS = 500; | 148 static const int kDoubleClickTimeMS = 500; |
146 static const int kDoubleClickWidth = 4; | 149 static const int kDoubleClickWidth = 4; |
147 static const int kDoubleClickHeight = 4; | 150 static const int kDoubleClickHeight = 4; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 int GestureEvent::GetLowestTouchId() const { | 398 int GestureEvent::GetLowestTouchId() const { |
396 if (touch_ids_bitfield_ == 0) | 399 if (touch_ids_bitfield_ == 0) |
397 return -1; | 400 return -1; |
398 int i = -1; | 401 int i = -1; |
399 // Find the index of the least significant 1 bit | 402 // Find the index of the least significant 1 bit |
400 while (!(1 << ++i & touch_ids_bitfield_)); | 403 while (!(1 << ++i & touch_ids_bitfield_)); |
401 return i; | 404 return i; |
402 } | 405 } |
403 | 406 |
404 } // namespace ui | 407 } // namespace ui |
OLD | NEW |