Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Side by Side Diff: ash/wm/overview/window_selector_controller.cc

Issue 2918403006: CrOS Tablet Window management - Split Screen part I (Closed)
Patch Set: Add unittests. Will split the CL into two CLs. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/overview/window_selector_controller.h ('k') | ash/wm/overview/window_selector_item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_grid.h"
13 #include "ash/wm/overview/window_selector.h" 14 #include "ash/wm/overview/window_selector.h"
15 #include "ash/wm/overview/window_selector_item.h"
14 #include "ash/wm/screen_pinning_controller.h" 16 #include "ash/wm/screen_pinning_controller.h"
17 #include "ash/wm/splitview/split_view_controller.h"
15 #include "ash/wm/window_state.h" 18 #include "ash/wm/window_state.h"
16 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
17 20
18 namespace ash { 21 namespace ash {
19 22
20 WindowSelectorController::WindowSelectorController() {} 23 WindowSelectorController::WindowSelectorController() {}
21 24
22 WindowSelectorController::~WindowSelectorController() { 25 WindowSelectorController::~WindowSelectorController() {
23 // Destroy widgets that may be still animating if shell shuts down soon after 26 // Destroy widgets that may be still animating if shell shuts down soon after
24 // exiting overview mode. 27 // exiting overview mode.
(...skipping 22 matching lines...) Expand all
47 // Don't start overview if window selection is not allowed. 50 // Don't start overview if window selection is not allowed.
48 if (!CanSelect()) 51 if (!CanSelect())
49 return false; 52 return false;
50 53
51 auto windows = Shell::Get()->mru_window_tracker()->BuildMruWindowList(); 54 auto windows = Shell::Get()->mru_window_tracker()->BuildMruWindowList();
52 auto end = 55 auto end =
53 std::remove_if(windows.begin(), windows.end(), 56 std::remove_if(windows.begin(), windows.end(),
54 std::not1(std::ptr_fun(&WindowSelector::IsSelectable))); 57 std::not1(std::ptr_fun(&WindowSelector::IsSelectable)));
55 windows.resize(end - windows.begin()); 58 windows.resize(end - windows.begin());
56 59
57 // Don't enter overview mode with no windows. 60 if (!Shell::Get()->IsSplitViewModeActive()) {
58 if (windows.empty()) 61 // Don't enter overview with no window if the split view mode is inactive.
59 return false; 62 if (windows.empty())
63 return false;
64 } else {
65 // Don't enter overview with less than 1 window if the split view mode is
66 // active.
67 if (windows.size() <= 1)
68 return false;
69
70 // Remove the default snapped window from the window list. The default
71 // snapped window occupies one side of the screen, while the other windows
72 // occupy the other side of the screen in overview mode. The default snap
73 // position is the position where the window was first snapped. See
74 // |default_snap_position_| in SplitViewController for more detail.
75 aura::Window* default_snapped_window =
76 Shell::Get()->split_view_controller()->GetDefaultSnappedWindow();
77 auto iter =
78 std::find(windows.begin(), windows.end(), default_snapped_window);
79 DCHECK(iter != windows.end());
80 windows.erase(iter);
81 }
60 82
61 Shell::Get()->NotifyOverviewModeStarting(); 83 Shell::Get()->NotifyOverviewModeStarting();
62 window_selector_.reset(new WindowSelector(this)); 84 window_selector_.reset(new WindowSelector(this));
63 window_selector_->Init(windows); 85 window_selector_->Init(windows);
64 OnSelectionStarted(); 86 OnSelectionStarted();
65 } 87 }
66 return true; 88 return true;
67 } 89 }
68 90
69 bool WindowSelectorController::IsSelecting() const { 91 bool WindowSelectorController::IsSelecting() const {
70 return window_selector_.get() != NULL; 92 return window_selector_.get() != NULL;
71 } 93 }
72 94
73 void WindowSelectorController::IncrementSelection(int increment) { 95 void WindowSelectorController::IncrementSelection(int increment) {
74 DCHECK(IsSelecting()); 96 DCHECK(IsSelecting());
75 window_selector_->IncrementSelection(increment); 97 window_selector_->IncrementSelection(increment);
76 } 98 }
77 99
78 bool WindowSelectorController::AcceptSelection() { 100 bool WindowSelectorController::AcceptSelection() {
79 DCHECK(IsSelecting()); 101 DCHECK(IsSelecting());
80 return window_selector_->AcceptSelection(); 102 return window_selector_->AcceptSelection();
81 } 103 }
82 104
83 bool WindowSelectorController::IsRestoringMinimizedWindows() const { 105 bool WindowSelectorController::IsRestoringMinimizedWindows() const {
84 return window_selector_.get() != NULL && 106 return window_selector_.get() != NULL &&
85 window_selector_->restoring_minimized_windows(); 107 window_selector_->restoring_minimized_windows();
86 } 108 }
87 109
110 std::vector<aura::Window*>
111 WindowSelectorController::GetWindowsListInOverviewGridsForTesting() {
112 std::vector<aura::Window*> windows;
113 for (const std::unique_ptr<WindowGrid>& grid :
114 window_selector_->grid_list_for_testing()) {
115 for (const auto& window_selector_item : grid->window_list())
116 windows.push_back(window_selector_item->GetWindow());
117 }
118 return windows;
119 }
120
88 // TODO(flackr): Make WindowSelectorController observe the activation of 121 // TODO(flackr): Make WindowSelectorController observe the activation of
89 // windows, so we can remove WindowSelectorDelegate. 122 // windows, so we can remove WindowSelectorDelegate.
90 void WindowSelectorController::OnSelectionEnded() { 123 void WindowSelectorController::OnSelectionEnded() {
91 window_selector_->Shutdown(); 124 window_selector_->Shutdown();
92 window_selector_.reset(); 125 window_selector_.reset();
93 last_selection_time_ = base::Time::Now(); 126 last_selection_time_ = base::Time::Now();
94 Shell::Get()->NotifyOverviewModeEnded(); 127 Shell::Get()->NotifyOverviewModeEnded();
95 } 128 }
96 129
97 void WindowSelectorController::AddDelayedAnimationObserver( 130 void WindowSelectorController::AddDelayedAnimationObserver(
(...skipping 22 matching lines...) Expand all
120 } 153 }
121 154
122 void WindowSelectorController::OnSelectionStarted() { 155 void WindowSelectorController::OnSelectionStarted() {
123 if (!last_selection_time_.is_null()) { 156 if (!last_selection_time_.is_null()) {
124 UMA_HISTOGRAM_LONG_TIMES("Ash.WindowSelector.TimeBetweenUse", 157 UMA_HISTOGRAM_LONG_TIMES("Ash.WindowSelector.TimeBetweenUse",
125 base::Time::Now() - last_selection_time_); 158 base::Time::Now() - last_selection_time_);
126 } 159 }
127 } 160 }
128 161
129 } // namespace ash 162 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overview/window_selector_controller.h ('k') | ash/wm/overview/window_selector_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698