Chromium Code Reviews| 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 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 for (auto child : container->children()) | 37 for (auto child : container->children()) |
| 38 child->RemoveObserver(this); | 38 child->RemoveObserver(this); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 void WindowManager::Initialize(RootWindowController* root_controller, | 42 void WindowManager::Initialize(RootWindowController* root_controller, |
| 43 session::mojom::Session* session) { | 43 session::mojom::Session* session) { |
| 44 DCHECK(root_controller); | 44 DCHECK(root_controller); |
| 45 DCHECK(!root_controller_); | 45 DCHECK(!root_controller_); |
| 46 root_controller_ = root_controller; | 46 root_controller_ = root_controller; |
| 47 // The children of the root are considered containers. | 47 |
| 48 for (auto container : root_controller_->root()->children()) { | 48 // Observe all the containers and their child windows. |
|
sky
2016/04/22 15:23:42
Why do you need to observer the child windows?
sky
2016/04/22 15:25:40
Never mind this comment, I just saw your comments
sadrul
2016/04/22 16:06:05
Done (introduced a DisconnectedAppHandler). Change
| |
| 49 int count = static_cast<int>(mojom::Container::COUNT); | |
| 50 for (int id = 1; id < count; ++id) { | |
|
sky
2016/04/22 15:23:42
1 -> ROOT + 1 ?
sadrul
2016/04/22 16:06:06
Done.
| |
| 51 mus::Window* container = root_controller_->GetWindowForContainer( | |
| 52 static_cast<mojom::Container>(id)); | |
| 49 container->AddObserver(this); | 53 container->AddObserver(this); |
| 50 for (auto child : container->children()) | 54 for (auto child : container->children()) { |
| 51 child->AddObserver(this); | 55 if (!root_controller_->WindowIsContainer(child)) |
| 56 child->AddObserver(this); | |
| 57 } | |
| 52 } | 58 } |
| 53 | 59 |
| 54 // The insets are roughly what is needed by CustomFrameView. The expectation | 60 // The insets are roughly what is needed by CustomFrameView. The expectation |
| 55 // is at some point we'll write our own NonClientFrameView and get the insets | 61 // is at some point we'll write our own NonClientFrameView and get the insets |
| 56 // from it. | 62 // from it. |
| 57 mus::mojom::FrameDecorationValuesPtr frame_decoration_values = | 63 mus::mojom::FrameDecorationValuesPtr frame_decoration_values = |
| 58 mus::mojom::FrameDecorationValues::New(); | 64 mus::mojom::FrameDecorationValues::New(); |
| 59 const gfx::Insets client_area_insets = | 65 const gfx::Insets client_area_insets = |
| 60 NonClientFrameController::GetPreferredClientAreaInsets(); | 66 NonClientFrameController::GetPreferredClientAreaInsets(); |
| 61 frame_decoration_values->normal_client_area_insets = | 67 frame_decoration_values->normal_client_area_insets = |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 const bool provide_non_client_frame = | 110 const bool provide_non_client_frame = |
| 105 GetWindowType(*properties) == mus::mojom::WindowType::WINDOW; | 111 GetWindowType(*properties) == mus::mojom::WindowType::WINDOW; |
| 106 if (provide_non_client_frame) | 112 if (provide_non_client_frame) |
| 107 (*properties)[mus::mojom::kWaitForUnderlay_Property].clear(); | 113 (*properties)[mus::mojom::kWaitForUnderlay_Property].clear(); |
| 108 | 114 |
| 109 // TODO(sky): constrain and validate properties before passing to server. | 115 // TODO(sky): constrain and validate properties before passing to server. |
| 110 mus::Window* window = root->connection()->NewWindow(properties); | 116 mus::Window* window = root->connection()->NewWindow(properties); |
| 111 window->SetBounds(CalculateDefaultBounds(window)); | 117 window->SetBounds(CalculateDefaultBounds(window)); |
| 112 | 118 |
| 113 mojom::Container container = GetRequestedContainer(window); | 119 mojom::Container container = GetRequestedContainer(window); |
| 114 root_controller_->GetWindowForContainer(container)->AddChild(window); | 120 mus::Window* container_window = |
| 121 root_controller_->GetWindowForContainer(container); | |
| 122 DCHECK(root_controller_->WindowIsContainer(container_window)); | |
| 123 container_window->AddChild(window); | |
| 115 | 124 |
| 116 if (provide_non_client_frame) { | 125 if (provide_non_client_frame) { |
| 117 NonClientFrameController::Create(root_controller_->GetConnector(), window, | 126 NonClientFrameController::Create(root_controller_->GetConnector(), window, |
| 118 root_controller_->window_manager_client()); | 127 root_controller_->window_manager_client()); |
| 119 } | 128 } |
| 120 | 129 |
| 121 root_controller_->IncrementWindowCount(); | 130 root_controller_->IncrementWindowCount(); |
| 122 | 131 |
| 123 return window; | 132 return window; |
| 124 } | 133 } |
| 125 | 134 |
| 126 void WindowManager::OnTreeChanging(const TreeChangeParams& params) { | 135 void WindowManager::OnTreeChanging(const TreeChangeParams& params) { |
| 127 DCHECK(root_controller_); | 136 DCHECK(root_controller_); |
| 128 if (root_controller_->WindowIsContainer(params.old_parent)) | 137 if (params.old_parent == params.receiver && |
| 138 root_controller_->WindowIsContainer(params.old_parent)) | |
| 129 params.target->RemoveObserver(this); | 139 params.target->RemoveObserver(this); |
| 130 else if (root_controller_->WindowIsContainer(params.new_parent)) | 140 |
| 141 if (params.new_parent == params.receiver && | |
| 142 root_controller_->WindowIsContainer(params.new_parent)) | |
| 131 params.target->AddObserver(this); | 143 params.target->AddObserver(this); |
| 132 } | 144 } |
| 133 | 145 |
| 134 void WindowManager::OnWindowEmbeddedAppDisconnected(mus::Window* window) { | 146 void WindowManager::OnWindowEmbeddedAppDisconnected(mus::Window* window) { |
| 135 window->Destroy(); | 147 window->Destroy(); |
| 136 } | 148 } |
| 137 | 149 |
| 138 void WindowManager::SetWindowManagerClient(mus::WindowManagerClient* client) { | 150 void WindowManager::SetWindowManagerClient(mus::WindowManagerClient* client) { |
| 139 window_manager_client_ = client; | 151 window_manager_client_ = client; |
| 140 } | 152 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 168 | 180 |
| 169 void WindowManager::ScreenlockStateChanged(bool locked) { | 181 void WindowManager::ScreenlockStateChanged(bool locked) { |
| 170 // Hide USER_PRIVATE windows when the screen is locked. | 182 // Hide USER_PRIVATE windows when the screen is locked. |
| 171 mus::Window* window = root_controller_->GetWindowForContainer( | 183 mus::Window* window = root_controller_->GetWindowForContainer( |
| 172 mash::wm::mojom::Container::USER_PRIVATE); | 184 mash::wm::mojom::Container::USER_PRIVATE); |
| 173 window->SetVisible(!locked); | 185 window->SetVisible(!locked); |
| 174 } | 186 } |
| 175 | 187 |
| 176 } // namespace wm | 188 } // namespace wm |
| 177 } // namespace mash | 189 } // namespace mash |
| OLD | NEW |