| 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_impl.h" | 5 #include "mash/wm/window_manager_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "components/mus/common/types.h" | 10 #include "components/mus/common/types.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 return window; | 117 return window; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void WindowManagerImpl::OnTreeChanging(const TreeChangeParams& params) { | 120 void WindowManagerImpl::OnTreeChanging(const TreeChangeParams& params) { |
| 121 DCHECK(state_); | 121 DCHECK(state_); |
| 122 if (state_->WindowIsContainer(params.old_parent)) | 122 if (state_->WindowIsContainer(params.old_parent)) |
| 123 params.target->RemoveObserver(this); | 123 params.target->RemoveObserver(this); |
| 124 else if (state_->WindowIsContainer(params.new_parent)) | 124 else if (state_->WindowIsContainer(params.new_parent)) |
| 125 params.target->AddObserver(this); | 125 params.target->AddObserver(this); |
| 126 |
| 127 if (user_window_observer_) { |
| 128 mus::Window* user_window_container = |
| 129 state_->GetWindowForContainer(mojom::CONTAINER_USER_WINDOWS); |
| 130 if (params.new_parent == user_window_container) |
| 131 user_window_observer_->OnUserWindowAdded(params.target->id()); |
| 132 else if (params.old_parent == user_window_container) |
| 133 user_window_observer_->OnUserWindowRemoved(params.target->id()); |
| 134 } |
| 126 } | 135 } |
| 127 | 136 |
| 128 void WindowManagerImpl::OnWindowEmbeddedAppDisconnected(mus::Window* window) { | 137 void WindowManagerImpl::OnWindowEmbeddedAppDisconnected(mus::Window* window) { |
| 129 window->Destroy(); | 138 window->Destroy(); |
| 130 } | 139 } |
| 131 | 140 |
| 132 void WindowManagerImpl::OpenWindow( | 141 void WindowManagerImpl::OpenWindow( |
| 133 mus::mojom::WindowTreeClientPtr client, | 142 mus::mojom::WindowTreeClientPtr client, |
| 134 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { | 143 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { |
| 135 mus::Window::SharedProperties properties = | 144 mus::Window::SharedProperties properties = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 160 config->normal_client_area_insets = mojo::Insets::From(client_area_insets); | 169 config->normal_client_area_insets = mojo::Insets::From(client_area_insets); |
| 161 | 170 |
| 162 config->maximized_client_area_insets = mojo::Insets::From(client_area_insets); | 171 config->maximized_client_area_insets = mojo::Insets::From(client_area_insets); |
| 163 | 172 |
| 164 config->max_title_bar_button_width = | 173 config->max_title_bar_button_width = |
| 165 NonClientFrameController::GetMaxTitleBarButtonWidth(); | 174 NonClientFrameController::GetMaxTitleBarButtonWidth(); |
| 166 | 175 |
| 167 callback.Run(std::move(config)); | 176 callback.Run(std::move(config)); |
| 168 } | 177 } |
| 169 | 178 |
| 179 void WindowManagerImpl::AddUserWindowObserver( |
| 180 mus::mojom::UserWindowObserverPtr observer) { |
| 181 // TODO(msw): Support multiple observers. |
| 182 user_window_observer_ = std::move(observer); |
| 183 } |
| 184 |
| 185 void WindowManagerImpl::FocusUserWindow(uint32_t window_id) { |
| 186 mus::Window* container = |
| 187 state_->GetWindowForContainer(mojom::CONTAINER_USER_WINDOWS); |
| 188 mus::Window* window = container->GetChildById(window_id); |
| 189 if (window) |
| 190 window->SetFocus(); |
| 191 } |
| 192 |
| 170 bool WindowManagerImpl::OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) { | 193 bool WindowManagerImpl::OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) { |
| 171 // By returning true the bounds of |window| is updated. | 194 // By returning true the bounds of |window| is updated. |
| 172 return true; | 195 return true; |
| 173 } | 196 } |
| 174 | 197 |
| 175 bool WindowManagerImpl::OnWmSetProperty( | 198 bool WindowManagerImpl::OnWmSetProperty( |
| 176 mus::Window* window, | 199 mus::Window* window, |
| 177 const std::string& name, | 200 const std::string& name, |
| 178 scoped_ptr<std::vector<uint8_t>>* new_data) { | 201 scoped_ptr<std::vector<uint8_t>>* new_data) { |
| 179 // TODO(sky): constrain this to set of keys we know about, and allowed | 202 // TODO(sky): constrain this to set of keys we know about, and allowed |
| 180 // values. | 203 // values. |
| 181 return name == mus::mojom::WindowManager::kShowState_Property || | 204 return name == mus::mojom::WindowManager::kShowState_Property || |
| 182 name == mus::mojom::WindowManager::kPreferredSize_Property || | 205 name == mus::mojom::WindowManager::kPreferredSize_Property || |
| 183 name == mus::mojom::WindowManager::kResizeBehavior_Property || | 206 name == mus::mojom::WindowManager::kResizeBehavior_Property || |
| 184 name == mus::mojom::WindowManager::kWindowTitle_Property; | 207 name == mus::mojom::WindowManager::kWindowTitle_Property; |
| 185 } | 208 } |
| 186 | 209 |
| 187 mus::Window* WindowManagerImpl::OnWmCreateTopLevelWindow( | 210 mus::Window* WindowManagerImpl::OnWmCreateTopLevelWindow( |
| 188 std::map<std::string, std::vector<uint8_t>>* properties) { | 211 std::map<std::string, std::vector<uint8_t>>* properties) { |
| 189 return NewTopLevelWindow(properties, nullptr); | 212 return NewTopLevelWindow(properties, nullptr); |
| 190 } | 213 } |
| 191 | 214 |
| 192 } // namespace wm | 215 } // namespace wm |
| 193 } // namespace mash | 216 } // namespace mash |
| OLD | NEW |