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/user_window_controller_impl.h" | 5 #include "ash/mus/user_window_controller_impl.h" |
6 | 6 |
| 7 #include "ash/common/shell_window_ids.h" |
| 8 #include "ash/mus/bridge/wm_window_mus.h" |
7 #include "ash/mus/property_util.h" | 9 #include "ash/mus/property_util.h" |
8 #include "ash/mus/root_window_controller.h" | 10 #include "ash/mus/root_window_controller.h" |
9 #include "ash/public/interfaces/container.mojom.h" | 11 #include "ash/public/interfaces/container.mojom.h" |
10 #include "components/mus/public/cpp/property_type_converters.h" | 12 #include "components/mus/public/cpp/property_type_converters.h" |
11 #include "components/mus/public/cpp/window.h" | 13 #include "components/mus/public/cpp/window.h" |
12 #include "components/mus/public/cpp/window_property.h" | 14 #include "components/mus/public/cpp/window_property.h" |
13 #include "components/mus/public/cpp/window_tree_client.h" | 15 #include "components/mus/public/cpp/window_tree_client.h" |
14 #include "mojo/common/common_type_converters.h" | 16 #include "mojo/common/common_type_converters.h" |
15 #include "ui/resources/grit/ui_resources.h" | 17 #include "ui/resources/grit/ui_resources.h" |
16 | 18 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 131 |
130 ::mus::Window* UserWindowControllerImpl::GetUserWindowById(uint32_t id) { | 132 ::mus::Window* UserWindowControllerImpl::GetUserWindowById(uint32_t id) { |
131 for (::mus::Window* window : GetUserWindowContainer()->children()) { | 133 for (::mus::Window* window : GetUserWindowContainer()->children()) { |
132 if (window->GetLocalProperty(kUserWindowIdKey) == id) | 134 if (window->GetLocalProperty(kUserWindowIdKey) == id) |
133 return window; | 135 return window; |
134 } | 136 } |
135 return nullptr; | 137 return nullptr; |
136 } | 138 } |
137 | 139 |
138 ::mus::Window* UserWindowControllerImpl::GetUserWindowContainer() const { | 140 ::mus::Window* UserWindowControllerImpl::GetUserWindowContainer() const { |
139 return root_controller_->GetWindowForContainer( | 141 WmWindowMus* window = root_controller_->GetWindowByShellWindowId( |
140 mojom::Container::USER_PRIVATE_WINDOWS); | 142 kShellWindowId_DefaultContainer); |
| 143 return window ? window->mus_window() : nullptr; |
141 } | 144 } |
142 | 145 |
143 void UserWindowControllerImpl::OnTreeChanging(const TreeChangeParams& params) { | 146 void UserWindowControllerImpl::OnTreeChanging(const TreeChangeParams& params) { |
144 DCHECK(root_controller_); | 147 DCHECK(root_controller_); |
145 if (params.new_parent == GetUserWindowContainer()) { | 148 if (params.new_parent == GetUserWindowContainer()) { |
146 params.target->AddObserver(window_property_observer_.get()); | 149 params.target->AddObserver(window_property_observer_.get()); |
147 AssignIdIfNecessary(params.target); | 150 AssignIdIfNecessary(params.target); |
148 if (user_window_observer_) | 151 if (user_window_observer_) |
149 user_window_observer_->OnUserWindowAdded(GetUserWindow(params.target)); | 152 user_window_observer_->OnUserWindowAdded(GetUserWindow(params.target)); |
150 } else if (params.old_parent == GetUserWindowContainer()) { | 153 } else if (params.old_parent == GetUserWindowContainer()) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 199 } |
197 | 200 |
198 void UserWindowControllerImpl::FocusUserWindow(uint32_t window_id) { | 201 void UserWindowControllerImpl::FocusUserWindow(uint32_t window_id) { |
199 ::mus::Window* window = GetUserWindowById(window_id); | 202 ::mus::Window* window = GetUserWindowById(window_id); |
200 if (window) | 203 if (window) |
201 window->SetFocus(); | 204 window->SetFocus(); |
202 } | 205 } |
203 | 206 |
204 } // namespace mus | 207 } // namespace mus |
205 } // namespace ash | 208 } // namespace ash |
OLD | NEW |