OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/wm/window_manager_impl.h" | 5 #include "athena/wm/window_manager_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "athena/screen/public/screen_manager.h" | 9 #include "athena/screen/public/screen_manager.h" |
10 #include "athena/util/container_priorities.h" | 10 #include "athena/util/container_priorities.h" |
11 #include "athena/wm/bezel_controller.h" | |
12 #include "athena/wm/public/window_manager_observer.h" | 11 #include "athena/wm/public/window_manager_observer.h" |
13 #include "athena/wm/split_view_controller.h" | 12 #include "athena/wm/split_view_controller.h" |
14 #include "athena/wm/title_drag_controller.h" | 13 #include "athena/wm/title_drag_controller.h" |
15 #include "athena/wm/window_list_provider_impl.h" | 14 #include "athena/wm/window_list_provider_impl.h" |
16 #include "athena/wm/window_overview_mode.h" | 15 #include "athena/wm/window_overview_mode.h" |
17 #include "base/bind.h" | 16 #include "base/bind.h" |
18 #include "base/logging.h" | 17 #include "base/logging.h" |
19 #include "ui/aura/client/aura_constants.h" | 18 #include "ui/aura/client/aura_constants.h" |
20 #include "ui/aura/layout_manager.h" | 19 #include "ui/aura/layout_manager.h" |
21 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 WindowManagerImpl::WindowManagerImpl() { | 150 WindowManagerImpl::WindowManagerImpl() { |
152 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); | 151 ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); |
153 params.can_activate_children = true; | 152 params.can_activate_children = true; |
154 params.default_parent = true; | 153 params.default_parent = true; |
155 params.modal_container_priority = CP_SYSTEM_MODAL; | 154 params.modal_container_priority = CP_SYSTEM_MODAL; |
156 container_.reset(ScreenManager::Get()->CreateContainer(params)); | 155 container_.reset(ScreenManager::Get()->CreateContainer(params)); |
157 container_->SetLayoutManager(new AthenaContainerLayoutManager); | 156 container_->SetLayoutManager(new AthenaContainerLayoutManager); |
158 container_->AddObserver(this); | 157 container_->AddObserver(this); |
159 window_list_provider_.reset(new WindowListProviderImpl(container_.get())); | 158 window_list_provider_.reset(new WindowListProviderImpl(container_.get())); |
160 window_list_provider_->AddObserver(this); | 159 window_list_provider_->AddObserver(this); |
161 bezel_controller_.reset(new BezelController(container_.get())); | |
162 split_view_controller_.reset( | 160 split_view_controller_.reset( |
163 new SplitViewController(container_.get(), window_list_provider_.get())); | 161 new SplitViewController(container_.get(), window_list_provider_.get())); |
164 AddObserver(split_view_controller_.get()); | 162 AddObserver(split_view_controller_.get()); |
165 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); | |
166 container_->AddPreTargetHandler(bezel_controller_.get()); | |
167 title_drag_controller_.reset(new TitleDragController(container_.get(), this)); | 163 title_drag_controller_.reset(new TitleDragController(container_.get(), this)); |
168 wm_state_.reset(new wm::WMState()); | 164 wm_state_.reset(new wm::WMState()); |
169 aura::client::ActivationClient* activation_client = | 165 aura::client::ActivationClient* activation_client = |
170 aura::client::GetActivationClient(container_->GetRootWindow()); | 166 aura::client::GetActivationClient(container_->GetRootWindow()); |
171 DCHECK(container_->GetRootWindow()); | 167 DCHECK(container_->GetRootWindow()); |
172 DCHECK(activation_client); | 168 DCHECK(activation_client); |
173 shadow_controller_.reset(new wm::ShadowController(activation_client)); | 169 shadow_controller_.reset(new wm::ShadowController(activation_client)); |
174 instance = this; | 170 instance = this; |
175 InstallAccelerators(); | 171 InstallAccelerators(); |
176 } | 172 } |
177 | 173 |
178 WindowManagerImpl::~WindowManagerImpl() { | 174 WindowManagerImpl::~WindowManagerImpl() { |
179 window_list_provider_->RemoveObserver(this); | 175 window_list_provider_->RemoveObserver(this); |
180 overview_.reset(); | 176 overview_.reset(); |
181 RemoveObserver(split_view_controller_.get()); | 177 RemoveObserver(split_view_controller_.get()); |
182 split_view_controller_.reset(); | 178 split_view_controller_.reset(); |
183 window_list_provider_.reset(); | 179 window_list_provider_.reset(); |
184 if (container_) { | 180 if (container_) |
185 container_->RemoveObserver(this); | 181 container_->RemoveObserver(this); |
186 container_->RemovePreTargetHandler(bezel_controller_.get()); | 182 |
187 } | |
188 // |title_drag_controller_| needs to be reset before |container_|. | 183 // |title_drag_controller_| needs to be reset before |container_|. |
189 title_drag_controller_.reset(); | 184 title_drag_controller_.reset(); |
190 container_.reset(); | 185 container_.reset(); |
191 instance = nullptr; | 186 instance = nullptr; |
192 } | 187 } |
193 | 188 |
194 void WindowManagerImpl::ToggleSplitView() { | 189 void WindowManagerImpl::ToggleSplitView() { |
195 if (IsOverviewModeActive()) | 190 if (IsOverviewModeActive()) |
196 return; | 191 return; |
197 | 192 |
198 if (split_view_controller_->IsSplitViewModeActive()) { | 193 if (split_view_controller_->IsSplitViewModeActive()) { |
199 split_view_controller_->DeactivateSplitMode(); | 194 split_view_controller_->DeactivateSplitMode(); |
200 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); | 195 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); |
201 // Relayout so that windows are maximzied. | 196 // Relayout so that windows are maximzied. |
202 container_->layout_manager()->OnWindowResized(); | 197 container_->layout_manager()->OnWindowResized(); |
203 } else if (split_view_controller_->CanActivateSplitViewMode()) { | 198 } else if (split_view_controller_->CanActivateSplitViewMode()) { |
204 FOR_EACH_OBSERVER(WindowManagerObserver, | 199 FOR_EACH_OBSERVER(WindowManagerObserver, |
205 observers_, | 200 observers_, |
206 OnSplitViewModeEnter()); | 201 OnSplitViewModeEnter()); |
207 split_view_controller_->ActivateSplitMode(nullptr, nullptr, nullptr); | 202 split_view_controller_->ActivateSplitMode(nullptr, nullptr, nullptr); |
208 } | 203 } |
209 } | 204 } |
210 | 205 |
211 void WindowManagerImpl::EnterOverview() { | 206 void WindowManagerImpl::EnterOverview() { |
212 if (IsOverviewModeActive()) | 207 if (IsOverviewModeActive()) |
213 return; | 208 return; |
214 | 209 |
215 bezel_controller_->set_left_right_delegate(nullptr); | |
216 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); | 210 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); |
217 | 211 |
218 // Note: The window_list_provider_ resembles the exact window list of the | 212 // Note: The window_list_provider_ resembles the exact window list of the |
219 // container, so no re-stacking is required before showing the OverviewMode. | 213 // container, so no re-stacking is required before showing the OverviewMode. |
220 overview_ = WindowOverviewMode::Create( | 214 overview_ = WindowOverviewMode::Create( |
221 container_.get(), window_list_provider_.get(), | 215 container_.get(), window_list_provider_.get(), |
222 split_view_controller_.get(), this); | 216 split_view_controller_.get(), this); |
223 AcceleratorManager::Get()->RegisterAccelerator(kEscAcceleratorData, this); | 217 AcceleratorManager::Get()->RegisterAccelerator(kEscAcceleratorData, this); |
224 } | 218 } |
225 | 219 |
(...skipping 16 matching lines...) Expand all Loading... |
242 } | 236 } |
243 | 237 |
244 bool WindowManagerImpl::IsOverviewModeActive() { | 238 bool WindowManagerImpl::IsOverviewModeActive() { |
245 return overview_; | 239 return overview_; |
246 } | 240 } |
247 | 241 |
248 void WindowManagerImpl::ExitOverviewNoActivate() { | 242 void WindowManagerImpl::ExitOverviewNoActivate() { |
249 if (!IsOverviewModeActive()) | 243 if (!IsOverviewModeActive()) |
250 return; | 244 return; |
251 | 245 |
252 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); | |
253 overview_.reset(); | 246 overview_.reset(); |
254 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); | 247 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); |
255 AcceleratorManager::Get()->UnregisterAccelerator(kEscAcceleratorData, this); | 248 AcceleratorManager::Get()->UnregisterAccelerator(kEscAcceleratorData, this); |
256 } | 249 } |
257 | 250 |
258 void WindowManagerImpl::InstallAccelerators() { | 251 void WindowManagerImpl::InstallAccelerators() { |
259 const AcceleratorData accelerator_data[] = { | 252 const AcceleratorData accelerator_data[] = { |
260 {TRIGGER_ON_PRESS, | 253 {TRIGGER_ON_PRESS, |
261 ui::VKEY_F6, | 254 ui::VKEY_F6, |
262 ui::EF_NONE, | 255 ui::EF_NONE, |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 DCHECK(!instance); | 501 DCHECK(!instance); |
509 } | 502 } |
510 | 503 |
511 // static | 504 // static |
512 WindowManager* WindowManager::Get() { | 505 WindowManager* WindowManager::Get() { |
513 DCHECK(instance); | 506 DCHECK(instance); |
514 return instance; | 507 return instance; |
515 } | 508 } |
516 | 509 |
517 } // namespace athena | 510 } // namespace athena |
OLD | NEW |