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

Side by Side Diff: ash/mus/shadow_controller.cc

Issue 2029883002: Moves mash/wm into ash/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_static_assert
Patch Set: move comment Created 4 years, 6 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 | « ash/mus/shadow_controller.h ('k') | ash/mus/shelf_layout_impl.h » ('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 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/shadow_controller.h" 5 #include "ash/mus/shadow_controller.h"
6 6
7 #include "ash/mus/property_util.h"
8 #include "ash/mus/shadow.h"
7 #include "components/mus/public/cpp/window.h" 9 #include "components/mus/public/cpp/window.h"
8 #include "components/mus/public/cpp/window_tree_client.h" 10 #include "components/mus/public/cpp/window_tree_client.h"
9 #include "mash/wm/property_util.h"
10 #include "mash/wm/shadow.h"
11 11
12 namespace mash { 12 namespace ash {
13 namespace wm { 13 namespace mus {
14 namespace { 14 namespace {
15 15
16 // Returns the first ancestor of |from| (including |from|) that has a shadow. 16 // Returns the first ancestor of |from| (including |from|) that has a shadow.
17 mus::Window* FindAncestorWithShadow(mus::Window* from) { 17 ::mus::Window* FindAncestorWithShadow(::mus::Window* from) {
18 mus::Window* result = from; 18 ::mus::Window* result = from;
19 while (result && !GetShadow(result)) 19 while (result && !GetShadow(result))
20 result = result->parent(); 20 result = result->parent();
21 // Small shadows never change. 21 // Small shadows never change.
22 return result && GetShadow(result)->style() != Shadow::STYLE_SMALL ? result 22 return result && GetShadow(result)->style() != Shadow::STYLE_SMALL ? result
23 : nullptr; 23 : nullptr;
24 } 24 }
25 25
26 } // namespace 26 } // namespace
27 27
28 ShadowController::ShadowController(mus::WindowTreeClient* window_tree) 28 ShadowController::ShadowController(::mus::WindowTreeClient* window_tree)
29 : window_tree_(window_tree), active_window_(nullptr) { 29 : window_tree_(window_tree), active_window_(nullptr) {
30 window_tree_->AddObserver(this); 30 window_tree_->AddObserver(this);
31 SetActiveWindow(FindAncestorWithShadow(window_tree_->GetFocusedWindow())); 31 SetActiveWindow(FindAncestorWithShadow(window_tree_->GetFocusedWindow()));
32 } 32 }
33 33
34 ShadowController::~ShadowController() { 34 ShadowController::~ShadowController() {
35 window_tree_->RemoveObserver(this); 35 window_tree_->RemoveObserver(this);
36 if (active_window_) 36 if (active_window_)
37 active_window_->RemoveObserver(this); 37 active_window_->RemoveObserver(this);
38 } 38 }
39 39
40 void ShadowController::SetActiveWindow(mus::Window* window) { 40 void ShadowController::SetActiveWindow(::mus::Window* window) {
41 if (window == active_window_) 41 if (window == active_window_)
42 return; 42 return;
43 43
44 if (active_window_) { 44 if (active_window_) {
45 if (GetShadow(active_window_)) 45 if (GetShadow(active_window_))
46 GetShadow(active_window_)->SetStyle(Shadow::STYLE_INACTIVE); 46 GetShadow(active_window_)->SetStyle(Shadow::STYLE_INACTIVE);
47 active_window_->RemoveObserver(this); 47 active_window_->RemoveObserver(this);
48 } 48 }
49 active_window_ = window; 49 active_window_ = window;
50 if (active_window_) { 50 if (active_window_) {
51 GetShadow(active_window_)->SetStyle(Shadow::STYLE_ACTIVE); 51 GetShadow(active_window_)->SetStyle(Shadow::STYLE_ACTIVE);
52 active_window_->AddObserver(this); 52 active_window_->AddObserver(this);
53 } 53 }
54 } 54 }
55 55
56 void ShadowController::OnWindowTreeFocusChanged(mus::Window* gained_focus, 56 void ShadowController::OnWindowTreeFocusChanged(::mus::Window* gained_focus,
57 mus::Window* lost_focus) { 57 ::mus::Window* lost_focus) {
58 SetActiveWindow(FindAncestorWithShadow(gained_focus)); 58 SetActiveWindow(FindAncestorWithShadow(gained_focus));
59 } 59 }
60 60
61 void ShadowController::OnWindowDestroying(mus::Window* window) { 61 void ShadowController::OnWindowDestroying(::mus::Window* window) {
62 DCHECK_EQ(window, active_window_); 62 DCHECK_EQ(window, active_window_);
63 SetActiveWindow(nullptr); 63 SetActiveWindow(nullptr);
64 } 64 }
65 65
66 } // namespace wm 66 } // namespace mus
67 } // namespace mash 67 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/shadow_controller.h ('k') | ash/mus/shelf_layout_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698