| 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/mus/root_window_controller.h" | 5 #include "ash/mus/root_window_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <sstream> | 11 #include <sstream> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "ash/common/shelf/shelf_layout_manager.h" | 16 #include "ash/common/shelf/shelf_layout_manager.h" |
| 17 #include "ash/common/shell_window_ids.h" | |
| 18 #include "ash/common/wm/container_finder.h" | 17 #include "ash/common/wm/container_finder.h" |
| 19 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 18 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 20 #include "ash/common/wm/panels/panel_layout_manager.h" | 19 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 21 #include "ash/common/wm/root_window_layout_manager.h" | 20 #include "ash/common/wm/root_window_layout_manager.h" |
| 22 #include "ash/mus/bridge/wm_root_window_controller_mus.h" | 21 #include "ash/mus/bridge/wm_root_window_controller_mus.h" |
| 23 #include "ash/mus/bridge/wm_shelf_mus.h" | 22 #include "ash/mus/bridge/wm_shelf_mus.h" |
| 24 #include "ash/mus/bridge/wm_shell_mus.h" | 23 #include "ash/mus/bridge/wm_shell_mus.h" |
| 25 #include "ash/mus/bridge/wm_window_mus.h" | 24 #include "ash/mus/bridge/wm_window_mus.h" |
| 26 #include "ash/mus/container_ids.h" | |
| 27 #include "ash/mus/non_client_frame_controller.h" | 25 #include "ash/mus/non_client_frame_controller.h" |
| 28 #include "ash/mus/property_util.h" | 26 #include "ash/mus/property_util.h" |
| 29 #include "ash/mus/screenlock_layout.h" | 27 #include "ash/mus/screenlock_layout.h" |
| 30 #include "ash/mus/window_manager.h" | 28 #include "ash/mus/window_manager.h" |
| 29 #include "ash/shared/shell_window_ids.h" |
| 31 #include "base/bind.h" | 30 #include "base/bind.h" |
| 32 #include "base/command_line.h" | 31 #include "base/command_line.h" |
| 33 #include "base/memory/ptr_util.h" | 32 #include "base/memory/ptr_util.h" |
| 34 #include "mojo/public/cpp/bindings/type_converter.h" | 33 #include "mojo/public/cpp/bindings/type_converter.h" |
| 35 #include "services/service_manager/public/cpp/connector.h" | 34 #include "services/service_manager/public/cpp/connector.h" |
| 36 #include "services/ui/common/switches.h" | 35 #include "services/ui/common/switches.h" |
| 37 #include "services/ui/common/util.h" | 36 #include "services/ui/common/util.h" |
| 38 #include "services/ui/public/cpp/property_type_converters.h" | 37 #include "services/ui/public/cpp/property_type_converters.h" |
| 39 #include "services/ui/public/cpp/window.h" | 38 #include "services/ui/public/cpp/window.h" |
| 40 #include "services/ui/public/cpp/window_property.h" | 39 #include "services/ui/public/cpp/window_property.h" |
| 41 #include "services/ui/public/cpp/window_tree_client.h" | 40 #include "services/ui/public/cpp/window_tree_client.h" |
| 42 #include "ui/display/display_list.h" | 41 #include "ui/display/display_list.h" |
| 43 #include "ui/display/screen_base.h" | 42 #include "ui/display/screen_base.h" |
| 44 | 43 |
| 45 using ash::mojom::Container; | |
| 46 | |
| 47 namespace ash { | 44 namespace ash { |
| 48 namespace mus { | 45 namespace mus { |
| 49 | 46 |
| 50 RootWindowController::RootWindowController(WindowManager* window_manager, | 47 RootWindowController::RootWindowController(WindowManager* window_manager, |
| 51 ui::Window* root, | 48 ui::Window* root, |
| 52 const display::Display& display) | 49 const display::Display& display) |
| 53 : window_manager_(window_manager), | 50 : window_manager_(window_manager), |
| 54 root_(root), | 51 root_(root), |
| 55 window_count_(0), | 52 window_count_(0), |
| 56 display_(display), | 53 display_(display), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 GetWindowType(*properties) == ui::mojom::WindowType::WINDOW || | 91 GetWindowType(*properties) == ui::mojom::WindowType::WINDOW || |
| 95 GetWindowType(*properties) == ui::mojom::WindowType::PANEL; | 92 GetWindowType(*properties) == ui::mojom::WindowType::PANEL; |
| 96 if (provide_non_client_frame) | 93 if (provide_non_client_frame) |
| 97 (*properties)[ui::mojom::kWaitForUnderlay_Property].clear(); | 94 (*properties)[ui::mojom::kWaitForUnderlay_Property].clear(); |
| 98 | 95 |
| 99 // TODO(sky): constrain and validate properties before passing to server. | 96 // TODO(sky): constrain and validate properties before passing to server. |
| 100 ui::Window* window = root_->window_tree()->NewWindow(properties); | 97 ui::Window* window = root_->window_tree()->NewWindow(properties); |
| 101 window->SetBounds(CalculateDefaultBounds(window)); | 98 window->SetBounds(CalculateDefaultBounds(window)); |
| 102 | 99 |
| 103 ui::Window* container_window = nullptr; | 100 ui::Window* container_window = nullptr; |
| 104 mojom::Container container; | 101 int container_id = kShellWindowId_Invalid; |
| 105 if (GetRequestedContainer(window, &container)) { | 102 if (GetRequestedContainer(window, &container_id)) { |
| 106 container_window = GetWindowForContainer(container); | 103 container_window = GetWindowByShellWindowId(container_id)->mus_window(); |
| 107 } else { | 104 } else { |
| 108 // TODO(sky): window->bounds() isn't quite right. | 105 // TODO(sky): window->bounds() isn't quite right. |
| 109 container_window = WmWindowMus::GetMusWindow(wm::GetDefaultParent( | 106 container_window = WmWindowMus::GetMusWindow(wm::GetDefaultParent( |
| 110 WmWindowMus::Get(root_), WmWindowMus::Get(window), window->bounds())); | 107 WmWindowMus::Get(root_), WmWindowMus::Get(window), window->bounds())); |
| 111 } | 108 } |
| 112 DCHECK(WmWindowMus::Get(container_window)->IsContainer()); | 109 DCHECK(WmWindowMus::Get(container_window)->IsContainer()); |
| 113 | 110 |
| 114 if (provide_non_client_frame) { | 111 if (provide_non_client_frame) { |
| 115 NonClientFrameController::Create(container_window, window, | 112 NonClientFrameController::Create(container_window, window, |
| 116 window_manager_->window_manager_client()); | 113 window_manager_->window_manager_client()); |
| 117 } else { | 114 } else { |
| 118 container_window->AddChild(window); | 115 container_window->AddChild(window); |
| 119 } | 116 } |
| 120 | 117 |
| 121 window_count_++; | 118 window_count_++; |
| 122 | 119 |
| 123 return window; | 120 return window; |
| 124 } | 121 } |
| 125 | 122 |
| 126 ui::Window* RootWindowController::GetWindowForContainer(Container container) { | |
| 127 WmWindowMus* wm_window = | |
| 128 GetWindowByShellWindowId(MashContainerToAshShellWindowId(container)); | |
| 129 DCHECK(wm_window); | |
| 130 return wm_window->mus_window(); | |
| 131 } | |
| 132 | |
| 133 WmWindowMus* RootWindowController::GetWindowByShellWindowId(int id) { | 123 WmWindowMus* RootWindowController::GetWindowByShellWindowId(int id) { |
| 134 return WmWindowMus::AsWmWindowMus( | 124 return WmWindowMus::AsWmWindowMus( |
| 135 WmWindowMus::Get(root_)->GetChildByShellWindowId(id)); | 125 WmWindowMus::Get(root_)->GetChildByShellWindowId(id)); |
| 136 } | 126 } |
| 137 | 127 |
| 138 void RootWindowController::SetWorkAreaInests(const gfx::Insets& insets) { | 128 void RootWindowController::SetWorkAreaInests(const gfx::Insets& insets) { |
| 139 display_.UpdateWorkAreaFromInsets(insets); | 129 display_.UpdateWorkAreaFromInsets(insets); |
| 140 display::DisplayList* display_list = | 130 display::DisplayList* display_list = |
| 141 window_manager_->screen()->display_list(); | 131 window_manager_->screen()->display_list(); |
| 142 auto iter = display_list->FindDisplayById(display_.id()); | 132 auto iter = display_list->FindDisplayById(display_.id()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 void RootWindowController::CreateLayoutManagers() { | 170 void RootWindowController::CreateLayoutManagers() { |
| 181 // Override the default layout managers for certain containers. | 171 // Override the default layout managers for certain containers. |
| 182 WmWindowMus* lock_screen_container = | 172 WmWindowMus* lock_screen_container = |
| 183 GetWindowByShellWindowId(kShellWindowId_LockScreenContainer); | 173 GetWindowByShellWindowId(kShellWindowId_LockScreenContainer); |
| 184 layout_managers_[lock_screen_container->mus_window()].reset( | 174 layout_managers_[lock_screen_container->mus_window()].reset( |
| 185 new ScreenlockLayout(lock_screen_container->mus_window())); | 175 new ScreenlockLayout(lock_screen_container->mus_window())); |
| 186 } | 176 } |
| 187 | 177 |
| 188 } // namespace mus | 178 } // namespace mus |
| 189 } // namespace ash | 179 } // namespace ash |
| OLD | NEW |