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 "services/ui/ws/window_finder.h" | 5 #include "services/ui/ws/window_finder.h" |
6 | 6 |
7 #include "base/containers/adapters.h" | 7 #include "base/containers/adapters.h" |
8 #include "services/ui/ws/server_window.h" | 8 #include "services/ui/ws/server_window.h" |
9 #include "services/ui/ws/server_window_delegate.h" | 9 #include "services/ui/ws/server_window_delegate.h" |
10 #include "services/ui/ws/window_coordinate_conversions.h" | 10 #include "services/ui/ws/window_coordinate_conversions.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 gfx::Transform transform = child->transform(); | 45 gfx::Transform transform = child->transform(); |
46 gfx::Transform translation; | 46 gfx::Transform translation; |
47 translation.Translate(static_cast<float>(child->bounds().x()), | 47 translation.Translate(static_cast<float>(child->bounds().x()), |
48 static_cast<float>(child->bounds().y())); | 48 static_cast<float>(child->bounds().y())); |
49 transform.ConcatTransform(translation); | 49 transform.ConcatTransform(translation); |
50 gfx::Point3F location_in_child3(gfx::PointF{location_in_parent}); | 50 gfx::Point3F location_in_child3(gfx::PointF{location_in_parent}); |
51 transform.TransformPointReverse(&location_in_child3); | 51 transform.TransformPointReverse(&location_in_child3); |
52 return gfx::ToFlooredPoint(location_in_child3.AsPointF()); | 52 return gfx::ToFlooredPoint(location_in_child3.AsPointF()); |
53 } | 53 } |
54 | 54 |
55 bool FindDeepestVisibleWindowForEventsImpl(ServerWindow* window, | 55 bool FindDeepestVisibleWindowForLocationImpl(ServerWindow* window, |
56 const gfx::Point& location, | 56 const gfx::Point& location, |
57 DeepestWindow* deepest_window) { | 57 DeepestWindow* deepest_window) { |
58 // The non-client area takes precedence over descendants, as otherwise the | 58 // The non-client area takes precedence over descendants, as otherwise the |
59 // user would likely not be able to hit the non-client area as it's common | 59 // user would likely not be able to hit the non-client area as it's common |
60 // for descendants to go into the non-client area. | 60 // for descendants to go into the non-client area. |
61 if (IsLocationInNonclientArea(window, location)) { | 61 if (IsLocationInNonclientArea(window, location)) { |
62 deepest_window->window = window; | 62 deepest_window->window = window; |
63 deepest_window->in_non_client_area = true; | 63 deepest_window->in_non_client_area = true; |
64 return true; | 64 return true; |
65 } | 65 } |
66 const mojom::EventTargetingPolicy event_targeting_policy = | 66 const mojom::EventTargetingPolicy event_targeting_policy = |
67 window->event_targeting_policy(); | 67 window->event_targeting_policy(); |
(...skipping 15 matching lines...) Expand all Loading... |
83 child_bounds.Inset(-child->extended_hit_test_region().left(), | 83 child_bounds.Inset(-child->extended_hit_test_region().left(), |
84 -child->extended_hit_test_region().top(), | 84 -child->extended_hit_test_region().top(), |
85 -child->extended_hit_test_region().right(), | 85 -child->extended_hit_test_region().right(), |
86 -child->extended_hit_test_region().bottom()); | 86 -child->extended_hit_test_region().bottom()); |
87 if (!child_bounds.Contains(location_in_child) || | 87 if (!child_bounds.Contains(location_in_child) || |
88 (child->hit_test_mask() && | 88 (child->hit_test_mask() && |
89 !child->hit_test_mask()->Contains(location_in_child))) { | 89 !child->hit_test_mask()->Contains(location_in_child))) { |
90 continue; | 90 continue; |
91 } | 91 } |
92 | 92 |
93 if (FindDeepestVisibleWindowForEventsImpl(child, location_in_child, | 93 if (FindDeepestVisibleWindowForLocationImpl(child, location_in_child, |
94 deepest_window)) { | 94 deepest_window)) { |
95 return true; | 95 return true; |
96 } | 96 } |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 if (event_targeting_policy == mojom::EventTargetingPolicy::DESCENDANTS_ONLY) | 100 if (event_targeting_policy == mojom::EventTargetingPolicy::DESCENDANTS_ONLY) |
101 return false; | 101 return false; |
102 | 102 |
103 deepest_window->window = window; | 103 deepest_window->window = window; |
104 deepest_window->in_non_client_area = false; | 104 deepest_window->in_non_client_area = false; |
105 return true; | 105 return true; |
106 } | 106 } |
107 | 107 |
108 } // namespace | 108 } // namespace |
109 | 109 |
110 DeepestWindow FindDeepestVisibleWindowForEvents(ServerWindow* root_window, | 110 DeepestWindow FindDeepestVisibleWindowForLocation(ServerWindow* root_window, |
111 const gfx::Point& location) { | 111 const gfx::Point& location) { |
112 DeepestWindow result; | 112 DeepestWindow result; |
113 FindDeepestVisibleWindowForEventsImpl(root_window, location, &result); | 113 FindDeepestVisibleWindowForLocationImpl(root_window, location, &result); |
114 return result; | 114 return result; |
115 } | 115 } |
116 | 116 |
117 gfx::Transform GetTransformToWindow(ServerWindow* window) { | 117 gfx::Transform GetTransformToWindow(ServerWindow* window) { |
118 gfx::Transform transform; | 118 gfx::Transform transform; |
119 ServerWindow* current = window; | 119 ServerWindow* current = window; |
120 while (current->parent()) { | 120 while (current->parent()) { |
121 transform.Translate(-current->bounds().x(), -current->bounds().y()); | 121 transform.Translate(-current->bounds().x(), -current->bounds().y()); |
122 current = current->parent(); | 122 current = current->parent(); |
123 } | 123 } |
124 return transform; | 124 return transform; |
125 } | 125 } |
126 | 126 |
127 } // namespace ws | 127 } // namespace ws |
128 } // namespace ui | 128 } // namespace ui |
OLD | NEW |