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/mus/event_dispatcher.h" | 5 #include "components/mus/event_dispatcher.h" |
6 | 6 |
7 #include "components/mus/server_view.h" | 7 #include "components/mus/server_view.h" |
8 #include "components/mus/view_coordinate_conversions.h" | 8 #include "components/mus/view_coordinate_conversions.h" |
9 #include "components/mus/view_locator.h" | 9 #include "components/mus/view_locator.h" |
10 #include "components/mus/view_tree_host_impl.h" | 10 #include "components/mus/view_tree_host_impl.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 pair.second.flags == event.flags) { | 64 pair.second.flags == event.flags) { |
65 *accelerator_id = pair.first; | 65 *accelerator_id = pair.first; |
66 return true; | 66 return true; |
67 } | 67 } |
68 } | 68 } |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 ServerView* EventDispatcher::FindEventTarget(mojo::Event* event) { | 72 ServerView* EventDispatcher::FindEventTarget(mojo::Event* event) { |
73 ServerView* focused_view = view_tree_host_->GetFocusedView(); | 73 ServerView* focused_view = view_tree_host_->GetFocusedView(); |
74 if (event->pointer_data) { | 74 if (event->pointer_data && event->pointer_data->location) { |
75 ServerView* root = view_tree_host_->root_view(); | 75 ServerView* root = view_tree_host_->root_view(); |
76 const gfx::Point root_point( | 76 const gfx::Point root_point( |
77 static_cast<int>(event->pointer_data->location->x), | 77 static_cast<int>(event->pointer_data->location->x), |
78 static_cast<int>(event->pointer_data->location->y)); | 78 static_cast<int>(event->pointer_data->location->y)); |
79 ServerView* target = focused_view; | 79 ServerView* target = focused_view; |
80 if (event->action == mojo::EVENT_TYPE_POINTER_DOWN || !target || | 80 if (event->action == mojo::EVENT_TYPE_POINTER_DOWN || !target || |
81 !root->Contains(target)) { | 81 !root->Contains(target)) { |
82 target = FindDeepestVisibleView(root, root_point); | 82 target = FindDeepestVisibleView(root, root_point); |
83 CHECK(target); | 83 CHECK(target); |
84 } | 84 } |
85 const gfx::PointF local_point(ConvertPointFBetweenViews( | 85 const gfx::PointF local_point(ConvertPointFBetweenViews( |
86 root, target, gfx::PointF(event->pointer_data->location->x, | 86 root, target, gfx::PointF(event->pointer_data->location->x, |
87 event->pointer_data->location->y))); | 87 event->pointer_data->location->y))); |
88 event->pointer_data->location->x = local_point.x(); | 88 event->pointer_data->location->x = local_point.x(); |
89 event->pointer_data->location->y = local_point.y(); | 89 event->pointer_data->location->y = local_point.y(); |
90 return target; | 90 return target; |
91 } | 91 } |
92 | 92 |
93 return focused_view; | 93 return focused_view; |
94 } | 94 } |
95 | 95 |
96 } // namespace mus | 96 } // namespace mus |
OLD | NEW |