| 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/ws/window_finder.h" | 5 #include "components/mus/ws/window_finder.h" |
| 6 | 6 |
| 7 #include "cc/surfaces/surface_id.h" | 7 #include "cc/surfaces/surface_id.h" |
| 8 #include "components/mus/surfaces/surfaces_state.h" | 8 #include "components/mus/surfaces/surfaces_state.h" |
| 9 #include "components/mus/ws/server_window.h" | 9 #include "components/mus/ws/server_window.h" |
| 10 #include "components/mus/ws/server_window_delegate.h" | 10 #include "components/mus/ws/server_window_delegate.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 transform); | 77 transform); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace | 80 } // namespace |
| 81 | 81 |
| 82 ServerWindow* FindDeepestVisibleWindowForEvents( | 82 ServerWindow* FindDeepestVisibleWindowForEvents( |
| 83 ServerWindow* root_window, | 83 ServerWindow* root_window, |
| 84 cc::SurfaceId display_surface_id, | 84 cc::SurfaceId display_surface_id, |
| 85 gfx::Point* location) { | 85 gfx::Point* location) { |
| 86 // TODO(sky): remove this when insets can be set on surface. | 86 // TODO(sky): remove this when insets can be set on surface. |
| 87 display_surface_id = cc::SurfaceId(); | 87 // display_surface_id = cc::SurfaceId(); |
| 88 | 88 |
| 89 if (display_surface_id.is_null()) { | 89 if (display_surface_id.is_null()) { |
| 90 // Surface-based hit-testing will not return a valid target if no | 90 // Surface-based hit-testing will not return a valid target if no |
| 91 // CompositorFrame has been submitted (e.g. in unit-tests). | 91 // CompositorFrame has been submitted (e.g. in unit-tests). |
| 92 return FindDeepestVisibleWindowNonSurface(root_window, location); | 92 return FindDeepestVisibleWindowNonSurface(root_window, location); |
| 93 } | 93 } |
| 94 | 94 |
| 95 gfx::Transform transform; | 95 gfx::Transform transform; |
| 96 cc::SurfaceId target_surface = | 96 cc::SurfaceId target_surface = |
| 97 root_window->delegate() | 97 root_window->delegate() |
| 98 ->GetSurfacesState() | 98 ->GetSurfacesState() |
| 99 ->hit_tester() | 99 ->hit_tester() |
| 100 ->GetTargetSurfaceAtPoint(display_surface_id, *location, &transform); | 100 ->GetTargetSurfaceAtPoint(display_surface_id, *location, &transform); |
| 101 WindowId id = WindowIdFromTransportId( | 101 WindowId id = WindowIdFromTransportId( |
| 102 cc::SurfaceIdAllocator::NamespaceForId(target_surface)); | 102 cc::SurfaceIdAllocator::NamespaceForId(target_surface)); |
| 103 // TODO(fsamuel): This should be a DCHECK but currently we use stale | 103 // TODO(fsamuel): This should be a DCHECK but currently we use stale |
| 104 // information to decide where to route input events. This should be fixed | 104 // information to decide where to route input events. This should be fixed |
| 105 // once we implement a UI scheduler. | 105 // once we implement a UI scheduler. |
| 106 ServerWindow* target = root_window->GetChildWindow(id); | 106 ServerWindow* target = root_window->GetChildWindow(id); |
| 107 if (target) | 107 if (target) |
| 108 transform.TransformPoint(location); | 108 transform.TransformPoint(location); |
| 109 return target; | 109 return target ? target |
| 110 : FindDeepestVisibleWindowNonSurface(root_window, location); |
| 110 } | 111 } |
| 111 | 112 |
| 112 gfx::Transform GetTransformToWindow(cc::SurfaceId display_surface_id, | 113 gfx::Transform GetTransformToWindow(cc::SurfaceId display_surface_id, |
| 113 ServerWindow* window) { | 114 ServerWindow* window) { |
| 114 if (!display_surface_id.is_null()) { | 115 if (!display_surface_id.is_null()) { |
| 115 gfx::Transform transform; | 116 gfx::Transform transform; |
| 116 if (HitTestSurfaceOfType(display_surface_id, window, | 117 if (HitTestSurfaceOfType(display_surface_id, window, |
| 117 mus::mojom::SurfaceType::DEFAULT, &transform) || | 118 mus::mojom::SurfaceType::DEFAULT, &transform) || |
| 118 HitTestSurfaceOfType(display_surface_id, window, | 119 HitTestSurfaceOfType(display_surface_id, window, |
| 119 mus::mojom::SurfaceType::UNDERLAY, &transform)) { | 120 mus::mojom::SurfaceType::UNDERLAY, &transform)) { |
| 120 return transform; | 121 return transform; |
| 121 } | 122 } |
| 122 } | 123 } |
| 123 | 124 |
| 124 return GetTransformToWindowNonSurface(window); | 125 return GetTransformToWindowNonSurface(window); |
| 125 } | 126 } |
| 126 | 127 |
| 127 } // namespace ws | 128 } // namespace ws |
| 128 } // namespace mus | 129 } // namespace mus |
| OLD | NEW |