| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/wm/overview/window_selector_controller.h" | 5 #include "ash/wm/overview/window_selector_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/session/session_controller.h" | 9 #include "ash/session/session_controller.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/shell_port.h" | 11 #include "ash/shell_port.h" |
| 12 #include "ash/wm/mru_window_tracker.h" | 12 #include "ash/wm/mru_window_tracker.h" |
| 13 #include "ash/wm/overview/window_selector.h" | 13 #include "ash/wm/overview/window_selector.h" |
| 14 #include "ash/wm/screen_pinning_controller.h" | 14 #include "ash/wm/screen_pinning_controller.h" |
| 15 #include "ash/wm/splitview/split_view_controller.h" |
| 15 #include "ash/wm/window_state.h" | 16 #include "ash/wm/window_state.h" |
| 16 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 | 20 |
| 20 WindowSelectorController::WindowSelectorController() {} | 21 WindowSelectorController::WindowSelectorController() {} |
| 21 | 22 |
| 22 WindowSelectorController::~WindowSelectorController() { | 23 WindowSelectorController::~WindowSelectorController() { |
| 23 // Destroy widgets that may be still animating if shell shuts down soon after | 24 // Destroy widgets that may be still animating if shell shuts down soon after |
| 24 // exiting overview mode. | 25 // exiting overview mode. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 47 // Don't start overview if window selection is not allowed. | 48 // Don't start overview if window selection is not allowed. |
| 48 if (!CanSelect()) | 49 if (!CanSelect()) |
| 49 return false; | 50 return false; |
| 50 | 51 |
| 51 auto windows = Shell::Get()->mru_window_tracker()->BuildMruWindowList(); | 52 auto windows = Shell::Get()->mru_window_tracker()->BuildMruWindowList(); |
| 52 auto end = | 53 auto end = |
| 53 std::remove_if(windows.begin(), windows.end(), | 54 std::remove_if(windows.begin(), windows.end(), |
| 54 std::not1(std::ptr_fun(&WindowSelector::IsSelectable))); | 55 std::not1(std::ptr_fun(&WindowSelector::IsSelectable))); |
| 55 windows.resize(end - windows.begin()); | 56 windows.resize(end - windows.begin()); |
| 56 | 57 |
| 57 // Don't enter overview mode with no windows. | 58 if (!Shell::Get()->IsSplitViewModeActive()) { |
| 58 if (windows.empty()) | 59 // Don't enter overview with no window if the split view mode is inactive. |
| 59 return false; | 60 if (windows.empty()) |
| 61 return false; |
| 62 } else { |
| 63 // Don't enter overview with less than 1 window if the split view mode is |
| 64 // active. |
| 65 if (windows.size() <= 1) |
| 66 return false; |
| 67 |
| 68 // Remove the default snapped window from the window list. The default |
| 69 // snapped window occupy one side of the screen, while the other windows |
| 70 // occupy the other side of the screen in overview mode. The default snap |
| 71 // position is the position where the window was firstly snapped. See |
| 72 // |default_snap_position_| in SplitViewController for more detail. |
| 73 aura::Window* default_snapped_window = |
| 74 Shell::Get()->split_view_controller()->GetDefaultSnappedWindow(); |
| 75 auto iter = |
| 76 std::find(windows.begin(), windows.end(), default_snapped_window); |
| 77 DCHECK(iter != windows.end()); |
| 78 windows.erase(iter); |
| 79 } |
| 60 | 80 |
| 61 Shell::Get()->NotifyOverviewModeStarting(); | 81 Shell::Get()->NotifyOverviewModeStarting(); |
| 62 window_selector_.reset(new WindowSelector(this)); | 82 window_selector_.reset(new WindowSelector(this)); |
| 63 window_selector_->Init(windows); | 83 window_selector_->Init(windows); |
| 64 OnSelectionStarted(); | 84 OnSelectionStarted(); |
| 65 } | 85 } |
| 66 return true; | 86 return true; |
| 67 } | 87 } |
| 68 | 88 |
| 69 bool WindowSelectorController::IsSelecting() const { | 89 bool WindowSelectorController::IsSelecting() const { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 140 } |
| 121 | 141 |
| 122 void WindowSelectorController::OnSelectionStarted() { | 142 void WindowSelectorController::OnSelectionStarted() { |
| 123 if (!last_selection_time_.is_null()) { | 143 if (!last_selection_time_.is_null()) { |
| 124 UMA_HISTOGRAM_LONG_TIMES("Ash.WindowSelector.TimeBetweenUse", | 144 UMA_HISTOGRAM_LONG_TIMES("Ash.WindowSelector.TimeBetweenUse", |
| 125 base::Time::Now() - last_selection_time_); | 145 base::Time::Now() - last_selection_time_); |
| 126 } | 146 } |
| 127 } | 147 } |
| 128 | 148 |
| 129 } // namespace ash | 149 } // namespace ash |
| OLD | NEW |