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

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

Issue 2978273002: Revert of Cros Tablet Window management - Split Screen part II (Closed)
Patch Set: 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"
14 #include "ash/wm/overview/window_selector.h" 13 #include "ash/wm/overview/window_selector.h"
15 #include "ash/wm/overview/window_selector_item.h"
16 #include "ash/wm/screen_pinning_controller.h" 14 #include "ash/wm/screen_pinning_controller.h"
17 #include "ash/wm/splitview/split_view_controller.h"
18 #include "ash/wm/window_state.h" 15 #include "ash/wm/window_state.h"
19 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
20 17
21 namespace ash { 18 namespace ash {
22 19
23 WindowSelectorController::WindowSelectorController() {} 20 WindowSelectorController::WindowSelectorController() {}
24 21
25 WindowSelectorController::~WindowSelectorController() { 22 WindowSelectorController::~WindowSelectorController() {
26 // Destroy widgets that may be still animating if shell shuts down soon after 23 // Destroy widgets that may be still animating if shell shuts down soon after
27 // exiting overview mode. 24 // exiting overview mode.
(...skipping 22 matching lines...) Expand all
50 // Don't start overview if window selection is not allowed. 47 // Don't start overview if window selection is not allowed.
51 if (!CanSelect()) 48 if (!CanSelect())
52 return false; 49 return false;
53 50
54 auto windows = Shell::Get()->mru_window_tracker()->BuildMruWindowList(); 51 auto windows = Shell::Get()->mru_window_tracker()->BuildMruWindowList();
55 auto end = 52 auto end =
56 std::remove_if(windows.begin(), windows.end(), 53 std::remove_if(windows.begin(), windows.end(),
57 std::not1(std::ptr_fun(&WindowSelector::IsSelectable))); 54 std::not1(std::ptr_fun(&WindowSelector::IsSelectable)));
58 windows.resize(end - windows.begin()); 55 windows.resize(end - windows.begin());
59 56
60 if (!Shell::Get()->IsSplitViewModeActive()) { 57 // Don't enter overview mode with no windows.
61 // Don't enter overview with no window if the split view mode is inactive. 58 if (windows.empty())
62 if (windows.empty()) 59 return false;
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 }
82 60
83 Shell::Get()->NotifyOverviewModeStarting(); 61 Shell::Get()->NotifyOverviewModeStarting();
84 window_selector_.reset(new WindowSelector(this)); 62 window_selector_.reset(new WindowSelector(this));
85 window_selector_->Init(windows); 63 window_selector_->Init(windows);
86 OnSelectionStarted(); 64 OnSelectionStarted();
87 } 65 }
88 return true; 66 return true;
89 } 67 }
90 68
91 bool WindowSelectorController::IsSelecting() const { 69 bool WindowSelectorController::IsSelecting() const {
92 return window_selector_.get() != NULL; 70 return window_selector_.get() != NULL;
93 } 71 }
94 72
95 void WindowSelectorController::IncrementSelection(int increment) { 73 void WindowSelectorController::IncrementSelection(int increment) {
96 DCHECK(IsSelecting()); 74 DCHECK(IsSelecting());
97 window_selector_->IncrementSelection(increment); 75 window_selector_->IncrementSelection(increment);
98 } 76 }
99 77
100 bool WindowSelectorController::AcceptSelection() { 78 bool WindowSelectorController::AcceptSelection() {
101 DCHECK(IsSelecting()); 79 DCHECK(IsSelecting());
102 return window_selector_->AcceptSelection(); 80 return window_selector_->AcceptSelection();
103 } 81 }
104 82
105 bool WindowSelectorController::IsRestoringMinimizedWindows() const { 83 bool WindowSelectorController::IsRestoringMinimizedWindows() const {
106 return window_selector_.get() != NULL && 84 return window_selector_.get() != NULL &&
107 window_selector_->restoring_minimized_windows(); 85 window_selector_->restoring_minimized_windows();
108 } 86 }
109 87
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
121 // TODO(flackr): Make WindowSelectorController observe the activation of 88 // TODO(flackr): Make WindowSelectorController observe the activation of
122 // windows, so we can remove WindowSelectorDelegate. 89 // windows, so we can remove WindowSelectorDelegate.
123 void WindowSelectorController::OnSelectionEnded() { 90 void WindowSelectorController::OnSelectionEnded() {
124 window_selector_->Shutdown(); 91 window_selector_->Shutdown();
125 window_selector_.reset(); 92 window_selector_.reset();
126 last_selection_time_ = base::Time::Now(); 93 last_selection_time_ = base::Time::Now();
127 Shell::Get()->NotifyOverviewModeEnded(); 94 Shell::Get()->NotifyOverviewModeEnded();
128 } 95 }
129 96
130 void WindowSelectorController::AddDelayedAnimationObserver( 97 void WindowSelectorController::AddDelayedAnimationObserver(
(...skipping 22 matching lines...) Expand all
153 } 120 }
154 121
155 void WindowSelectorController::OnSelectionStarted() { 122 void WindowSelectorController::OnSelectionStarted() {
156 if (!last_selection_time_.is_null()) { 123 if (!last_selection_time_.is_null()) {
157 UMA_HISTOGRAM_LONG_TIMES("Ash.WindowSelector.TimeBetweenUse", 124 UMA_HISTOGRAM_LONG_TIMES("Ash.WindowSelector.TimeBetweenUse",
158 base::Time::Now() - last_selection_time_); 125 base::Time::Now() - last_selection_time_);
159 } 126 }
160 } 127 }
161 128
162 } // namespace ash 129 } // 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