OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/wm/window_selector_controller.h" |
| 6 |
| 7 #include "ash/session_state_delegate.h" |
| 8 #include "ash/shell.h" |
| 9 #include "ash/wm/mru_window_tracker.h" |
| 10 #include "ash/wm/window_selector.h" |
| 11 #include "ash/wm/window_util.h" |
| 12 |
| 13 namespace ash { |
| 14 |
| 15 WindowSelectorController::WindowSelectorController() { |
| 16 } |
| 17 |
| 18 WindowSelectorController::~WindowSelectorController() { |
| 19 } |
| 20 |
| 21 // static |
| 22 bool WindowSelectorController::CanSelect() { |
| 23 // Don't allow a window overview if the screen is locked or a modal dialog is |
| 24 // open. |
| 25 return !Shell::GetInstance()->session_state_delegate()->IsScreenLocked() && |
| 26 !Shell::GetInstance()->IsSystemModalWindowOpen(); |
| 27 } |
| 28 |
| 29 void WindowSelectorController::ToggleOverview() { |
| 30 if (window_selector_.get()) { |
| 31 window_selector_.reset(); |
| 32 } else { |
| 33 std::vector<aura::Window*> windows = ash::Shell::GetInstance()-> |
| 34 mru_window_tracker()->BuildMruWindowList(); |
| 35 // Don't enter overview mode with no windows. |
| 36 if (windows.empty()) |
| 37 return; |
| 38 |
| 39 // Deactivating the window will hide popup windows like the omnibar or |
| 40 // open menus. |
| 41 aura::Window* active_window = wm::GetActiveWindow(); |
| 42 if (active_window) |
| 43 wm::DeactivateWindow(active_window); |
| 44 window_selector_.reset(new WindowSelector(windows, this)); |
| 45 } |
| 46 } |
| 47 |
| 48 bool WindowSelectorController::IsSelecting() { |
| 49 return window_selector_.get() != NULL; |
| 50 } |
| 51 |
| 52 void WindowSelectorController::OnWindowSelected(aura::Window* window) { |
| 53 window_selector_.reset(); |
| 54 wm::ActivateWindow(window); |
| 55 } |
| 56 |
| 57 void WindowSelectorController::OnSelectionCanceled() { |
| 58 window_selector_.reset(); |
| 59 } |
| 60 |
| 61 } // namespace ash |
OLD | NEW |