| 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::GetRootWindowForDisplayId(int64_t display_id) { | 82 ash::wm::WmWindow* WmGlobalsMus::GetRootWindowForDisplayId(int64_t display_id) { |
| 83 return GetRootWindowControllerWithDisplayId(display_id)->GetWindow(); | 83 return GetRootWindowControllerWithDisplayId(display_id)->GetWindow(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 ash::wm::WmWindow* WmGlobalsMus::GetRootWindowForNewWindows() { | 86 ash::wm::WmWindow* WmGlobalsMus::GetRootWindowForNewWindows() { |
| 87 NOTIMPLEMENTED(); | 87 NOTIMPLEMENTED(); |
| 88 return root_window_controllers_[0]->GetWindow(); | 88 return root_window_controllers_[0]->GetWindow(); |
| 89 } | 89 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 if (!window) | 178 if (!window) |
| 179 return false; | 179 return false; |
| 180 | 180 |
| 181 for (size_t i = 0; i < kNumActivationContainers; ++i) { | 181 for (size_t i = 0; i < kNumActivationContainers; ++i) { |
| 182 if (window->local_id() == static_cast<int>(kActivationContainers[i])) | 182 if (window->local_id() == static_cast<int>(kActivationContainers[i])) |
| 183 return true; | 183 return true; |
| 184 } | 184 } |
| 185 return false; | 185 return false; |
| 186 } | 186 } |
| 187 | 187 |
| 188 void WmGlobalsMus::RemoveConnectionObserver() { | 188 void WmGlobalsMus::RemoveClientObserver() { |
| 189 if (!connection_) | 189 if (!client_) |
| 190 return; | 190 return; |
| 191 | 191 |
| 192 connection_->RemoveObserver(this); | 192 client_->RemoveObserver(this); |
| 193 connection_ = nullptr; | 193 client_ = nullptr; |
| 194 } | 194 } |
| 195 | 195 |
| 196 void WmGlobalsMus::OnWindowTreeFocusChanged(mus::Window* gained_focus, | 196 void WmGlobalsMus::OnWindowTreeFocusChanged(mus::Window* gained_focus, |
| 197 mus::Window* lost_focus) { | 197 mus::Window* lost_focus) { |
| 198 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus); | 198 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus); |
| 199 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus); | 199 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus); |
| 200 if (gained_active == lost_active) | 200 if (gained_active == lost_active) |
| 201 return; | 201 return; |
| 202 | 202 |
| 203 FOR_EACH_OBSERVER(ash::wm::WmActivationObserver, activation_observers_, | 203 FOR_EACH_OBSERVER(ash::wm::WmActivationObserver, activation_observers_, |
| 204 OnWindowActivated(gained_active, lost_active)); | 204 OnWindowActivated(gained_active, lost_active)); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void WmGlobalsMus::OnWillDestroyConnection( | 207 void WmGlobalsMus::OnWillDestroyClient( |
| 208 mus::WindowTreeConnection* connection) { | 208 mus::WindowTreeClient* client) { |
| 209 DCHECK_EQ(connection, connection_); | 209 DCHECK_EQ(client, client_); |
| 210 RemoveConnectionObserver(); | 210 RemoveClientObserver(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace wm | 213 } // namespace wm |
| 214 } // namespace mash | 214 } // namespace mash |
| OLD | NEW |