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" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // Relayout so that windows are maximzied. | 186 // Relayout so that windows are maximzied. |
187 container_->layout_manager()->OnWindowResized(); | 187 container_->layout_manager()->OnWindowResized(); |
188 } else if (split_view_controller_->CanActivateSplitViewMode()) { | 188 } else if (split_view_controller_->CanActivateSplitViewMode()) { |
189 FOR_EACH_OBSERVER(WindowManagerObserver, | 189 FOR_EACH_OBSERVER(WindowManagerObserver, |
190 observers_, | 190 observers_, |
191 OnSplitViewModeEnter()); | 191 OnSplitViewModeEnter()); |
192 split_view_controller_->ActivateSplitMode(NULL, NULL, NULL); | 192 split_view_controller_->ActivateSplitMode(NULL, NULL, NULL); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 void WindowManagerImpl::ToggleOverview() { | 196 void WindowManagerImpl::EnterOverview() { |
197 if (IsOverviewModeActive()) { | 197 if (IsOverviewModeActive()) |
198 SetInOverview(false); | 198 return; |
199 | 199 |
200 // Activate the window which was active prior to entering overview. | 200 bezel_controller_->set_left_right_delegate(NULL); |
201 const aura::Window::Windows windows = | 201 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); |
202 window_list_provider_->GetWindowList(); | |
203 if (!windows.empty()) { | |
204 aura::Window* window = windows.back(); | |
205 // Show the window in case the exit overview animation has finished and | |
206 // |window| was hidden. | |
207 window->Show(); | |
208 | 202 |
209 wm::ActivateWindow(window); | 203 // Note: The window_list_provider_ resembles the exact window list of the |
210 } | 204 // container, so no re-stacking is required before showing the OverviewMode. |
211 } else { | 205 overview_ = WindowOverviewMode::Create( |
212 SetInOverview(true); | 206 container_.get(), window_list_provider_.get(), |
| 207 split_view_controller_.get(), this); |
| 208 } |
| 209 |
| 210 void WindowManagerImpl::ExitOverview() { |
| 211 if (!IsOverviewModeActive()) |
| 212 return; |
| 213 |
| 214 ExitOverviewNoActivate(); |
| 215 |
| 216 // Activate the window which was active prior to entering overview. |
| 217 const aura::Window::Windows windows = window_list_provider_->GetWindowList(); |
| 218 if (!windows.empty()) { |
| 219 aura::Window* window_to_activate = windows.back(); |
| 220 |
| 221 // Show the window in case the exit overview animation has finished and |
| 222 // |window| was hidden. |
| 223 window_to_activate->Show(); |
| 224 wm::ActivateWindow(window_to_activate); |
213 } | 225 } |
214 } | 226 } |
215 | 227 |
216 bool WindowManagerImpl::IsOverviewModeActive() { | 228 bool WindowManagerImpl::IsOverviewModeActive() { |
217 return overview_; | 229 return overview_; |
218 } | 230 } |
219 | 231 |
220 void WindowManagerImpl::SetInOverview(bool active) { | 232 void WindowManagerImpl::ExitOverviewNoActivate() { |
221 bool in_overview = !!overview_; | 233 if (!IsOverviewModeActive()) |
222 if (active == in_overview) | |
223 return; | 234 return; |
224 | 235 |
225 bezel_controller_->set_left_right_delegate( | 236 bezel_controller_->set_left_right_delegate(split_view_controller_.get()); |
226 active ? NULL : split_view_controller_.get()); | 237 overview_.reset(); |
227 if (active) { | 238 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); |
228 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); | |
229 | |
230 // Note: The window_list_provider_ resembles the exact window list of the | |
231 // container, so no re-stacking is required before showing the OverviewMode. | |
232 overview_ = WindowOverviewMode::Create( | |
233 container_.get(), window_list_provider_.get(), | |
234 split_view_controller_.get(), this); | |
235 } else { | |
236 overview_.reset(); | |
237 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); | |
238 } | |
239 } | 239 } |
240 | 240 |
241 void WindowManagerImpl::InstallAccelerators() { | 241 void WindowManagerImpl::InstallAccelerators() { |
242 const AcceleratorData accelerator_data[] = { | 242 const AcceleratorData accelerator_data[] = { |
243 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, | 243 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, |
244 AF_NONE}, | 244 AF_NONE}, |
245 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, | 245 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, |
246 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, | 246 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, |
247 }; | 247 }; |
248 AcceleratorManager::Get()->RegisterAccelerators( | 248 AcceleratorManager::Get()->RegisterAccelerators( |
(...skipping 10 matching lines...) Expand all Loading... |
259 | 259 |
260 void WindowManagerImpl::ToggleSplitViewForTest() { | 260 void WindowManagerImpl::ToggleSplitViewForTest() { |
261 ToggleSplitView(); | 261 ToggleSplitView(); |
262 } | 262 } |
263 | 263 |
264 WindowListProvider* WindowManagerImpl::GetWindowListProvider() { | 264 WindowListProvider* WindowManagerImpl::GetWindowListProvider() { |
265 return window_list_provider_.get(); | 265 return window_list_provider_.get(); |
266 } | 266 } |
267 | 267 |
268 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { | 268 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { |
269 SetInOverview(false); | 269 ExitOverviewNoActivate(); |
270 | 270 |
271 // Show the window in case the exit overview animation has finished and | 271 // Show the window in case the exit overview animation has finished and |
272 // |window| was hidden. | 272 // |window| was hidden. |
273 window->Show(); | 273 window->Show(); |
274 | 274 |
275 wm::ActivateWindow(window); | 275 wm::ActivateWindow(window); |
276 | 276 |
277 if (split_view_controller_->IsSplitViewModeActive()) { | 277 if (split_view_controller_->IsSplitViewModeActive()) { |
278 split_view_controller_->DeactivateSplitMode(); | 278 split_view_controller_->DeactivateSplitMode(); |
279 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); | 279 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); |
(...skipping 18 matching lines...) Expand all Loading... |
298 base::Unretained(window), | 298 base::Unretained(window), |
299 desired_bounds, | 299 desired_bounds, |
300 gfx::Transform()))); | 300 gfx::Transform()))); |
301 window->SetTransform(transform); | 301 window->SetTransform(transform); |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
305 void WindowManagerImpl::OnSelectSplitViewWindow(aura::Window* left, | 305 void WindowManagerImpl::OnSelectSplitViewWindow(aura::Window* left, |
306 aura::Window* right, | 306 aura::Window* right, |
307 aura::Window* to_activate) { | 307 aura::Window* to_activate) { |
308 SetInOverview(false); | 308 ExitOverviewNoActivate(); |
309 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter()); | 309 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter()); |
310 split_view_controller_->ActivateSplitMode(left, right, to_activate); | 310 split_view_controller_->ActivateSplitMode(left, right, to_activate); |
311 } | 311 } |
312 | 312 |
313 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { | 313 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { |
314 if (window == container_) | 314 if (window == container_) |
315 container_.reset(); | 315 container_.reset(); |
316 } | 316 } |
317 | 317 |
318 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { | 318 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { |
319 return true; | 319 return true; |
320 } | 320 } |
321 | 321 |
322 bool WindowManagerImpl::OnAcceleratorFired(int command_id, | 322 bool WindowManagerImpl::OnAcceleratorFired(int command_id, |
323 const ui::Accelerator& accelerator) { | 323 const ui::Accelerator& accelerator) { |
324 switch (command_id) { | 324 switch (command_id) { |
325 case CMD_TOGGLE_OVERVIEW: | 325 case CMD_TOGGLE_OVERVIEW: |
326 ToggleOverview(); | 326 if (IsOverviewModeActive()) |
| 327 ExitOverview(); |
| 328 else |
| 329 EnterOverview(); |
327 break; | 330 break; |
328 case CMD_TOGGLE_SPLIT_VIEW: | 331 case CMD_TOGGLE_SPLIT_VIEW: |
329 ToggleSplitView(); | 332 ToggleSplitView(); |
330 break; | 333 break; |
331 } | 334 } |
332 return true; | 335 return true; |
333 } | 336 } |
334 | 337 |
335 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { | 338 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { |
336 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); | 339 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 DCHECK(!instance); | 428 DCHECK(!instance); |
426 } | 429 } |
427 | 430 |
428 // static | 431 // static |
429 WindowManager* WindowManager::Get() { | 432 WindowManager* WindowManager::Get() { |
430 DCHECK(instance); | 433 DCHECK(instance); |
431 return instance; | 434 return instance; |
432 } | 435 } |
433 | 436 |
434 } // namespace athena | 437 } // namespace athena |
OLD | NEW |