| OLD | NEW |
| 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 "mash/wm/window_manager.h" | 5 #include "mash/wm/window_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "ash/public/interfaces/container.mojom.h" |
| 11 #include "ash/wm/common/container_finder.h" | 12 #include "ash/wm/common/container_finder.h" |
| 12 #include "components/mus/common/types.h" | 13 #include "components/mus/common/types.h" |
| 13 #include "components/mus/public/cpp/property_type_converters.h" | 14 #include "components/mus/public/cpp/property_type_converters.h" |
| 14 #include "components/mus/public/cpp/window.h" | 15 #include "components/mus/public/cpp/window.h" |
| 15 #include "components/mus/public/cpp/window_property.h" | 16 #include "components/mus/public/cpp/window_property.h" |
| 16 #include "components/mus/public/cpp/window_tree_client.h" | 17 #include "components/mus/public/cpp/window_tree_client.h" |
| 17 #include "components/mus/public/interfaces/input_events.mojom.h" | 18 #include "components/mus/public/interfaces/input_events.mojom.h" |
| 18 #include "components/mus/public/interfaces/mus_constants.mojom.h" | 19 #include "components/mus/public/interfaces/mus_constants.mojom.h" |
| 19 #include "components/mus/public/interfaces/window_manager.mojom.h" | 20 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 20 #include "mash/wm/bridge/wm_window_mus.h" | 21 #include "mash/wm/bridge/wm_window_mus.h" |
| 21 #include "mash/wm/non_client_frame_controller.h" | 22 #include "mash/wm/non_client_frame_controller.h" |
| 22 #include "mash/wm/property_util.h" | 23 #include "mash/wm/property_util.h" |
| 23 #include "mash/wm/public/interfaces/container.mojom.h" | |
| 24 #include "mash/wm/root_window_controller.h" | 24 #include "mash/wm/root_window_controller.h" |
| 25 | 25 |
| 26 namespace mash { | 26 namespace mash { |
| 27 namespace wm { | 27 namespace wm { |
| 28 | 28 |
| 29 WindowManager::WindowManager() | 29 WindowManager::WindowManager() |
| 30 : root_controller_(nullptr), | 30 : root_controller_(nullptr), |
| 31 window_manager_client_(nullptr), | 31 window_manager_client_(nullptr), |
| 32 binding_(this) {} | 32 binding_(this) {} |
| 33 | 33 |
| 34 WindowManager::~WindowManager() { | 34 WindowManager::~WindowManager() { |
| 35 } | 35 } |
| 36 | 36 |
| 37 void WindowManager::Initialize(RootWindowController* root_controller, | 37 void WindowManager::Initialize(RootWindowController* root_controller, |
| 38 session::mojom::Session* session) { | 38 session::mojom::Session* session) { |
| 39 DCHECK(root_controller); | 39 DCHECK(root_controller); |
| 40 DCHECK(!root_controller_); | 40 DCHECK(!root_controller_); |
| 41 root_controller_ = root_controller; | 41 root_controller_ = root_controller; |
| 42 | 42 |
| 43 // Observe all the containers so that windows can be added to/removed from the | 43 // Observe all the containers so that windows can be added to/removed from the |
| 44 // |disconnected_app_handler_|. | 44 // |disconnected_app_handler_|. |
| 45 int count = static_cast<int>(mojom::Container::COUNT); | 45 int count = static_cast<int>(ash::mojom::Container::COUNT); |
| 46 for (int id = static_cast<int>(mojom::Container::ROOT) + 1; id < count; | 46 for (int id = static_cast<int>(ash::mojom::Container::ROOT) + 1; id < count; |
| 47 ++id) { | 47 ++id) { |
| 48 mus::Window* container = root_controller_->GetWindowForContainer( | 48 mus::Window* container = root_controller_->GetWindowForContainer( |
| 49 static_cast<mojom::Container>(id)); | 49 static_cast<ash::mojom::Container>(id)); |
| 50 Add(container); | 50 Add(container); |
| 51 | 51 |
| 52 // Add any pre-existing windows in the container to | 52 // Add any pre-existing windows in the container to |
| 53 // |disconnected_app_handler_|. | 53 // |disconnected_app_handler_|. |
| 54 for (auto child : container->children()) { | 54 for (auto child : container->children()) { |
| 55 if (!root_controller_->WindowIsContainer(child)) | 55 if (!root_controller_->WindowIsContainer(child)) |
| 56 disconnected_app_handler_.Add(child); | 56 disconnected_app_handler_.Add(child); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 86 GetWindowType(*properties) == mus::mojom::WindowType::WINDOW || | 86 GetWindowType(*properties) == mus::mojom::WindowType::WINDOW || |
| 87 GetWindowType(*properties) == mus::mojom::WindowType::PANEL; | 87 GetWindowType(*properties) == mus::mojom::WindowType::PANEL; |
| 88 if (provide_non_client_frame) | 88 if (provide_non_client_frame) |
| 89 (*properties)[mus::mojom::kWaitForUnderlay_Property].clear(); | 89 (*properties)[mus::mojom::kWaitForUnderlay_Property].clear(); |
| 90 | 90 |
| 91 // TODO(sky): constrain and validate properties before passing to server. | 91 // TODO(sky): constrain and validate properties before passing to server. |
| 92 mus::Window* window = root->window_tree()->NewWindow(properties); | 92 mus::Window* window = root->window_tree()->NewWindow(properties); |
| 93 window->SetBounds(CalculateDefaultBounds(window)); | 93 window->SetBounds(CalculateDefaultBounds(window)); |
| 94 | 94 |
| 95 mus::Window* container_window = nullptr; | 95 mus::Window* container_window = nullptr; |
| 96 if (window->HasSharedProperty(mojom::kWindowContainer_Property)) { | 96 if (window->HasSharedProperty(ash::mojom::kWindowContainer_Property)) { |
| 97 container_window = | 97 container_window = |
| 98 root_controller_->GetWindowForContainer(GetRequestedContainer(window)); | 98 root_controller_->GetWindowForContainer(GetRequestedContainer(window)); |
| 99 } else { | 99 } else { |
| 100 // TODO(sky): window->bounds() isn't quite right. | 100 // TODO(sky): window->bounds() isn't quite right. |
| 101 container_window = WmWindowMus::GetMusWindow( | 101 container_window = WmWindowMus::GetMusWindow( |
| 102 ash::wm::GetDefaultParent(WmWindowMus::Get(root_controller_->root()), | 102 ash::wm::GetDefaultParent(WmWindowMus::Get(root_controller_->root()), |
| 103 WmWindowMus::Get(window), window->bounds())); | 103 WmWindowMus::Get(window), window->bounds())); |
| 104 } | 104 } |
| 105 DCHECK(root_controller_->WindowIsContainer(container_window)); | 105 DCHECK(root_controller_->WindowIsContainer(container_window)); |
| 106 | 106 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 SetWindowIsJanky(window, janky); | 197 SetWindowIsJanky(window, janky); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void WindowManager::OnAccelerator(uint32_t id, const ui::Event& event) { | 200 void WindowManager::OnAccelerator(uint32_t id, const ui::Event& event) { |
| 201 root_controller_->OnAccelerator(id, std::move(event)); | 201 root_controller_->OnAccelerator(id, std::move(event)); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void WindowManager::ScreenlockStateChanged(bool locked) { | 204 void WindowManager::ScreenlockStateChanged(bool locked) { |
| 205 // Hide USER_PRIVATE_CONTAINER windows when the screen is locked. | 205 // Hide USER_PRIVATE_CONTAINER windows when the screen is locked. |
| 206 mus::Window* window = root_controller_->GetWindowForContainer( | 206 mus::Window* window = root_controller_->GetWindowForContainer( |
| 207 mash::wm::mojom::Container::USER_PRIVATE); | 207 ash::mojom::Container::USER_PRIVATE); |
| 208 window->SetVisible(!locked); | 208 window->SetVisible(!locked); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace wm | 211 } // namespace wm |
| 212 } // namespace mash | 212 } // namespace mash |
| OLD | NEW |