Chromium Code Reviews| 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/views/events/event.h" | 5 #include "ui/views/events/event.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/base/keycodes/keyboard_code_conversion.h" | 8 #include "ui/base/keycodes/keyboard_code_conversion.h" |
| 9 #include "ui/views/view.h" | 9 #include "ui/views/view.h" |
| 10 #include "ui/views/widget/root_view.h" | 10 #include "ui/views/widget/root_view.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 // This value matches windows WHEEL_DELTA. | 225 // This value matches windows WHEEL_DELTA. |
| 226 // static | 226 // static |
| 227 const int MouseWheelEvent::kWheelDelta = 120; | 227 const int MouseWheelEvent::kWheelDelta = 120; |
| 228 #else | 228 #else |
| 229 // This value matches GTK+ wheel scroll amount. | 229 // This value matches GTK+ wheel scroll amount. |
| 230 const int MouseWheelEvent::kWheelDelta = 53; | 230 const int MouseWheelEvent::kWheelDelta = 53; |
| 231 #endif | 231 #endif |
| 232 | 232 |
| 233 //////////////////////////////////////////////////////////////////////////////// | 233 //////////////////////////////////////////////////////////////////////////////// |
| 234 // GestureEvent, public: | 234 // GestureEvent, public: |
| 235 GestureEvent::GestureEvent(ui::EventType type, | |
| 236 int x, | |
| 237 int y, | |
| 238 int flags, | |
| 239 base::Time time_stamp, | |
| 240 float delta_x, | |
| 241 float delta_y, | |
| 242 unsigned int touch_ids_bitfield) | |
| 243 : LocatedEvent(type, gfx::Point(x, y), flags), | |
| 244 delta_x_(delta_x), | |
| 245 delta_y_(delta_y), | |
| 246 touch_ids_bitfield_(touch_ids_bitfield) { | |
| 247 set_time_stamp(time_stamp); | |
| 248 } | |
| 235 | 249 |
| 236 GestureEvent::GestureEvent(const GestureEvent& model, View* source, | 250 GestureEvent::GestureEvent(const GestureEvent& model, View* source, |
| 237 View* target) | 251 View* target) |
| 238 : LocatedEvent(model, source, target), | 252 : LocatedEvent(model, source, target), |
| 239 delta_x_(model.delta_x_), | 253 delta_x_(model.delta_x_), |
| 240 delta_y_(model.delta_y_) { | 254 delta_y_(model.delta_y_), |
| 255 touch_ids_bitfield_(model.touch_ids_bitfield_) { | |
| 241 } | 256 } |
| 242 | 257 |
| 243 //////////////////////////////////////////////////////////////////////////////// | 258 //////////////////////////////////////////////////////////////////////////////// |
| 244 // GestureEvent, private: | 259 // GestureEvent, private: |
| 245 | 260 |
| 246 GestureEvent::GestureEvent(const GestureEvent& model, View* root) | 261 GestureEvent::GestureEvent(const GestureEvent& model, View* root) |
| 247 : LocatedEvent(model, root), | 262 : LocatedEvent(model, root), |
| 248 delta_x_(model.delta_x_), | 263 delta_x_(model.delta_x_), |
| 249 delta_y_(model.delta_y_) { | 264 delta_y_(model.delta_y_), |
| 265 touch_ids_bitfield_(0) { | |
| 250 } | 266 } |
| 251 | 267 |
| 252 GestureEvent::GestureEvent(ui::EventType type, int x, int y, int flags) | 268 GestureEvent::GestureEvent(ui::EventType type, int x, int y, int flags) |
| 253 : LocatedEvent(type, gfx::Point(x, y), flags), | 269 : LocatedEvent(type, gfx::Point(x, y), flags), |
| 254 delta_x_(0), | 270 delta_x_(0), |
| 255 delta_y_(0) { | 271 delta_y_(0), |
| 272 touch_ids_bitfield_(0) { | |
| 256 } | 273 } |
| 257 | 274 |
| 258 GestureEvent::~GestureEvent() { | 275 GestureEvent::~GestureEvent() { |
| 259 } | 276 } |
| 260 | 277 |
| 261 #if !defined(USE_AURA) | |
| 262 int GestureEvent::GetLowestTouchId() const { | 278 int GestureEvent::GetLowestTouchId() const { |
| 263 // TODO: | 279 if (touch_ids_bitfield_ == 0) |
| 264 return 0; | 280 return -1; |
| 281 int i = -1; | |
| 282 // Find the index of the least significant 1 bit | |
| 283 while (!(1 << ++i & touch_ids_bitfield_)); | |
|
sky
2012/05/03 22:39:19
nit: params around (1 << ++i)
| |
| 284 return i; | |
| 265 } | 285 } |
| 266 #endif | |
| 267 | 286 |
| 268 GestureEventForTest::GestureEventForTest(ui::EventType type, | 287 GestureEventForTest::GestureEventForTest(ui::EventType type, |
| 269 int x, | 288 int x, |
| 270 int y, | 289 int y, |
| 271 int flags) | 290 int flags) |
| 272 : GestureEvent(type, x, y, flags) { | 291 : GestureEvent(type, x, y, flags) { |
| 273 } | 292 } |
| 274 | 293 |
| 275 } // namespace views | 294 } // namespace views |
| OLD | NEW |