OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/view_manager/gesture_manager.h" | 5 #include "components/view_manager/gesture_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "components/view_manager/gesture_manager_delegate.h" | 9 #include "components/view_manager/gesture_manager_delegate.h" |
10 #include "components/view_manager/public/cpp/keys.h" | 10 #include "components/view_manager/public/cpp/keys.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // TODO(sky): I'm doing this until things are converted. Seems as though we | 48 // TODO(sky): I'm doing this until things are converted. Seems as though we |
49 // shouldn't do this long term. | 49 // shouldn't do this long term. |
50 if (result.empty()) | 50 if (result.empty()) |
51 result.push_back(deepest); | 51 result.push_back(deepest); |
52 return result; | 52 return result; |
53 } | 53 } |
54 | 54 |
55 mojo::EventPtr CloneEventForView(const mojo::Event& event, | 55 mojo::EventPtr CloneEventForView(const mojo::Event& event, |
56 const ServerView* view) { | 56 const ServerView* view) { |
57 mojo::EventPtr result(event.Clone()); | 57 mojo::EventPtr result(event.Clone()); |
58 const gfx::PointF location(event.pointer_data->x, event.pointer_data->y); | 58 const gfx::PointF location(event.pointer_data->where->x, |
| 59 event.pointer_data->where->y); |
59 const gfx::PointF target_location( | 60 const gfx::PointF target_location( |
60 ConvertPointFBetweenViews(view->GetRoot(), view, location)); | 61 ConvertPointFBetweenViews(view->GetRoot(), view, location)); |
61 result->pointer_data->x = target_location.x(); | 62 result->pointer_data->where->x = target_location.x(); |
62 result->pointer_data->y = target_location.y(); | 63 result->pointer_data->where->y = target_location.y(); |
63 return result.Pass(); | 64 return result.Pass(); |
64 } | 65 } |
65 | 66 |
66 } // namespace | 67 } // namespace |
67 | 68 |
68 // GestureStateChange ---------------------------------------------------------- | 69 // GestureStateChange ---------------------------------------------------------- |
69 | 70 |
70 GestureStateChange::GestureStateChange() | 71 GestureStateChange::GestureStateChange() |
71 : chosen_gesture(GestureManager::kInvalidGestureId) { | 72 : chosen_gesture(GestureManager::kInvalidGestureId) { |
72 } | 73 } |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 // Explicitly delete the pointers first as this may result in calling back to | 538 // Explicitly delete the pointers first as this may result in calling back to |
538 // us to cleanup and delete gestures. | 539 // us to cleanup and delete gestures. |
539 active_pointers_.clear(); | 540 active_pointers_.clear(); |
540 } | 541 } |
541 | 542 |
542 bool GestureManager::ProcessEvent(const mojo::Event& event) { | 543 bool GestureManager::ProcessEvent(const mojo::Event& event) { |
543 if (!event.pointer_data) | 544 if (!event.pointer_data) |
544 return false; | 545 return false; |
545 | 546 |
546 ScheduledDeleteProcessor delete_processor(this); | 547 ScheduledDeleteProcessor delete_processor(this); |
547 const gfx::Point location(static_cast<int>(event.pointer_data->x), | 548 const gfx::Point location(static_cast<int>(event.pointer_data->where->x), |
548 static_cast<int>(event.pointer_data->y)); | 549 static_cast<int>(event.pointer_data->where->y)); |
549 switch (event.action) { | 550 switch (event.action) { |
550 case mojo::EVENT_TYPE_POINTER_DOWN: { | 551 case mojo::EVENT_TYPE_POINTER_DOWN: { |
551 if (GetPointerById(event.pointer_data->pointer_id)) { | 552 if (GetPointerById(event.pointer_data->pointer_id)) { |
552 DVLOG(1) << "received more than one down for a pointer without a " | 553 DVLOG(1) << "received more than one down for a pointer without a " |
553 << "corresponding up, id=" << event.pointer_data->pointer_id; | 554 << "corresponding up, id=" << event.pointer_data->pointer_id; |
554 NOTREACHED(); | 555 NOTREACHED(); |
555 return true; | 556 return true; |
556 } | 557 } |
557 | 558 |
558 const ServerView* deepest = FindDeepestVisibleView(root_view_, location); | 559 const ServerView* deepest = FindDeepestVisibleView(root_view_, location); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 void GestureManager::ScheduleDelete(Pointer* pointer) { | 693 void GestureManager::ScheduleDelete(Pointer* pointer) { |
693 auto iter = | 694 auto iter = |
694 std::find(active_pointers_.begin(), active_pointers_.end(), pointer); | 695 std::find(active_pointers_.begin(), active_pointers_.end(), pointer); |
695 if (iter != active_pointers_.end()) { | 696 if (iter != active_pointers_.end()) { |
696 active_pointers_.weak_erase(iter); | 697 active_pointers_.weak_erase(iter); |
697 pointers_to_delete_.push_back(pointer); | 698 pointers_to_delete_.push_back(pointer); |
698 } | 699 } |
699 } | 700 } |
700 | 701 |
701 } // namespace view_manager | 702 } // namespace view_manager |
OLD | NEW |