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

Side by Side Diff: components/mus/ws/window_finder.cc

Issue 1489923002: Wire up inset of SetUnderlaySurfaceOffsetAndExtendedHitArea (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « components/mus/ws/window_finder.h ('k') | components/mus/ws/window_finder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "components/mus/ws/server_window_surface.h" 11 #include "components/mus/ws/server_window_surface.h"
12 #include "components/mus/ws/server_window_surface_manager.h" 12 #include "components/mus/ws/server_window_surface_manager.h"
13 #include "components/mus/ws/window_coordinate_conversions.h" 13 #include "components/mus/ws/window_coordinate_conversions.h"
14 #include "ui/gfx/geometry/point.h" 14 #include "ui/gfx/geometry/point.h"
15 #include "ui/gfx/geometry/point_f.h" 15 #include "ui/gfx/geometry/point_f.h"
16 #include "ui/gfx/transform.h" 16 #include "ui/gfx/transform.h"
17 17
18 namespace mus { 18 namespace mus {
19 namespace ws { 19 namespace ws {
20 namespace { 20 namespace {
21 21
22 bool IsValidWindowForEvents(ServerWindow* window) {
23 ServerWindowSurfaceManager* surface_manager = window->surface_manager();
24 return surface_manager &&
25 surface_manager->HasSurfaceOfType(mojom::SURFACE_TYPE_DEFAULT);
26 }
27
22 ServerWindow* FindDeepestVisibleWindowNonSurface(ServerWindow* window, 28 ServerWindow* FindDeepestVisibleWindowNonSurface(ServerWindow* window,
23 gfx::Point* location) { 29 gfx::Point* location) {
24 for (ServerWindow* child : window->GetChildren()) { 30 const ServerWindow::Windows children(window->GetChildren());
31 for (auto iter = children.rbegin(); iter != children.rend(); ++iter) {
32 ServerWindow* child = *iter;
25 if (!child->visible()) 33 if (!child->visible())
26 continue; 34 continue;
27 35
28 // TODO(sky): support transform. 36 // TODO(sky): support transform.
29 gfx::Point child_location(location->x() - child->bounds().x(), 37 gfx::Point child_location(location->x() - child->bounds().x(),
30 location->y() - child->bounds().y()); 38 location->y() - child->bounds().y());
31 if (child_location.x() >= 0 && child_location.y() >= 0 && 39 gfx::Rect child_bounds(child->bounds().size());
32 child_location.x() < child->bounds().width() && 40 child_bounds.Inset(-child->extended_hit_test_region().left(),
33 child_location.y() < child->bounds().height()) { 41 -child->extended_hit_test_region().top(),
42 -child->extended_hit_test_region().right(),
43 -child->extended_hit_test_region().bottom());
44 if (child_bounds.Contains(child_location)) {
34 *location = child_location; 45 *location = child_location;
35 return FindDeepestVisibleWindowNonSurface(child, location); 46 ServerWindow* result =
47 FindDeepestVisibleWindowNonSurface(child, location);
48 if (IsValidWindowForEvents(result))
49 return result;
36 } 50 }
37 } 51 }
38 return window; 52 return window;
39 } 53 }
40 54
41 gfx::Transform GetTransformToWindowNonSurface(ServerWindow* window) { 55 gfx::Transform GetTransformToWindowNonSurface(ServerWindow* window) {
42 gfx::Transform transform; 56 gfx::Transform transform;
43 ServerWindow* current = window; 57 ServerWindow* current = window;
44 while (current->parent()) { 58 while (current->parent()) {
45 transform.Translate(-current->bounds().x(), -current->bounds().y()); 59 transform.Translate(-current->bounds().x(), -current->bounds().y());
(...skipping 12 matching lines...) Expand all
58 return surface && 72 return surface &&
59 window->delegate() 73 window->delegate()
60 ->GetSurfacesState() 74 ->GetSurfacesState()
61 ->hit_tester() 75 ->hit_tester()
62 ->GetTransformToTargetSurface(display_surface_id, surface->id(), 76 ->GetTransformToTargetSurface(display_surface_id, surface->id(),
63 transform); 77 transform);
64 } 78 }
65 79
66 } // namespace 80 } // namespace
67 81
68 ServerWindow* FindDeepestVisibleWindow(ServerWindow* root_window, 82 ServerWindow* FindDeepestVisibleWindowForEvents(
69 cc::SurfaceId display_surface_id, 83 ServerWindow* root_window,
70 gfx::Point* location) { 84 cc::SurfaceId display_surface_id,
85 gfx::Point* location) {
86 // TODO(sky): remove this when insets can be set on surface.
87 display_surface_id = cc::SurfaceId();
88
71 if (display_surface_id.is_null()) { 89 if (display_surface_id.is_null()) {
72 // 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
73 // CompositorFrame has been submitted (e.g. in unit-tests). 91 // CompositorFrame has been submitted (e.g. in unit-tests).
74 return FindDeepestVisibleWindowNonSurface(root_window, location); 92 return FindDeepestVisibleWindowNonSurface(root_window, location);
75 } 93 }
76 94
77 gfx::Transform transform; 95 gfx::Transform transform;
78 cc::SurfaceId target_surface = 96 cc::SurfaceId target_surface =
79 root_window->delegate() 97 root_window->delegate()
80 ->GetSurfacesState() 98 ->GetSurfacesState()
(...skipping 20 matching lines...) Expand all
101 mus::mojom::SURFACE_TYPE_UNDERLAY, &transform)) { 119 mus::mojom::SURFACE_TYPE_UNDERLAY, &transform)) {
102 return transform; 120 return transform;
103 } 121 }
104 } 122 }
105 123
106 return GetTransformToWindowNonSurface(window); 124 return GetTransformToWindowNonSurface(window);
107 } 125 }
108 126
109 } // namespace ws 127 } // namespace ws
110 } // namespace mus 128 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_finder.h ('k') | components/mus/ws/window_finder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698