| 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/aura/wm_window_aura.h" | 16 #include "ash/aura/wm_window_aura.h" |
| 17 #include "ash/common/shelf/shelf_layout_manager.h" | 17 #include "ash/common/shelf/shelf_layout_manager.h" |
| 18 #include "ash/common/shelf/wm_shelf.h" | 18 #include "ash/common/shelf/wm_shelf.h" |
| 19 #include "ash/common/wm/container_finder.h" | 19 #include "ash/common/wm/container_finder.h" |
| 20 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 20 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 21 #include "ash/common/wm/panels/panel_layout_manager.h" | 21 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 22 #include "ash/common/wm/root_window_layout_manager.h" | 22 #include "ash/common/wm/root_window_layout_manager.h" |
| 23 #include "ash/mus/bridge/wm_shell_mus.h" | 23 #include "ash/mus/bridge/wm_shell_mus.h" |
| 24 #include "ash/mus/disconnected_app_handler.h" |
| 24 #include "ash/mus/non_client_frame_controller.h" | 25 #include "ash/mus/non_client_frame_controller.h" |
| 25 #include "ash/mus/property_util.h" | 26 #include "ash/mus/property_util.h" |
| 26 #include "ash/mus/screen_mus.h" | 27 #include "ash/mus/screen_mus.h" |
| 27 #include "ash/mus/window_manager.h" | 28 #include "ash/mus/window_manager.h" |
| 28 #include "ash/public/cpp/shell_window_ids.h" | 29 #include "ash/public/cpp/shell_window_ids.h" |
| 29 #include "ash/root_window_settings.h" | 30 #include "ash/root_window_settings.h" |
| 30 #include "base/bind.h" | 31 #include "base/bind.h" |
| 31 #include "base/command_line.h" | 32 #include "base/command_line.h" |
| 32 #include "base/memory/ptr_util.h" | 33 #include "base/memory/ptr_util.h" |
| 33 #include "mojo/public/cpp/bindings/type_converter.h" | 34 #include "mojo/public/cpp/bindings/type_converter.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 window_tree_host_(window_tree_host.get()), | 76 window_tree_host_(window_tree_host.get()), |
| 76 window_count_(0), | 77 window_count_(0), |
| 77 display_(display) { | 78 display_(display) { |
| 78 ash::InitRootWindowSettings(window_tree_host->window()); | 79 ash::InitRootWindowSettings(window_tree_host->window()); |
| 79 window_tree_host->window()->SetProperty(kRootWindowControllerKey, this); | 80 window_tree_host->window()->SetProperty(kRootWindowControllerKey, this); |
| 80 WmShellMus::Get()->AddRootWindowController(this); | 81 WmShellMus::Get()->AddRootWindowController(this); |
| 81 ash_root_window_controller_ = base::WrapUnique( | 82 ash_root_window_controller_ = base::WrapUnique( |
| 82 new ash::RootWindowController(nullptr, window_tree_host.release())); | 83 new ash::RootWindowController(nullptr, window_tree_host.release())); |
| 83 ash_root_window_controller_->Init(root_window_type); | 84 ash_root_window_controller_->Init(root_window_type); |
| 84 | 85 |
| 85 disconnected_app_handler_.reset(new DisconnectedAppHandler(root())); | |
| 86 | |
| 87 for (size_t i = 0; i < kNumActivatableShellWindowIds; ++i) { | 86 for (size_t i = 0; i < kNumActivatableShellWindowIds; ++i) { |
| 88 window_manager_->window_manager_client()->AddActivationParent( | 87 window_manager_->window_manager_client()->AddActivationParent( |
| 89 GetWindowByShellWindowId(kActivatableShellWindowIds[i])->aura_window()); | 88 GetWindowByShellWindowId(kActivatableShellWindowIds[i])->aura_window()); |
| 90 } | 89 } |
| 91 } | 90 } |
| 92 | 91 |
| 93 RootWindowController::~RootWindowController() { | 92 RootWindowController::~RootWindowController() { |
| 94 Shutdown(); | 93 Shutdown(); |
| 95 ash_root_window_controller_.reset(); | 94 ash_root_window_controller_.reset(); |
| 96 WmShellMus::Get()->RemoveRootWindowController(this); | 95 WmShellMus::Get()->RemoveRootWindowController(this); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 window_count_++; | 134 window_count_++; |
| 136 | 135 |
| 137 const bool provide_non_client_frame = | 136 const bool provide_non_client_frame = |
| 138 window_type == ui::mojom::WindowType::WINDOW || | 137 window_type == ui::mojom::WindowType::WINDOW || |
| 139 window_type == ui::mojom::WindowType::PANEL; | 138 window_type == ui::mojom::WindowType::PANEL; |
| 140 if (provide_non_client_frame) { | 139 if (provide_non_client_frame) { |
| 141 // See NonClientFrameController for details on lifetime. | 140 // See NonClientFrameController for details on lifetime. |
| 142 NonClientFrameController* non_client_frame_controller = | 141 NonClientFrameController* non_client_frame_controller = |
| 143 new NonClientFrameController(container_window, context, bounds, | 142 new NonClientFrameController(container_window, context, bounds, |
| 144 window_type, properties, window_manager_); | 143 window_type, properties, window_manager_); |
| 144 DisconnectedAppHandler::Create(non_client_frame_controller->window()); |
| 145 return non_client_frame_controller->window(); | 145 return non_client_frame_controller->window(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 aura::Window* window = new aura::Window(nullptr); | 148 aura::Window* window = new aura::Window(nullptr); |
| 149 aura::SetWindowType(window, window_type); | 149 aura::SetWindowType(window, window_type); |
| 150 // Apply properties before Init(), that way they are sent to the server at | 150 // Apply properties before Init(), that way they are sent to the server at |
| 151 // the time the window is created. | 151 // the time the window is created. |
| 152 aura::PropertyConverter* property_converter = | 152 aura::PropertyConverter* property_converter = |
| 153 window_manager_->property_converter(); | 153 window_manager_->property_converter(); |
| 154 for (auto& property_pair : *properties) { | 154 for (auto& property_pair : *properties) { |
| 155 property_converter->SetPropertyFromTransportValue( | 155 property_converter->SetPropertyFromTransportValue( |
| 156 window, property_pair.first, &property_pair.second); | 156 window, property_pair.first, &property_pair.second); |
| 157 } | 157 } |
| 158 window->Init(ui::LAYER_TEXTURED); | 158 window->Init(ui::LAYER_TEXTURED); |
| 159 window->SetBounds(bounds); | 159 window->SetBounds(bounds); |
| 160 DisconnectedAppHandler::Create(window); |
| 160 | 161 |
| 161 if (container_window) { | 162 if (container_window) { |
| 162 container_window->AddChild(window); | 163 container_window->AddChild(window); |
| 163 } else { | 164 } else { |
| 164 WmWindowAura* root = WmWindowAura::Get(this->root()); | 165 WmWindowAura* root = WmWindowAura::Get(this->root()); |
| 165 gfx::Point origin = | 166 gfx::Point origin = |
| 166 root->ConvertPointToTarget(root->GetRootWindow(), gfx::Point()); | 167 root->ConvertPointToTarget(root->GetRootWindow(), gfx::Point()); |
| 167 origin += display_.bounds().OffsetFromOrigin(); | 168 origin += display_.bounds().OffsetFromOrigin(); |
| 168 gfx::Rect bounds_in_screen(origin, bounds.size()); | 169 gfx::Rect bounds_in_screen(origin, bounds.size()); |
| 169 static_cast<WmWindowAura*>( | 170 static_cast<WmWindowAura*>( |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } else { | 236 } else { |
| 236 width = root()->bounds().width() - 240; | 237 width = root()->bounds().width() - 240; |
| 237 height = root()->bounds().height() - 240; | 238 height = root()->bounds().height() - 240; |
| 238 } | 239 } |
| 239 return gfx::Rect(40 + (window_count_ % 4) * 40, 40 + (window_count_ % 4) * 40, | 240 return gfx::Rect(40 + (window_count_ % 4) * 40, 40 + (window_count_ % 4) * 40, |
| 240 width, height); | 241 width, height); |
| 241 } | 242 } |
| 242 | 243 |
| 243 } // namespace mus | 244 } // namespace mus |
| 244 } // namespace ash | 245 } // namespace ash |
| OLD | NEW |