Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: mash/wm/bridge/wm_globals_mus.cc

Issue 1984293002: Random fixes for mash bridge classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mash/wm/bridge/wm_globals_mus.h ('k') | mash/wm/bridge/wm_lookup_mus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/mus/common/util.h" 10 #include "components/mus/common/util.h"
11 #include "components/mus/public/cpp/window.h" 11 #include "components/mus/public/cpp/window.h"
12 #include "components/mus/public/cpp/window_tree_connection.h" 12 #include "components/mus/public/cpp/window_tree_connection.h"
13 #include "mash/wm/bridge/wm_root_window_controller_mus.h" 13 #include "mash/wm/bridge/wm_root_window_controller_mus.h"
14 #include "mash/wm/bridge/wm_window_mus.h" 14 #include "mash/wm/bridge/wm_window_mus.h"
15 #include "mash/wm/container_ids.h"
15 #include "mash/wm/public/interfaces/container.mojom.h" 16 #include "mash/wm/public/interfaces/container.mojom.h"
16 #include "mash/wm/root_window_controller.h" 17 #include "mash/wm/root_window_controller.h"
17 18
18 namespace mash { 19 namespace mash {
19 namespace wm { 20 namespace wm {
20 21
21 WmGlobalsMus::WmGlobalsMus(mus::WindowTreeConnection* connection) 22 WmGlobalsMus::WmGlobalsMus(mus::WindowTreeConnection* connection)
22 : connection_(connection) { 23 : connection_(connection) {
23 connection_->AddObserver(this); 24 connection_->AddObserver(this);
24 WmGlobals::Set(this); 25 WmGlobals::Set(this);
25 } 26 }
26 27
27 WmGlobalsMus::~WmGlobalsMus() { 28 WmGlobalsMus::~WmGlobalsMus() {
28 connection_->RemoveObserver(this); 29 RemoveConnectionObserver();
29 WmGlobals::Set(nullptr); 30 WmGlobals::Set(nullptr);
30 } 31 }
31 32
32 // static 33 // static
33 WmGlobalsMus* WmGlobalsMus::Get() { 34 WmGlobalsMus* WmGlobalsMus::Get() {
34 return static_cast<WmGlobalsMus*>(ash::wm::WmGlobals::Get()); 35 return static_cast<WmGlobalsMus*>(ash::wm::WmGlobals::Get());
35 } 36 }
36 37
37 void WmGlobalsMus::AddRootWindowController( 38 void WmGlobalsMus::AddRootWindowController(
38 WmRootWindowControllerMus* controller) { 39 WmRootWindowControllerMus* controller) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 NOTIMPLEMENTED(); 166 NOTIMPLEMENTED();
166 } 167 }
167 168
168 void WmGlobalsMus::RemoveOverviewModeObserver( 169 void WmGlobalsMus::RemoveOverviewModeObserver(
169 ash::wm::WmOverviewModeObserver* observer) { 170 ash::wm::WmOverviewModeObserver* observer) {
170 NOTIMPLEMENTED(); 171 NOTIMPLEMENTED();
171 } 172 }
172 173
173 // static 174 // static
174 bool WmGlobalsMus::IsActivationParent(mus::Window* window) { 175 bool WmGlobalsMus::IsActivationParent(mus::Window* window) {
175 return window && window->local_id() == ash::kShellWindowId_DefaultContainer; 176 if (!window)
177 return false;
178
179 for (size_t i = 0; i < kNumActivationContainers; ++i) {
180 if (window->local_id() == static_cast<int>(kActivationContainers[i]))
181 return true;
182 }
183 return false;
184 }
185
186 void WmGlobalsMus::RemoveConnectionObserver() {
187 if (!connection_)
188 return;
189
190 connection_->RemoveObserver(this);
191 connection_ = nullptr;
176 } 192 }
177 193
178 void WmGlobalsMus::OnWindowTreeFocusChanged(mus::Window* gained_focus, 194 void WmGlobalsMus::OnWindowTreeFocusChanged(mus::Window* gained_focus,
179 mus::Window* lost_focus) { 195 mus::Window* lost_focus) {
180 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus); 196 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus);
181 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus); 197 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus);
182 if (gained_active == lost_active) 198 if (gained_active == lost_active)
183 return; 199 return;
184 200
185 FOR_EACH_OBSERVER(ash::wm::WmActivationObserver, activation_observers_, 201 FOR_EACH_OBSERVER(ash::wm::WmActivationObserver, activation_observers_,
186 OnWindowActivated(gained_active, lost_active)); 202 OnWindowActivated(gained_active, lost_active));
187 } 203 }
188 204
205 void WmGlobalsMus::OnWillDestroyConnection(
206 mus::WindowTreeConnection* connection) {
207 DCHECK_EQ(connection, connection_);
208 RemoveConnectionObserver();
209 }
210
189 } // namespace wm 211 } // namespace wm
190 } // namespace mash 212 } // namespace mash
OLDNEW
« no previous file with comments | « mash/wm/bridge/wm_globals_mus.h ('k') | mash/wm/bridge/wm_lookup_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698