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 "ash/mus/bridge/wm_globals_mus.h" | 5 #include "ash/mus/bridge/wm_shell_mus.h" |
6 | 6 |
7 #include "ash/common/shell_window_ids.h" | 7 #include "ash/common/shell_window_ids.h" |
8 #include "ash/common/wm/window_resizer.h" | 8 #include "ash/common/wm/window_resizer.h" |
9 #include "ash/common/wm/wm_activation_observer.h" | 9 #include "ash/common/wm_activation_observer.h" |
10 #include "ash/mus/bridge/wm_root_window_controller_mus.h" | 10 #include "ash/mus/bridge/wm_root_window_controller_mus.h" |
11 #include "ash/mus/bridge/wm_window_mus.h" | 11 #include "ash/mus/bridge/wm_window_mus.h" |
12 #include "ash/mus/container_ids.h" | 12 #include "ash/mus/container_ids.h" |
13 #include "ash/mus/drag_window_resizer.h" | 13 #include "ash/mus/drag_window_resizer.h" |
14 #include "ash/mus/root_window_controller.h" | 14 #include "ash/mus/root_window_controller.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "components/mus/common/util.h" | 16 #include "components/mus/common/util.h" |
17 #include "components/mus/public/cpp/window.h" | 17 #include "components/mus/public/cpp/window.h" |
18 #include "components/mus/public/cpp/window_tree_client.h" | 18 #include "components/mus/public/cpp/window_tree_client.h" |
19 | 19 |
20 namespace ash { | 20 namespace ash { |
21 namespace mus { | 21 namespace mus { |
22 | 22 |
23 WmGlobalsMus::WmGlobalsMus(::mus::WindowTreeClient* client) : client_(client) { | 23 WmShellMus::WmShellMus(::mus::WindowTreeClient* client) : client_(client) { |
24 client_->AddObserver(this); | 24 client_->AddObserver(this); |
25 WmGlobals::Set(this); | 25 WmShell::Set(this); |
26 } | 26 } |
27 | 27 |
28 WmGlobalsMus::~WmGlobalsMus() { | 28 WmShellMus::~WmShellMus() { |
29 RemoveClientObserver(); | 29 RemoveClientObserver(); |
30 WmGlobals::Set(nullptr); | 30 WmShell::Set(nullptr); |
31 } | 31 } |
32 | 32 |
33 // static | 33 // static |
34 WmGlobalsMus* WmGlobalsMus::Get() { | 34 WmShellMus* WmShellMus::Get() { |
35 return static_cast<WmGlobalsMus*>(wm::WmGlobals::Get()); | 35 return static_cast<WmShellMus*>(WmShell::Get()); |
36 } | 36 } |
37 | 37 |
38 void WmGlobalsMus::AddRootWindowController( | 38 void WmShellMus::AddRootWindowController( |
39 WmRootWindowControllerMus* controller) { | 39 WmRootWindowControllerMus* controller) { |
40 root_window_controllers_.push_back(controller); | 40 root_window_controllers_.push_back(controller); |
41 } | 41 } |
42 | 42 |
43 void WmGlobalsMus::RemoveRootWindowController( | 43 void WmShellMus::RemoveRootWindowController( |
44 WmRootWindowControllerMus* controller) { | 44 WmRootWindowControllerMus* controller) { |
45 auto iter = std::find(root_window_controllers_.begin(), | 45 auto iter = std::find(root_window_controllers_.begin(), |
46 root_window_controllers_.end(), controller); | 46 root_window_controllers_.end(), controller); |
47 DCHECK(iter != root_window_controllers_.end()); | 47 DCHECK(iter != root_window_controllers_.end()); |
48 root_window_controllers_.erase(iter); | 48 root_window_controllers_.erase(iter); |
49 } | 49 } |
50 | 50 |
51 // static | 51 // static |
52 WmWindowMus* WmGlobalsMus::GetToplevelAncestor(::mus::Window* window) { | 52 WmWindowMus* WmShellMus::GetToplevelAncestor(::mus::Window* window) { |
53 while (window) { | 53 while (window) { |
54 if (IsActivationParent(window->parent())) | 54 if (IsActivationParent(window->parent())) |
55 return WmWindowMus::Get(window); | 55 return WmWindowMus::Get(window); |
56 window = window->parent(); | 56 window = window->parent(); |
57 } | 57 } |
58 return nullptr; | 58 return nullptr; |
59 } | 59 } |
60 | 60 |
61 WmRootWindowControllerMus* WmGlobalsMus::GetRootWindowControllerWithDisplayId( | 61 WmRootWindowControllerMus* WmShellMus::GetRootWindowControllerWithDisplayId( |
62 int64_t id) { | 62 int64_t id) { |
63 for (WmRootWindowControllerMus* root_window_controller : | 63 for (WmRootWindowControllerMus* root_window_controller : |
64 root_window_controllers_) { | 64 root_window_controllers_) { |
65 if (root_window_controller->GetDisplay().id() == id) | 65 if (root_window_controller->GetDisplay().id() == id) |
66 return root_window_controller; | 66 return root_window_controller; |
67 } | 67 } |
68 NOTREACHED(); | 68 NOTREACHED(); |
69 return nullptr; | 69 return nullptr; |
70 } | 70 } |
71 | 71 |
72 wm::WmWindow* WmGlobalsMus::NewContainerWindow() { | 72 WmWindow* WmShellMus::NewContainerWindow() { |
73 return WmWindowMus::Get(client_->NewWindow()); | 73 return WmWindowMus::Get(client_->NewWindow()); |
74 } | 74 } |
75 | 75 |
76 wm::WmWindow* WmGlobalsMus::GetFocusedWindow() { | 76 WmWindow* WmShellMus::GetFocusedWindow() { |
77 return WmWindowMus::Get(client_->GetFocusedWindow()); | 77 return WmWindowMus::Get(client_->GetFocusedWindow()); |
78 } | 78 } |
79 | 79 |
80 wm::WmWindow* WmGlobalsMus::GetActiveWindow() { | 80 WmWindow* WmShellMus::GetActiveWindow() { |
81 return GetToplevelAncestor(client_->GetFocusedWindow()); | 81 return GetToplevelAncestor(client_->GetFocusedWindow()); |
82 } | 82 } |
83 | 83 |
84 wm::WmWindow* WmGlobalsMus::GetPrimaryRootWindow() { | 84 WmWindow* WmShellMus::GetPrimaryRootWindow() { |
85 return root_window_controllers_[0]->GetWindow(); | 85 return root_window_controllers_[0]->GetWindow(); |
86 } | 86 } |
87 | 87 |
88 wm::WmWindow* WmGlobalsMus::GetRootWindowForDisplayId(int64_t display_id) { | 88 WmWindow* WmShellMus::GetRootWindowForDisplayId(int64_t display_id) { |
89 return GetRootWindowControllerWithDisplayId(display_id)->GetWindow(); | 89 return GetRootWindowControllerWithDisplayId(display_id)->GetWindow(); |
90 } | 90 } |
91 | 91 |
92 wm::WmWindow* WmGlobalsMus::GetRootWindowForNewWindows() { | 92 WmWindow* WmShellMus::GetRootWindowForNewWindows() { |
93 NOTIMPLEMENTED(); | 93 NOTIMPLEMENTED(); |
94 return root_window_controllers_[0]->GetWindow(); | 94 return root_window_controllers_[0]->GetWindow(); |
95 } | 95 } |
96 | 96 |
97 std::vector<wm::WmWindow*> WmGlobalsMus::GetMruWindowList() { | 97 std::vector<WmWindow*> WmShellMus::GetMruWindowList() { |
98 NOTIMPLEMENTED(); | 98 NOTIMPLEMENTED(); |
99 return std::vector<wm::WmWindow*>(); | 99 return std::vector<WmWindow*>(); |
100 } | 100 } |
101 | 101 |
102 std::vector<wm::WmWindow*> WmGlobalsMus::GetMruWindowListIgnoreModals() { | 102 std::vector<WmWindow*> WmShellMus::GetMruWindowListIgnoreModals() { |
103 NOTIMPLEMENTED(); | 103 NOTIMPLEMENTED(); |
104 return std::vector<wm::WmWindow*>(); | 104 return std::vector<WmWindow*>(); |
105 } | 105 } |
106 | 106 |
107 bool WmGlobalsMus::IsForceMaximizeOnFirstRun() { | 107 bool WmShellMus::IsForceMaximizeOnFirstRun() { |
108 NOTIMPLEMENTED(); | 108 NOTIMPLEMENTED(); |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
112 bool WmGlobalsMus::IsUserSessionBlocked() { | 112 bool WmShellMus::IsUserSessionBlocked() { |
113 NOTIMPLEMENTED(); | 113 NOTIMPLEMENTED(); |
114 return false; | 114 return false; |
115 } | 115 } |
116 | 116 |
117 bool WmGlobalsMus::IsScreenLocked() { | 117 bool WmShellMus::IsScreenLocked() { |
118 NOTIMPLEMENTED(); | 118 NOTIMPLEMENTED(); |
119 return false; | 119 return false; |
120 } | 120 } |
121 | 121 |
122 void WmGlobalsMus::LockCursor() { | 122 void WmShellMus::LockCursor() { |
123 NOTIMPLEMENTED(); | 123 NOTIMPLEMENTED(); |
124 } | 124 } |
125 | 125 |
126 void WmGlobalsMus::UnlockCursor() { | 126 void WmShellMus::UnlockCursor() { |
127 NOTIMPLEMENTED(); | 127 NOTIMPLEMENTED(); |
128 } | 128 } |
129 | 129 |
130 std::vector<wm::WmWindow*> WmGlobalsMus::GetAllRootWindows() { | 130 std::vector<WmWindow*> WmShellMus::GetAllRootWindows() { |
131 std::vector<wm::WmWindow*> wm_windows(root_window_controllers_.size()); | 131 std::vector<WmWindow*> wm_windows(root_window_controllers_.size()); |
132 for (size_t i = 0; i < root_window_controllers_.size(); ++i) | 132 for (size_t i = 0; i < root_window_controllers_.size(); ++i) |
133 wm_windows[i] = root_window_controllers_[i]->GetWindow(); | 133 wm_windows[i] = root_window_controllers_[i]->GetWindow(); |
134 return wm_windows; | 134 return wm_windows; |
135 } | 135 } |
136 | 136 |
137 void WmGlobalsMus::RecordUserMetricsAction(wm::WmUserMetricsAction action) { | 137 void WmShellMus::RecordUserMetricsAction(wm::WmUserMetricsAction action) { |
138 NOTIMPLEMENTED(); | 138 NOTIMPLEMENTED(); |
139 } | 139 } |
140 | 140 |
141 std::unique_ptr<WindowResizer> WmGlobalsMus::CreateDragWindowResizer( | 141 std::unique_ptr<WindowResizer> WmShellMus::CreateDragWindowResizer( |
142 std::unique_ptr<WindowResizer> next_window_resizer, | 142 std::unique_ptr<WindowResizer> next_window_resizer, |
143 wm::WindowState* window_state) { | 143 wm::WindowState* window_state) { |
144 return base::WrapUnique( | 144 return base::WrapUnique( |
145 new DragWindowResizer(std::move(next_window_resizer), window_state)); | 145 new DragWindowResizer(std::move(next_window_resizer), window_state)); |
146 } | 146 } |
147 | 147 |
148 bool WmGlobalsMus::IsOverviewModeSelecting() { | 148 bool WmShellMus::IsOverviewModeSelecting() { |
149 NOTIMPLEMENTED(); | 149 NOTIMPLEMENTED(); |
150 return false; | 150 return false; |
151 } | 151 } |
152 | 152 |
153 bool WmGlobalsMus::IsOverviewModeRestoringMinimizedWindows() { | 153 bool WmShellMus::IsOverviewModeRestoringMinimizedWindows() { |
154 NOTIMPLEMENTED(); | 154 NOTIMPLEMENTED(); |
155 return false; | 155 return false; |
156 } | 156 } |
157 | 157 |
158 void WmGlobalsMus::AddActivationObserver(wm::WmActivationObserver* observer) { | 158 void WmShellMus::AddActivationObserver(WmActivationObserver* observer) { |
159 activation_observers_.AddObserver(observer); | 159 activation_observers_.AddObserver(observer); |
160 } | 160 } |
161 | 161 |
162 void WmGlobalsMus::RemoveActivationObserver( | 162 void WmShellMus::RemoveActivationObserver(WmActivationObserver* observer) { |
163 wm::WmActivationObserver* observer) { | |
164 activation_observers_.RemoveObserver(observer); | 163 activation_observers_.RemoveObserver(observer); |
165 } | 164 } |
166 | 165 |
167 void WmGlobalsMus::AddDisplayObserver(wm::WmDisplayObserver* observer) { | 166 void WmShellMus::AddDisplayObserver(WmDisplayObserver* observer) { |
168 NOTIMPLEMENTED(); | 167 NOTIMPLEMENTED(); |
169 } | 168 } |
170 | 169 |
171 void WmGlobalsMus::RemoveDisplayObserver(wm::WmDisplayObserver* observer) { | 170 void WmShellMus::RemoveDisplayObserver(WmDisplayObserver* observer) { |
172 NOTIMPLEMENTED(); | 171 NOTIMPLEMENTED(); |
173 } | 172 } |
174 | 173 |
175 void WmGlobalsMus::AddOverviewModeObserver( | 174 void WmShellMus::AddOverviewModeObserver(WmOverviewModeObserver* observer) { |
176 wm::WmOverviewModeObserver* observer) { | |
177 NOTIMPLEMENTED(); | 175 NOTIMPLEMENTED(); |
178 } | 176 } |
179 | 177 |
180 void WmGlobalsMus::RemoveOverviewModeObserver( | 178 void WmShellMus::RemoveOverviewModeObserver(WmOverviewModeObserver* observer) { |
181 wm::WmOverviewModeObserver* observer) { | |
182 NOTIMPLEMENTED(); | 179 NOTIMPLEMENTED(); |
183 } | 180 } |
184 | 181 |
185 // static | 182 // static |
186 bool WmGlobalsMus::IsActivationParent(::mus::Window* window) { | 183 bool WmShellMus::IsActivationParent(::mus::Window* window) { |
187 if (!window) | 184 if (!window) |
188 return false; | 185 return false; |
189 | 186 |
190 for (size_t i = 0; i < kNumActivationContainers; ++i) { | 187 for (size_t i = 0; i < kNumActivationContainers; ++i) { |
191 if (window->local_id() == static_cast<int>(kActivationContainers[i])) | 188 if (window->local_id() == static_cast<int>(kActivationContainers[i])) |
192 return true; | 189 return true; |
193 } | 190 } |
194 return false; | 191 return false; |
195 } | 192 } |
196 | 193 |
197 void WmGlobalsMus::RemoveClientObserver() { | 194 void WmShellMus::RemoveClientObserver() { |
198 if (!client_) | 195 if (!client_) |
199 return; | 196 return; |
200 | 197 |
201 client_->RemoveObserver(this); | 198 client_->RemoveObserver(this); |
202 client_ = nullptr; | 199 client_ = nullptr; |
203 } | 200 } |
204 | 201 |
205 // TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114. | 202 // TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114. |
206 void WmGlobalsMus::OnWindowTreeFocusChanged(::mus::Window* gained_focus, | 203 void WmShellMus::OnWindowTreeFocusChanged(::mus::Window* gained_focus, |
207 ::mus::Window* lost_focus) { | 204 ::mus::Window* lost_focus) { |
208 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus); | 205 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus); |
209 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus); | 206 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus); |
210 if (gained_active == lost_active) | 207 if (gained_active == lost_active) |
211 return; | 208 return; |
212 | 209 |
213 FOR_EACH_OBSERVER(wm::WmActivationObserver, activation_observers_, | 210 FOR_EACH_OBSERVER(WmActivationObserver, activation_observers_, |
214 OnWindowActivated(gained_active, lost_active)); | 211 OnWindowActivated(gained_active, lost_active)); |
215 } | 212 } |
216 | 213 |
217 void WmGlobalsMus::OnWillDestroyClient(::mus::WindowTreeClient* client) { | 214 void WmShellMus::OnWillDestroyClient(::mus::WindowTreeClient* client) { |
218 DCHECK_EQ(client, client_); | 215 DCHECK_EQ(client, client_); |
219 RemoveClientObserver(); | 216 RemoveClientObserver(); |
220 } | 217 } |
221 | 218 |
222 } // namespace mus | 219 } // namespace mus |
223 } // namespace ash | 220 } // namespace ash |
OLD | NEW |