OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/wm/container_finder.h" | 5 #include "ash/wm/container_finder.h" |
6 | 6 |
7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
8 #include "ash/public/cpp/window_properties.h" | 8 #include "ash/public/cpp/window_properties.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/session/session_controller.h" | 10 #include "ash/session/session_controller.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // In case of missing transient parent (it could happen for alerts from | 39 // In case of missing transient parent (it could happen for alerts from |
40 // background pages) assume that the window belongs to user session. | 40 // background pages) assume that the window belongs to user session. |
41 if (!Shell::Get()->session_controller()->IsUserSessionBlocked() || | 41 if (!Shell::Get()->session_controller()->IsUserSessionBlocked() || |
42 !window->GetTransientParent()) { | 42 !window->GetTransientParent()) { |
43 return root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); | 43 return root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); |
44 } | 44 } |
45 | 45 |
46 // Otherwise those that originate from LockScreen container and above are | 46 // Otherwise those that originate from LockScreen container and above are |
47 // placed in the screen lock modal container. | 47 // placed in the screen lock modal container. |
48 int window_container_id = | 48 int window_container_id = |
49 window->GetTransientParent()->GetParent()->GetShellWindowId(); | 49 window->GetTransientParent()->GetParent()->aura_window()->id(); |
50 if (window_container_id < kShellWindowId_LockScreenContainer) | 50 if (window_container_id < kShellWindowId_LockScreenContainer) |
51 return root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); | 51 return root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); |
52 return root->GetChildByShellWindowId(kShellWindowId_LockSystemModalContainer); | 52 return root->GetChildByShellWindowId(kShellWindowId_LockSystemModalContainer); |
53 } | 53 } |
54 | 54 |
55 WmWindow* GetContainerFromAlwaysOnTopController(WmWindow* root, | 55 WmWindow* GetContainerFromAlwaysOnTopController(WmWindow* root, |
56 WmWindow* window) { | 56 WmWindow* window) { |
57 return root->GetRootWindowController() | 57 return root->GetRootWindowController() |
58 ->always_on_top_controller() | 58 ->always_on_top_controller() |
59 ->GetContainer(window); | 59 ->GetContainer(window); |
60 } | 60 } |
61 | 61 |
62 } // namespace | 62 } // namespace |
63 | 63 |
64 WmWindow* GetContainerForWindow(WmWindow* window) { | 64 WmWindow* GetContainerForWindow(WmWindow* window) { |
65 WmWindow* parent = window->GetParent(); | 65 WmWindow* parent = window->GetParent(); |
66 // The first parent with an explicit shell window ID is the container. | 66 // The first parent with an explicit shell window ID is the container. |
67 while (parent && parent->GetShellWindowId() == kShellWindowId_Invalid) | 67 while (parent && parent->aura_window()->id() == kShellWindowId_Invalid) |
68 parent = parent->GetParent(); | 68 parent = parent->GetParent(); |
69 return parent; | 69 return parent; |
70 } | 70 } |
71 | 71 |
72 WmWindow* GetDefaultParent(WmWindow* window, const gfx::Rect& bounds) { | 72 WmWindow* GetDefaultParent(WmWindow* window, const gfx::Rect& bounds) { |
73 WmWindow* target_root = nullptr; | 73 WmWindow* target_root = nullptr; |
74 WmWindow* transient_parent = window->GetTransientParent(); | 74 WmWindow* transient_parent = window->GetTransientParent(); |
75 if (transient_parent) { | 75 if (transient_parent) { |
76 // Transient window should use the same root as its transient parent. | 76 // Transient window should use the same root as its transient parent. |
77 target_root = transient_parent->GetRootWindow(); | 77 target_root = transient_parent->GetRootWindow(); |
(...skipping 16 matching lines...) Expand all Loading... |
94 if (window->aura_window()->GetProperty(kPanelAttachedKey)) | 94 if (window->aura_window()->GetProperty(kPanelAttachedKey)) |
95 return target_root->GetChildByShellWindowId( | 95 return target_root->GetChildByShellWindowId( |
96 kShellWindowId_PanelContainer); | 96 kShellWindowId_PanelContainer); |
97 return GetContainerFromAlwaysOnTopController(target_root, window); | 97 return GetContainerFromAlwaysOnTopController(target_root, window); |
98 case ui::wm::WINDOW_TYPE_MENU: | 98 case ui::wm::WINDOW_TYPE_MENU: |
99 return target_root->GetChildByShellWindowId(kShellWindowId_MenuContainer); | 99 return target_root->GetChildByShellWindowId(kShellWindowId_MenuContainer); |
100 case ui::wm::WINDOW_TYPE_TOOLTIP: | 100 case ui::wm::WINDOW_TYPE_TOOLTIP: |
101 return target_root->GetChildByShellWindowId( | 101 return target_root->GetChildByShellWindowId( |
102 kShellWindowId_DragImageAndTooltipContainer); | 102 kShellWindowId_DragImageAndTooltipContainer); |
103 default: | 103 default: |
104 NOTREACHED() << "Window " << window->GetShellWindowId() | 104 NOTREACHED() << "Window " << window->aura_window()->id() |
105 << " has unhandled type " << window->GetType(); | 105 << " has unhandled type " << window->GetType(); |
106 break; | 106 break; |
107 } | 107 } |
108 return nullptr; | 108 return nullptr; |
109 } | 109 } |
110 | 110 |
111 aura::Window::Windows GetContainersFromAllRootWindows( | 111 aura::Window::Windows GetContainersFromAllRootWindows( |
112 int container_id, | 112 int container_id, |
113 aura::Window* priority_root) { | 113 aura::Window* priority_root) { |
114 aura::Window::Windows containers; | 114 aura::Window::Windows containers; |
115 for (aura::Window* root : Shell::GetAllRootWindows()) { | 115 for (aura::Window* root : Shell::GetAllRootWindows()) { |
116 aura::Window* container = root->GetChildById(container_id); | 116 aura::Window* container = root->GetChildById(container_id); |
117 if (!container) | 117 if (!container) |
118 continue; | 118 continue; |
119 | 119 |
120 if (priority_root && priority_root->Contains(container)) | 120 if (priority_root && priority_root->Contains(container)) |
121 containers.insert(containers.begin(), container); | 121 containers.insert(containers.begin(), container); |
122 else | 122 else |
123 containers.push_back(container); | 123 containers.push_back(container); |
124 } | 124 } |
125 return containers; | 125 return containers; |
126 } | 126 } |
127 | 127 |
128 } // namespace wm | 128 } // namespace wm |
129 } // namespace ash | 129 } // namespace ash |
OLD | NEW |