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

Side by Side Diff: ui/events/android/motion_event_android.cc

Issue 2896993002: Route OnDragEvent through ViewAndroid tree (Closed)
Patch Set: +ui/base Created 3 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/android/motion_event_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/android/motion_event_android.h" 5 #include "ui/events/android/motion_event_android.h"
6 6
7 #include <android/input.h> 7 #include <android/input.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 cached_action_button_(e.cached_action_button_), 254 cached_action_button_(e.cached_action_button_),
255 cached_button_state_(e.cached_button_state_), 255 cached_button_state_(e.cached_button_state_),
256 cached_flags_(e.cached_flags_), 256 cached_flags_(e.cached_flags_),
257 cached_raw_position_offset_(e.cached_raw_position_offset_), 257 cached_raw_position_offset_(e.cached_raw_position_offset_),
258 unique_event_id_(ui::GetNextTouchEventId()) { 258 unique_event_id_(ui::GetNextTouchEventId()) {
259 cached_pointers_[0] = e.cached_pointers_[0]; 259 cached_pointers_[0] = e.cached_pointers_[0];
260 if (cached_pointer_count_ > 1) 260 if (cached_pointer_count_ > 1)
261 cached_pointers_[1] = e.cached_pointers_[1]; 261 cached_pointers_[1] = e.cached_pointers_[1];
262 } 262 }
263 263
264 std::unique_ptr<MotionEventAndroid> MotionEventAndroid::Offset(float x, 264 std::unique_ptr<MotionEventAndroid> MotionEventAndroid::CreateFor(
265 float y) const { 265 const gfx::PointF& point) const {
266 std::unique_ptr<MotionEventAndroid> event(new MotionEventAndroid(*this)); 266 std::unique_ptr<MotionEventAndroid> event(new MotionEventAndroid(*this));
267 event->cached_pointers_[0] = OffsetCachedPointer(cached_pointers_[0], x, y); 267 if (cached_pointer_count_ > 1) {
268 if (cached_pointer_count_ > 1) 268 gfx::Vector2dF diff = event->cached_pointers_[1].position -
269 event->cached_pointers_[1] = OffsetCachedPointer(cached_pointers_[1], x, y); 269 event->cached_pointers_[0].position;
270 event->cached_pointers_[1] =
271 CreateCachedPointer(cached_pointers_[1], point + diff);
272 }
273 event->cached_pointers_[0] = CreateCachedPointer(cached_pointers_[0], point);
270 return event; 274 return event;
271 } 275 }
272 276
273 MotionEventAndroid::~MotionEventAndroid() { 277 MotionEventAndroid::~MotionEventAndroid() {
274 } 278 }
275 279
276 uint32_t MotionEventAndroid::GetUniqueEventId() const { 280 uint32_t MotionEventAndroid::GetUniqueEventId() const {
277 return unique_event_id_; 281 return unique_event_id_;
278 } 282 }
279 283
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 result.touch_major = ToDips(pointer.touch_major_pixels); 472 result.touch_major = ToDips(pointer.touch_major_pixels);
469 result.touch_minor = ToDips(pointer.touch_minor_pixels); 473 result.touch_minor = ToDips(pointer.touch_minor_pixels);
470 result.orientation = ToValidFloat(pointer.orientation_rad); 474 result.orientation = ToValidFloat(pointer.orientation_rad);
471 float tilt_rad = ToValidFloat(pointer.tilt_rad); 475 float tilt_rad = ToValidFloat(pointer.tilt_rad);
472 ConvertTiltOrientationToTiltXY(tilt_rad, result.orientation, &result.tilt_x, 476 ConvertTiltOrientationToTiltXY(tilt_rad, result.orientation, &result.tilt_x,
473 &result.tilt_y); 477 &result.tilt_y);
474 result.tool_type = FromAndroidToolType(pointer.tool_type); 478 result.tool_type = FromAndroidToolType(pointer.tool_type);
475 return result; 479 return result;
476 } 480 }
477 481
478 MotionEventAndroid::CachedPointer MotionEventAndroid::OffsetCachedPointer( 482 MotionEventAndroid::CachedPointer MotionEventAndroid::CreateCachedPointer(
479 const CachedPointer& pointer, 483 const CachedPointer& pointer,
480 float x, 484 const gfx::PointF& point) const {
481 float y) const {
482 CachedPointer result; 485 CachedPointer result;
483 result.id = pointer.id; 486 result.id = pointer.id;
484 result.position = gfx::PointF(pointer.position.x() + ToDips(x), 487 result.position = point;
485 pointer.position.y() + ToDips(y));
486 result.touch_major = pointer.touch_major; 488 result.touch_major = pointer.touch_major;
487 result.touch_minor = pointer.touch_minor; 489 result.touch_minor = pointer.touch_minor;
488 result.orientation = pointer.orientation; 490 result.orientation = pointer.orientation;
489 result.tilt_x = pointer.tilt_x; 491 result.tilt_x = pointer.tilt_x;
490 result.tilt_y = pointer.tilt_y; 492 result.tilt_y = pointer.tilt_y;
491 result.tool_type = pointer.tool_type; 493 result.tool_type = pointer.tool_type;
492 return result; 494 return result;
493 } 495 }
494 496
495 } // namespace ui 497 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/android/motion_event_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698