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

Side by Side Diff: ui/base/event.cc

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/event.h ('k') | ui/gfx/native_widget_types.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/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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 LocatedEvent::LocatedEvent(EventType type, 100 LocatedEvent::LocatedEvent(EventType type,
101 const gfx::Point& location, 101 const gfx::Point& location,
102 const gfx::Point& root_location, 102 const gfx::Point& root_location,
103 int flags) 103 int flags)
104 : Event(type, flags), 104 : Event(type, flags),
105 location_(location), 105 location_(location),
106 root_location_(root_location) { 106 root_location_(root_location) {
107 } 107 }
108 108
109 LocatedEvent::LocatedEvent(const LocatedEvent& model)
110 : Event(model),
111 location_(model.location_),
112 root_location_(model.root_location_) {
113 }
114
109 void LocatedEvent::UpdateForRootTransform(const Transform& root_transform) { 115 void LocatedEvent::UpdateForRootTransform(const Transform& root_transform) {
110 // Transform has to be done at root level. 116 // Transform has to be done at root level.
111 DCHECK_EQ(root_location_.x(), location_.x()); 117 DCHECK_EQ(root_location_.x(), location_.x());
112 DCHECK_EQ(root_location_.y(), location_.y()); 118 DCHECK_EQ(root_location_.y(), location_.y());
113 gfx::Point3f p(location_); 119 gfx::Point3f p(location_);
114 root_transform.TransformPointReverse(p); 120 root_transform.TransformPointReverse(p);
115 root_location_ = location_ = p.AsPoint(); 121 root_location_ = location_ = p.AsPoint();
116 } 122 }
117 123
118 MouseEvent::MouseEvent(const base::NativeEvent& native_event) 124 MouseEvent::MouseEvent(const base::NativeEvent& native_event)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 167 }
162 168
163 // static 169 // static
164 int MouseEvent::GetRepeatCount(const MouseEvent& event) { 170 int MouseEvent::GetRepeatCount(const MouseEvent& event) {
165 int click_count = 1; 171 int click_count = 1;
166 if (last_click_event_) { 172 if (last_click_event_) {
167 if (IsRepeatedClickEvent(*last_click_event_, event)) 173 if (IsRepeatedClickEvent(*last_click_event_, event))
168 click_count = last_click_event_->GetClickCount() + 1; 174 click_count = last_click_event_->GetClickCount() + 1;
169 delete last_click_event_; 175 delete last_click_event_;
170 } 176 }
171 last_click_event_ = new MouseEvent(event.native_event()); 177 last_click_event_ = new MouseEvent(event);
172 if (click_count > 3) 178 if (click_count > 3)
173 click_count = 3; 179 click_count = 3;
174 last_click_event_->SetClickCount(click_count); 180 last_click_event_->SetClickCount(click_count);
175 return click_count; 181 return click_count;
176 } 182 }
177 183
178 // static 184 // static
179 MouseEvent* MouseEvent::last_click_event_ = NULL; 185 MouseEvent* MouseEvent::last_click_event_ = NULL;
180 186
181 int MouseEvent::GetClickCount() const { 187 int MouseEvent::GetClickCount() const {
(...skipping 26 matching lines...) Expand all
208 f &= ~EF_IS_TRIPLE_CLICK; 214 f &= ~EF_IS_TRIPLE_CLICK;
209 break; 215 break;
210 case 3: 216 case 3:
211 f &= ~EF_IS_DOUBLE_CLICK; 217 f &= ~EF_IS_DOUBLE_CLICK;
212 f |= EF_IS_TRIPLE_CLICK; 218 f |= EF_IS_TRIPLE_CLICK;
213 break; 219 break;
214 } 220 }
215 set_flags(f); 221 set_flags(f);
216 } 222 }
217 223
224 MouseEvent::MouseEvent(const MouseEvent& model) : LocatedEvent(model) {
225 }
226
218 TouchEventImpl::TouchEventImpl(const base::NativeEvent& native_event) 227 TouchEventImpl::TouchEventImpl(const base::NativeEvent& native_event)
219 : LocatedEvent(native_event), 228 : LocatedEvent(native_event),
220 touch_id_(ui::GetTouchId(native_event)), 229 touch_id_(ui::GetTouchId(native_event)),
221 radius_x_(GetTouchRadiusX(native_event)), 230 radius_x_(GetTouchRadiusX(native_event)),
222 radius_y_(GetTouchRadiusY(native_event)), 231 radius_y_(GetTouchRadiusY(native_event)),
223 rotation_angle_(GetTouchAngle(native_event)), 232 rotation_angle_(GetTouchAngle(native_event)),
224 force_(GetTouchForce(native_event)) { 233 force_(GetTouchForce(native_event)) {
225 } 234 }
226 235
227 TouchEventImpl::TouchEventImpl(EventType type, 236 TouchEventImpl::TouchEventImpl(EventType type,
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 int GestureEventImpl::GetLowestTouchId() const { 428 int GestureEventImpl::GetLowestTouchId() const {
420 if (touch_ids_bitfield_ == 0) 429 if (touch_ids_bitfield_ == 0)
421 return -1; 430 return -1;
422 int i = -1; 431 int i = -1;
423 // Find the index of the least significant 1 bit 432 // Find the index of the least significant 1 bit
424 while (!(1 << ++i & touch_ids_bitfield_)); 433 while (!(1 << ++i & touch_ids_bitfield_));
425 return i; 434 return i;
426 } 435 }
427 436
428 } // namespace ui 437 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/event.h ('k') | ui/gfx/native_widget_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698