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 "ash/mus/window_manager.h" | 5 #include "ash/mus/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/common/shell_window_ids.h" |
11 #include "ash/common/wm/container_finder.h" | 12 #include "ash/common/wm/container_finder.h" |
12 #include "ash/mus/bridge/wm_window_mus.h" | 13 #include "ash/mus/bridge/wm_window_mus.h" |
13 #include "ash/mus/non_client_frame_controller.h" | 14 #include "ash/mus/non_client_frame_controller.h" |
14 #include "ash/mus/property_util.h" | 15 #include "ash/mus/property_util.h" |
15 #include "ash/mus/root_window_controller.h" | 16 #include "ash/mus/root_window_controller.h" |
16 #include "ash/public/interfaces/container.mojom.h" | 17 #include "ash/public/interfaces/container.mojom.h" |
17 #include "components/mus/common/types.h" | 18 #include "components/mus/common/types.h" |
18 #include "components/mus/public/cpp/property_type_converters.h" | 19 #include "components/mus/public/cpp/property_type_converters.h" |
19 #include "components/mus/public/cpp/window.h" | 20 #include "components/mus/public/cpp/window.h" |
20 #include "components/mus/public/cpp/window_property.h" | 21 #include "components/mus/public/cpp/window_property.h" |
(...skipping 13 matching lines...) Expand all Loading... |
34 WindowManager::~WindowManager() {} | 35 WindowManager::~WindowManager() {} |
35 | 36 |
36 void WindowManager::Initialize(RootWindowController* root_controller, | 37 void WindowManager::Initialize(RootWindowController* root_controller, |
37 mash::session::mojom::Session* session) { | 38 mash::session::mojom::Session* session) { |
38 DCHECK(root_controller); | 39 DCHECK(root_controller); |
39 DCHECK(!root_controller_); | 40 DCHECK(!root_controller_); |
40 root_controller_ = root_controller; | 41 root_controller_ = root_controller; |
41 | 42 |
42 // 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 |
43 // |disconnected_app_handler_|. | 44 // |disconnected_app_handler_|. |
44 int count = static_cast<int>(mojom::Container::COUNT); | 45 WmWindowMus* root = WmWindowMus::Get(root_controller_->root()); |
45 for (int id = static_cast<int>(mojom::Container::ROOT) + 1; id < count; | 46 for (int shell_window_id = kShellWindowId_Min; |
46 ++id) { | 47 shell_window_id < kShellWindowId_Max; ++shell_window_id) { |
47 ::mus::Window* container = root_controller_->GetWindowForContainer( | 48 // kShellWindowId_VirtualKeyboardContainer is lazily created. |
48 static_cast<mojom::Container>(id)); | 49 // TODO(sky): http://crbug.com/616909 . |
49 Add(container); | 50 // kShellWindowId_PhantomWindow is not a container, but a window. |
| 51 if (shell_window_id == kShellWindowId_VirtualKeyboardContainer || |
| 52 shell_window_id == kShellWindowId_PhantomWindow) |
| 53 continue; |
| 54 |
| 55 // kShellWindowId_MouseCursorContainer is chromeos specific. |
| 56 #if !defined(OS_CHROMEOS) |
| 57 if (shell_window_id == kShellWindowId_MouseCursorContainer) |
| 58 continue; |
| 59 #endif |
| 60 |
| 61 WmWindowMus* container = WmWindowMus::AsWmWindowMus( |
| 62 root->GetChildByShellWindowId(shell_window_id)); |
| 63 Add(container->mus_window()); |
50 | 64 |
51 // Add any pre-existing windows in the container to | 65 // Add any pre-existing windows in the container to |
52 // |disconnected_app_handler_|. | 66 // |disconnected_app_handler_|. |
53 for (auto child : container->children()) { | 67 for (::mus::Window* child : container->mus_window()->children()) { |
54 if (!root_controller_->WindowIsContainer(child)) | 68 if (!root_controller_->WindowIsContainer(child)) |
55 disconnected_app_handler_.Add(child); | 69 disconnected_app_handler_.Add(child); |
56 } | 70 } |
57 } | 71 } |
58 | 72 |
59 // The insets are roughly what is needed by CustomFrameView. The expectation | 73 // The insets are roughly what is needed by CustomFrameView. The expectation |
60 // is at some point we'll write our own NonClientFrameView and get the insets | 74 // is at some point we'll write our own NonClientFrameView and get the insets |
61 // from it. | 75 // from it. |
62 ::mus::mojom::FrameDecorationValuesPtr frame_decoration_values = | 76 ::mus::mojom::FrameDecorationValuesPtr frame_decoration_values = |
63 ::mus::mojom::FrameDecorationValues::New(); | 77 ::mus::mojom::FrameDecorationValues::New(); |
(...skipping 21 matching lines...) Expand all Loading... |
85 GetWindowType(*properties) == ::mus::mojom::WindowType::WINDOW || | 99 GetWindowType(*properties) == ::mus::mojom::WindowType::WINDOW || |
86 GetWindowType(*properties) == ::mus::mojom::WindowType::PANEL; | 100 GetWindowType(*properties) == ::mus::mojom::WindowType::PANEL; |
87 if (provide_non_client_frame) | 101 if (provide_non_client_frame) |
88 (*properties)[::mus::mojom::kWaitForUnderlay_Property].clear(); | 102 (*properties)[::mus::mojom::kWaitForUnderlay_Property].clear(); |
89 | 103 |
90 // TODO(sky): constrain and validate properties before passing to server. | 104 // TODO(sky): constrain and validate properties before passing to server. |
91 ::mus::Window* window = root->window_tree()->NewWindow(properties); | 105 ::mus::Window* window = root->window_tree()->NewWindow(properties); |
92 window->SetBounds(CalculateDefaultBounds(window)); | 106 window->SetBounds(CalculateDefaultBounds(window)); |
93 | 107 |
94 ::mus::Window* container_window = nullptr; | 108 ::mus::Window* container_window = nullptr; |
95 if (window->HasSharedProperty(mojom::kWindowContainer_Property)) { | 109 mojom::Container container; |
96 container_window = | 110 if (GetRequestedContainer(window, &container)) { |
97 root_controller_->GetWindowForContainer(GetRequestedContainer(window)); | 111 container_window = root_controller_->GetWindowForContainer(container); |
98 } else { | 112 } else { |
99 // TODO(sky): window->bounds() isn't quite right. | 113 // TODO(sky): window->bounds() isn't quite right. |
100 container_window = WmWindowMus::GetMusWindow( | 114 container_window = WmWindowMus::GetMusWindow( |
101 wm::GetDefaultParent(WmWindowMus::Get(root_controller_->root()), | 115 wm::GetDefaultParent(WmWindowMus::Get(root_controller_->root()), |
102 WmWindowMus::Get(window), window->bounds())); | 116 WmWindowMus::Get(window), window->bounds())); |
103 } | 117 } |
104 DCHECK(root_controller_->WindowIsContainer(container_window)); | 118 DCHECK(root_controller_->WindowIsContainer(container_window)); |
105 | 119 |
106 if (provide_non_client_frame) { | 120 if (provide_non_client_frame) { |
107 NonClientFrameController::Create(root_controller_->GetConnector(), | 121 NonClientFrameController::Create(root_controller_->GetConnector(), |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 bool janky) { | 208 bool janky) { |
195 for (auto window : client_windows) | 209 for (auto window : client_windows) |
196 SetWindowIsJanky(window, janky); | 210 SetWindowIsJanky(window, janky); |
197 } | 211 } |
198 | 212 |
199 void WindowManager::OnAccelerator(uint32_t id, const ui::Event& event) { | 213 void WindowManager::OnAccelerator(uint32_t id, const ui::Event& event) { |
200 root_controller_->OnAccelerator(id, std::move(event)); | 214 root_controller_->OnAccelerator(id, std::move(event)); |
201 } | 215 } |
202 | 216 |
203 void WindowManager::ScreenlockStateChanged(bool locked) { | 217 void WindowManager::ScreenlockStateChanged(bool locked) { |
204 // Hide USER_PRIVATE_CONTAINER windows when the screen is locked. | 218 WmWindowMus* non_lock_screen_containers_container = |
205 ::mus::Window* window = | 219 root_controller_->GetWindowByShellWindowId( |
206 root_controller_->GetWindowForContainer(mojom::Container::USER_PRIVATE); | 220 kShellWindowId_NonLockScreenContainersContainer); |
207 window->SetVisible(!locked); | 221 non_lock_screen_containers_container->mus_window()->SetVisible(!locked); |
208 } | 222 } |
209 | 223 |
210 } // namespace mus | 224 } // namespace mus |
211 } // namespace ash | 225 } // namespace ash |
OLD | NEW |