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 WmWindowMus* container = WmWindowMus::AsWmWindowMus( | |
56 root->GetChildByShellWindowId(shell_window_id)); | |
57 Add(container->mus_window()); | |
50 | 58 |
51 // Add any pre-existing windows in the container to | 59 // Add any pre-existing windows in the container to |
52 // |disconnected_app_handler_|. | 60 // |disconnected_app_handler_|. |
53 for (auto child : container->children()) { | 61 for (auto child : container->mus_window()->children()) { |
James Cook
2016/06/03 00:24:58
nit: instead of "auto", the actual type (mus::Wind
sky
2016/06/03 03:07:03
Done.
| |
54 if (!root_controller_->WindowIsContainer(child)) | 62 if (!root_controller_->WindowIsContainer(child)) |
55 disconnected_app_handler_.Add(child); | 63 disconnected_app_handler_.Add(child); |
56 } | 64 } |
57 } | 65 } |
58 | 66 |
59 // The insets are roughly what is needed by CustomFrameView. The expectation | 67 // 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 | 68 // is at some point we'll write our own NonClientFrameView and get the insets |
61 // from it. | 69 // from it. |
62 ::mus::mojom::FrameDecorationValuesPtr frame_decoration_values = | 70 ::mus::mojom::FrameDecorationValuesPtr frame_decoration_values = |
63 ::mus::mojom::FrameDecorationValues::New(); | 71 ::mus::mojom::FrameDecorationValues::New(); |
(...skipping 21 matching lines...) Expand all Loading... | |
85 GetWindowType(*properties) == ::mus::mojom::WindowType::WINDOW || | 93 GetWindowType(*properties) == ::mus::mojom::WindowType::WINDOW || |
86 GetWindowType(*properties) == ::mus::mojom::WindowType::PANEL; | 94 GetWindowType(*properties) == ::mus::mojom::WindowType::PANEL; |
87 if (provide_non_client_frame) | 95 if (provide_non_client_frame) |
88 (*properties)[::mus::mojom::kWaitForUnderlay_Property].clear(); | 96 (*properties)[::mus::mojom::kWaitForUnderlay_Property].clear(); |
89 | 97 |
90 // TODO(sky): constrain and validate properties before passing to server. | 98 // TODO(sky): constrain and validate properties before passing to server. |
91 ::mus::Window* window = root->window_tree()->NewWindow(properties); | 99 ::mus::Window* window = root->window_tree()->NewWindow(properties); |
92 window->SetBounds(CalculateDefaultBounds(window)); | 100 window->SetBounds(CalculateDefaultBounds(window)); |
93 | 101 |
94 ::mus::Window* container_window = nullptr; | 102 ::mus::Window* container_window = nullptr; |
95 if (window->HasSharedProperty(mojom::kWindowContainer_Property)) { | 103 mojom::Container container; |
96 container_window = | 104 if (GetRequestedContainer(window, &container)) { |
97 root_controller_->GetWindowForContainer(GetRequestedContainer(window)); | 105 container_window = root_controller_->GetWindowForContainer(container); |
98 } else { | 106 } else { |
99 // TODO(sky): window->bounds() isn't quite right. | 107 // TODO(sky): window->bounds() isn't quite right. |
100 container_window = WmWindowMus::GetMusWindow( | 108 container_window = WmWindowMus::GetMusWindow( |
101 wm::GetDefaultParent(WmWindowMus::Get(root_controller_->root()), | 109 wm::GetDefaultParent(WmWindowMus::Get(root_controller_->root()), |
102 WmWindowMus::Get(window), window->bounds())); | 110 WmWindowMus::Get(window), window->bounds())); |
103 } | 111 } |
104 DCHECK(root_controller_->WindowIsContainer(container_window)); | 112 DCHECK(root_controller_->WindowIsContainer(container_window)); |
105 | 113 |
106 if (provide_non_client_frame) { | 114 if (provide_non_client_frame) { |
107 NonClientFrameController::Create(root_controller_->GetConnector(), | 115 NonClientFrameController::Create(root_controller_->GetConnector(), |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 bool janky) { | 202 bool janky) { |
195 for (auto window : client_windows) | 203 for (auto window : client_windows) |
196 SetWindowIsJanky(window, janky); | 204 SetWindowIsJanky(window, janky); |
197 } | 205 } |
198 | 206 |
199 void WindowManager::OnAccelerator(uint32_t id, const ui::Event& event) { | 207 void WindowManager::OnAccelerator(uint32_t id, const ui::Event& event) { |
200 root_controller_->OnAccelerator(id, std::move(event)); | 208 root_controller_->OnAccelerator(id, std::move(event)); |
201 } | 209 } |
202 | 210 |
203 void WindowManager::ScreenlockStateChanged(bool locked) { | 211 void WindowManager::ScreenlockStateChanged(bool locked) { |
204 // Hide USER_PRIVATE_CONTAINER windows when the screen is locked. | 212 WmWindowMus* non_lock_screen_containers_container = |
205 ::mus::Window* window = | 213 root_controller_->GetWindowByShellWindowId( |
206 root_controller_->GetWindowForContainer(mojom::Container::USER_PRIVATE); | 214 kShellWindowId_NonLockScreenContainersContainer); |
207 window->SetVisible(!locked); | 215 non_lock_screen_containers_container->mus_window()->SetVisible(!locked); |
James Cook
2016/06/03 00:24:58
I think this is OK, but I'm not 100% sure. In clas
sky
2016/06/03 03:07:03
Agreed. It's hard to test this given we don't have
| |
208 } | 216 } |
209 | 217 |
210 } // namespace mus | 218 } // namespace mus |
211 } // namespace ash | 219 } // namespace ash |
OLD | NEW |