OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/bridge/wm_globals_mus.h" | 5 #include "mash/wm/bridge/wm_globals_mus.h" |
6 | 6 |
7 #include "ash/wm/common/window_resizer.h" | 7 #include "ash/wm/common/window_resizer.h" |
8 #include "ash/wm/common/wm_activation_observer.h" | 8 #include "ash/wm/common/wm_activation_observer.h" |
9 #include "ash/wm/common/wm_shell_window_ids.h" | 9 #include "ash/wm/common/wm_shell_window_ids.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "components/mus/common/util.h" | 11 #include "components/mus/common/util.h" |
12 #include "components/mus/public/cpp/window.h" | 12 #include "components/mus/public/cpp/window.h" |
13 #include "components/mus/public/cpp/window_tree_connection.h" | 13 #include "components/mus/public/cpp/window_tree_client.h" |
14 #include "mash/wm/bridge/wm_root_window_controller_mus.h" | 14 #include "mash/wm/bridge/wm_root_window_controller_mus.h" |
15 #include "mash/wm/bridge/wm_window_mus.h" | 15 #include "mash/wm/bridge/wm_window_mus.h" |
16 #include "mash/wm/container_ids.h" | 16 #include "mash/wm/container_ids.h" |
17 #include "mash/wm/drag_window_resizer.h" | 17 #include "mash/wm/drag_window_resizer.h" |
18 #include "mash/wm/public/interfaces/container.mojom.h" | 18 #include "mash/wm/public/interfaces/container.mojom.h" |
19 #include "mash/wm/root_window_controller.h" | 19 #include "mash/wm/root_window_controller.h" |
20 | 20 |
21 namespace mash { | 21 namespace mash { |
22 namespace wm { | 22 namespace wm { |
23 | 23 |
24 WmGlobalsMus::WmGlobalsMus(mus::WindowTreeConnection* connection) | 24 WmGlobalsMus::WmGlobalsMus(mus::WindowTreeClient* client) |
25 : connection_(connection) { | 25 : client_(client) { |
26 connection_->AddObserver(this); | 26 client_->AddObserver(this); |
27 WmGlobals::Set(this); | 27 WmGlobals::Set(this); |
28 } | 28 } |
29 | 29 |
30 WmGlobalsMus::~WmGlobalsMus() { | 30 WmGlobalsMus::~WmGlobalsMus() { |
31 RemoveConnectionObserver(); | 31 RemoveClientObserver(); |
32 WmGlobals::Set(nullptr); | 32 WmGlobals::Set(nullptr); |
33 } | 33 } |
34 | 34 |
35 // static | 35 // static |
36 WmGlobalsMus* WmGlobalsMus::Get() { | 36 WmGlobalsMus* WmGlobalsMus::Get() { |
37 return static_cast<WmGlobalsMus*>(ash::wm::WmGlobals::Get()); | 37 return static_cast<WmGlobalsMus*>(ash::wm::WmGlobals::Get()); |
38 } | 38 } |
39 | 39 |
40 void WmGlobalsMus::AddRootWindowController( | 40 void WmGlobalsMus::AddRootWindowController( |
41 WmRootWindowControllerMus* controller) { | 41 WmRootWindowControllerMus* controller) { |
(...skipping 23 matching lines...) Expand all Loading... |
65 for (WmRootWindowControllerMus* root_window_controller : | 65 for (WmRootWindowControllerMus* root_window_controller : |
66 root_window_controllers_) { | 66 root_window_controllers_) { |
67 if (root_window_controller->GetDisplay().id() == id) | 67 if (root_window_controller->GetDisplay().id() == id) |
68 return root_window_controller; | 68 return root_window_controller; |
69 } | 69 } |
70 NOTREACHED(); | 70 NOTREACHED(); |
71 return nullptr; | 71 return nullptr; |
72 } | 72 } |
73 | 73 |
74 ash::wm::WmWindow* WmGlobalsMus::GetFocusedWindow() { | 74 ash::wm::WmWindow* WmGlobalsMus::GetFocusedWindow() { |
75 return WmWindowMus::Get(connection_->GetFocusedWindow()); | 75 return WmWindowMus::Get(client_->GetFocusedWindow()); |
76 } | 76 } |
77 | 77 |
78 ash::wm::WmWindow* WmGlobalsMus::GetActiveWindow() { | 78 ash::wm::WmWindow* WmGlobalsMus::GetActiveWindow() { |
79 return GetToplevelAncestor(connection_->GetFocusedWindow()); | 79 return GetToplevelAncestor(client_->GetFocusedWindow()); |
80 } | 80 } |
81 | 81 |
82 ash::wm::WmWindow* WmGlobalsMus::GetPrimaryRootWindow() { | 82 ash::wm::WmWindow* WmGlobalsMus::GetPrimaryRootWindow() { |
83 return root_window_controllers_[0]->GetWindow(); | 83 return root_window_controllers_[0]->GetWindow(); |
84 } | 84 } |
85 | 85 |
86 ash::wm::WmWindow* WmGlobalsMus::GetRootWindowForDisplayId(int64_t display_id) { | 86 ash::wm::WmWindow* WmGlobalsMus::GetRootWindowForDisplayId(int64_t display_id) { |
87 return GetRootWindowControllerWithDisplayId(display_id)->GetWindow(); | 87 return GetRootWindowControllerWithDisplayId(display_id)->GetWindow(); |
88 } | 88 } |
89 | 89 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 if (!window) | 187 if (!window) |
188 return false; | 188 return false; |
189 | 189 |
190 for (size_t i = 0; i < kNumActivationContainers; ++i) { | 190 for (size_t i = 0; i < kNumActivationContainers; ++i) { |
191 if (window->local_id() == static_cast<int>(kActivationContainers[i])) | 191 if (window->local_id() == static_cast<int>(kActivationContainers[i])) |
192 return true; | 192 return true; |
193 } | 193 } |
194 return false; | 194 return false; |
195 } | 195 } |
196 | 196 |
197 void WmGlobalsMus::RemoveConnectionObserver() { | 197 void WmGlobalsMus::RemoveClientObserver() { |
198 if (!connection_) | 198 if (!client_) |
199 return; | 199 return; |
200 | 200 |
201 connection_->RemoveObserver(this); | 201 client_->RemoveObserver(this); |
202 connection_ = nullptr; | 202 client_ = nullptr; |
203 } | 203 } |
204 | 204 |
205 // TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114. | 205 // TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114. |
206 void WmGlobalsMus::OnWindowTreeFocusChanged(mus::Window* gained_focus, | 206 void WmGlobalsMus::OnWindowTreeFocusChanged(mus::Window* gained_focus, |
207 mus::Window* lost_focus) { | 207 mus::Window* lost_focus) { |
208 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus); | 208 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus); |
209 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus); | 209 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus); |
210 if (gained_active == lost_active) | 210 if (gained_active == lost_active) |
211 return; | 211 return; |
212 | 212 |
213 FOR_EACH_OBSERVER(ash::wm::WmActivationObserver, activation_observers_, | 213 FOR_EACH_OBSERVER(ash::wm::WmActivationObserver, activation_observers_, |
214 OnWindowActivated(gained_active, lost_active)); | 214 OnWindowActivated(gained_active, lost_active)); |
215 } | 215 } |
216 | 216 |
217 void WmGlobalsMus::OnWillDestroyConnection( | 217 void WmGlobalsMus::OnWillDestroyClient( |
218 mus::WindowTreeConnection* connection) { | 218 mus::WindowTreeClient* client) { |
219 DCHECK_EQ(connection, connection_); | 219 DCHECK_EQ(client, client_); |
220 RemoveConnectionObserver(); | 220 RemoveClientObserver(); |
221 } | 221 } |
222 | 222 |
223 } // namespace wm | 223 } // namespace wm |
224 } // namespace mash | 224 } // namespace mash |
OLD | NEW |