OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/mus/top_level_window_factory.h" | 5 #include "ash/mus/top_level_window_factory.h" |
6 | 6 |
7 #include "ash/mus/disconnected_app_handler.h" | 7 #include "ash/mus/disconnected_app_handler.h" |
8 #include "ash/mus/frame/detached_title_area_renderer.h" | 8 #include "ash/mus/frame/detached_title_area_renderer.h" |
9 #include "ash/mus/non_client_frame_controller.h" | 9 #include "ash/mus/non_client_frame_controller.h" |
10 #include "ash/mus/property_util.h" | 10 #include "ash/mus/property_util.h" |
11 #include "ash/mus/window_manager.h" | 11 #include "ash/mus/window_manager.h" |
12 #include "ash/public/cpp/shell_window_ids.h" | 12 #include "ash/public/cpp/shell_window_ids.h" |
13 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
14 #include "ash/root_window_settings.h" | 14 #include "ash/root_window_settings.h" |
15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
16 #include "ash/wm/container_finder.h" | 16 #include "ash/wm/container_finder.h" |
17 #include "ash/wm/window_state.h" | 17 #include "ash/wm/window_state.h" |
18 #include "ash/wm_window.h" | |
19 #include "mojo/public/cpp/bindings/type_converter.h" | 18 #include "mojo/public/cpp/bindings/type_converter.h" |
20 #include "services/ui/public/cpp/property_type_converters.h" | 19 #include "services/ui/public/cpp/property_type_converters.h" |
21 #include "services/ui/public/interfaces/window_manager.mojom.h" | 20 #include "services/ui/public/interfaces/window_manager.mojom.h" |
22 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 21 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
23 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
24 #include "ui/aura/mus/property_converter.h" | 23 #include "ui/aura/mus/property_converter.h" |
25 #include "ui/aura/mus/property_utils.h" | 24 #include "ui/aura/mus/property_utils.h" |
26 #include "ui/aura/mus/window_tree_client.h" | 25 #include "ui/aura/mus/window_tree_client.h" |
27 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
28 #include "ui/display/display.h" | 27 #include "ui/display/display.h" |
| 28 #include "ui/display/screen.h" |
29 | 29 |
30 namespace ash { | 30 namespace ash { |
31 namespace mus { | 31 namespace mus { |
32 namespace { | 32 namespace { |
33 | 33 |
34 // Returns true if a fullscreen window was requested. | 34 // Returns true if a fullscreen window was requested. |
35 bool IsFullscreen(aura::PropertyConverter* property_converter, | 35 bool IsFullscreen(aura::PropertyConverter* property_converter, |
36 const std::vector<uint8_t>& transport_data) { | 36 const std::vector<uint8_t>& transport_data) { |
37 using ui::mojom::WindowManager; | 37 using ui::mojom::WindowManager; |
38 aura::PropertyConverter::PrimitiveType show_state = 0; | 38 aura::PropertyConverter::PrimitiveType show_state = 0; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 const gfx::Size root_size = | 88 const gfx::Size root_size = |
89 root_window_controller->GetRootWindow()->bounds().size(); | 89 root_window_controller->GetRootWindow()->bounds().size(); |
90 auto show_state_iter = | 90 auto show_state_iter = |
91 properties->find(ui::mojom::WindowManager::kShowState_Property); | 91 properties->find(ui::mojom::WindowManager::kShowState_Property); |
92 if (show_state_iter != properties->end()) { | 92 if (show_state_iter != properties->end()) { |
93 if (IsFullscreen(window_manager->property_converter(), | 93 if (IsFullscreen(window_manager->property_converter(), |
94 show_state_iter->second)) { | 94 show_state_iter->second)) { |
95 gfx::Rect bounds(root_size); | 95 gfx::Rect bounds(root_size); |
96 if (!container_window) { | 96 if (!container_window) { |
97 const display::Display display = | 97 const display::Display display = |
98 root_window_controller->GetWindow()->GetDisplayNearestWindow(); | 98 display::Screen::GetScreen()->GetDisplayNearestWindow( |
| 99 root_window_controller->GetRootWindow()); |
99 bounds.Offset(display.bounds().OffsetFromOrigin()); | 100 bounds.Offset(display.bounds().OffsetFromOrigin()); |
100 } | 101 } |
101 return bounds; | 102 return bounds; |
102 } | 103 } |
103 } | 104 } |
104 | 105 |
105 gfx::Size window_size; | 106 gfx::Size window_size; |
106 if (GetWindowPreferredSize(*properties, &window_size) && | 107 if (GetWindowPreferredSize(*properties, &window_size) && |
107 !window_size.IsEmpty()) { | 108 !window_size.IsEmpty()) { |
108 // TODO(sky): likely want to constrain more than root size. | 109 // TODO(sky): likely want to constrain more than root size. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 aura::SetWindowType(window, window_type); | 172 aura::SetWindowType(window, window_type); |
172 window->SetProperty(aura::client::kEmbedType, | 173 window->SetProperty(aura::client::kEmbedType, |
173 aura::client::WindowEmbedType::TOP_LEVEL_IN_WM); | 174 aura::client::WindowEmbedType::TOP_LEVEL_IN_WM); |
174 ApplyProperties(window, property_converter, *properties); | 175 ApplyProperties(window, property_converter, *properties); |
175 window->Init(ui::LAYER_TEXTURED); | 176 window->Init(ui::LAYER_TEXTURED); |
176 window->SetBounds(bounds); | 177 window->SetBounds(bounds); |
177 | 178 |
178 if (container_window) { | 179 if (container_window) { |
179 container_window->AddChild(window); | 180 container_window->AddChild(window); |
180 } else { | 181 } else { |
181 WmWindow* root = root_window_controller->GetWindow(); | 182 aura::Window* root = root_window_controller->GetRootWindow(); |
182 gfx::Point origin = | 183 gfx::Point origin; |
183 root->ConvertPointToTarget(root->GetRootWindow(), gfx::Point()); | 184 aura::Window::ConvertPointToTarget(root, root->GetRootWindow(), &origin); |
184 origin += root_window_controller->GetWindow() | 185 const display::Display display = |
185 ->GetDisplayNearestWindow() | 186 display::Screen::GetScreen()->GetDisplayNearestWindow( |
186 .bounds() | 187 root_window_controller->GetRootWindow()); |
187 .OffsetFromOrigin(); | 188 origin += display.bounds().OffsetFromOrigin(); |
188 gfx::Rect bounds_in_screen(origin, bounds.size()); | 189 gfx::Rect bounds_in_screen(origin, bounds.size()); |
189 ash::wm::GetDefaultParent(window, bounds_in_screen)->AddChild(window); | 190 ash::wm::GetDefaultParent(window, bounds_in_screen)->AddChild(window); |
190 } | 191 } |
191 return window; | 192 return window; |
192 } | 193 } |
193 | 194 |
194 } // namespace | 195 } // namespace |
195 | 196 |
196 aura::Window* CreateAndParentTopLevelWindow( | 197 aura::Window* CreateAndParentTopLevelWindow( |
197 WindowManager* window_manager, | 198 WindowManager* window_manager, |
198 ui::mojom::WindowType window_type, | 199 ui::mojom::WindowType window_type, |
199 std::map<std::string, std::vector<uint8_t>>* properties) { | 200 std::map<std::string, std::vector<uint8_t>>* properties) { |
200 RootWindowController* root_window_controller = | 201 RootWindowController* root_window_controller = |
201 GetRootWindowControllerForNewTopLevelWindow(properties); | 202 GetRootWindowControllerForNewTopLevelWindow(properties); |
202 aura::Window* window = CreateAndParentTopLevelWindowInRoot( | 203 aura::Window* window = CreateAndParentTopLevelWindowInRoot( |
203 window_manager, root_window_controller, window_type, properties); | 204 window_manager, root_window_controller, window_type, properties); |
204 DisconnectedAppHandler::Create(window); | 205 DisconnectedAppHandler::Create(window); |
205 | 206 |
206 auto ignored_by_shelf_iter = properties->find( | 207 auto ignored_by_shelf_iter = properties->find( |
207 ui::mojom::WindowManager::kWindowIgnoredByShelf_InitProperty); | 208 ui::mojom::WindowManager::kWindowIgnoredByShelf_InitProperty); |
208 if (ignored_by_shelf_iter != properties->end()) { | 209 if (ignored_by_shelf_iter != properties->end()) { |
209 wm::WindowState* window_state = WmWindow::Get(window)->GetWindowState(); | 210 wm::WindowState* window_state = wm::GetWindowState(window); |
210 window_state->set_ignored_by_shelf( | 211 window_state->set_ignored_by_shelf( |
211 mojo::ConvertTo<bool>(ignored_by_shelf_iter->second)); | 212 mojo::ConvertTo<bool>(ignored_by_shelf_iter->second)); |
212 // No need to persist this value. | 213 // No need to persist this value. |
213 properties->erase(ignored_by_shelf_iter); | 214 properties->erase(ignored_by_shelf_iter); |
214 } | 215 } |
215 | 216 |
216 auto focusable_iter = | 217 auto focusable_iter = |
217 properties->find(ui::mojom::WindowManager::kFocusable_InitProperty); | 218 properties->find(ui::mojom::WindowManager::kFocusable_InitProperty); |
218 if (focusable_iter != properties->end()) { | 219 if (focusable_iter != properties->end()) { |
219 bool can_focus = mojo::ConvertTo<bool>(focusable_iter->second); | 220 bool can_focus = mojo::ConvertTo<bool>(focusable_iter->second); |
220 window_manager->window_tree_client()->SetCanFocus(window, can_focus); | 221 window_manager->window_tree_client()->SetCanFocus(window, can_focus); |
221 NonClientFrameController* non_client_frame_controller = | 222 NonClientFrameController* non_client_frame_controller = |
222 NonClientFrameController::Get(window); | 223 NonClientFrameController::Get(window); |
223 if (non_client_frame_controller) | 224 if (non_client_frame_controller) |
224 non_client_frame_controller->set_can_activate(can_focus); | 225 non_client_frame_controller->set_can_activate(can_focus); |
225 // No need to persist this value. | 226 // No need to persist this value. |
226 properties->erase(focusable_iter); | 227 properties->erase(focusable_iter); |
227 } | 228 } |
228 return window; | 229 return window; |
229 } | 230 } |
230 | 231 |
231 } // namespace mus | 232 } // namespace mus |
232 } // namespace ash | 233 } // namespace ash |
OLD | NEW |