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.h" | 5 #include "ash/wm/overview/window_selector.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/accessibility_delegate.h" | 9 #include "ash/accessibility_delegate.h" |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 } | 88 } |
89 | 89 |
90 } // namespace | 90 } // namespace |
91 | 91 |
92 WindowSelector::WindowSelector(const WindowList& windows, | 92 WindowSelector::WindowSelector(const WindowList& windows, |
93 WindowSelectorDelegate* delegate) | 93 WindowSelectorDelegate* delegate) |
94 : delegate_(delegate), | 94 : delegate_(delegate), |
95 restore_focus_window_(aura::client::GetFocusClient( | 95 restore_focus_window_(aura::client::GetFocusClient( |
96 Shell::GetPrimaryRootWindow())->GetFocusedWindow()), | 96 Shell::GetPrimaryRootWindow())->GetFocusedWindow()), |
97 ignore_activations_(false), | 97 ignore_activations_(false), |
98 selected_grid_index_(0), | |
98 overview_start_time_(base::Time::Now()), | 99 overview_start_time_(base::Time::Now()), |
99 selected_grid_index_(0) { | 100 num_key_presses_(0), |
101 num_items_(0), | |
102 num_closed_items_(0) { | |
100 DCHECK(delegate_); | 103 DCHECK(delegate_); |
101 Shell* shell = Shell::GetInstance(); | 104 Shell* shell = Shell::GetInstance(); |
102 shell->OnOverviewModeStarting(); | 105 shell->OnOverviewModeStarting(); |
103 | 106 |
104 if (restore_focus_window_) | 107 if (restore_focus_window_) |
105 restore_focus_window_->AddObserver(this); | 108 restore_focus_window_->AddObserver(this); |
106 | 109 |
107 const aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 110 const aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
108 size_t items = 0; | |
109 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); | 111 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); |
110 iter != root_windows.end(); iter++) { | 112 iter != root_windows.end(); iter++) { |
111 // Observed switchable containers for newly created windows on all root | 113 // Observed switchable containers for newly created windows on all root |
112 // windows. | 114 // windows. |
113 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { | 115 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { |
114 aura::Window* container = Shell::GetContainer(*iter, | 116 aura::Window* container = Shell::GetContainer(*iter, |
115 kSwitchableWindowContainerIds[i]); | 117 kSwitchableWindowContainerIds[i]); |
116 container->AddObserver(this); | 118 container->AddObserver(this); |
117 observed_windows_.insert(container); | 119 observed_windows_.insert(container); |
118 } | 120 } |
119 scoped_ptr<WindowGrid> grid(new WindowGrid(*iter, windows, this)); | 121 scoped_ptr<WindowGrid> grid(new WindowGrid(*iter, windows, this)); |
120 if (grid->empty()) | 122 if (grid->empty()) |
121 continue; | 123 continue; |
124 num_items_ += grid->size(); | |
122 grid_list_.push_back(grid.release()); | 125 grid_list_.push_back(grid.release()); |
123 items += grid_list_.size(); | |
124 } | 126 } |
125 | 127 |
126 DCHECK(!grid_list_.empty()); | 128 DCHECK(!grid_list_.empty()); |
127 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", items); | 129 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_); |
128 | 130 |
129 shell->activation_client()->AddObserver(this); | 131 shell->activation_client()->AddObserver(this); |
130 | 132 |
131 // Remove focus from active window before entering overview. | 133 // Remove focus from active window before entering overview. |
132 aura::client::GetFocusClient( | 134 aura::client::GetFocusClient( |
133 Shell::GetPrimaryRootWindow())->FocusWindow(NULL); | 135 Shell::GetPrimaryRootWindow())->FocusWindow(NULL); |
134 | 136 |
135 shell->PrependPreTargetHandler(this); | 137 shell->PrependPreTargetHandler(this); |
136 shell->GetScreen()->AddObserver(this); | 138 shell->GetScreen()->AddObserver(this); |
137 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW); | 139 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW); |
(...skipping 24 matching lines...) Expand all Loading... | |
162 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 164 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
163 ScopedTransformOverviewWindow::kTransitionMilliseconds)); | 165 ScopedTransformOverviewWindow::kTransitionMilliseconds)); |
164 settings.SetPreemptionStrategy( | 166 settings.SetPreemptionStrategy( |
165 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 167 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
166 (*iter)->layer()->SetOpacity(1); | 168 (*iter)->layer()->SetOpacity(1); |
167 (*iter)->Show(); | 169 (*iter)->Show(); |
168 } | 170 } |
169 | 171 |
170 shell->RemovePreTargetHandler(this); | 172 shell->RemovePreTargetHandler(this); |
171 shell->GetScreen()->RemoveObserver(this); | 173 shell->GetScreen()->RemoveObserver(this); |
172 UMA_HISTOGRAM_MEDIUM_TIMES( | 174 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowSelector.TimeInOverview", |
173 "Ash.WindowSelector.TimeInOverview", | 175 base::Time::Now() - overview_start_time_); |
174 base::Time::Now() - overview_start_time_); | 176 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.OverviewClosedItems", |
177 num_closed_items_); | |
flackr
2014/06/10 15:39:41
This metric seems like it is the same as num_items
Nina
2014/06/10 16:10:14
Right, I'll update the code to reflect this.
| |
175 | 178 |
176 // TODO(nsatragno): Change this to OnOverviewModeEnded and move it to when | 179 // TODO(nsatragno): Change this to OnOverviewModeEnded and move it to when |
177 // everything is done. | 180 // everything is done. |
178 shell->OnOverviewModeEnding(); | 181 shell->OnOverviewModeEnding(); |
179 | 182 |
180 // Clearing the window list resets the ignored_by_shelf flag on the windows. | 183 // Clearing the window list resets the ignored_by_shelf flag on the windows. |
181 grid_list_.clear(); | 184 grid_list_.clear(); |
182 UpdateShelfVisibility(); | 185 UpdateShelfVisibility(); |
183 } | 186 } |
184 | 187 |
(...skipping 14 matching lines...) Expand all Loading... | |
199 | 202 |
200 void WindowSelector::OnKeyEvent(ui::KeyEvent* event) { | 203 void WindowSelector::OnKeyEvent(ui::KeyEvent* event) { |
201 if (event->type() != ui::ET_KEY_PRESSED) | 204 if (event->type() != ui::ET_KEY_PRESSED) |
202 return; | 205 return; |
203 | 206 |
204 switch (event->key_code()) { | 207 switch (event->key_code()) { |
205 case ui::VKEY_ESCAPE: | 208 case ui::VKEY_ESCAPE: |
206 CancelSelection(); | 209 CancelSelection(); |
207 break; | 210 break; |
208 case ui::VKEY_UP: | 211 case ui::VKEY_UP: |
212 num_key_presses_++; | |
209 Move(WindowSelector::UP); | 213 Move(WindowSelector::UP); |
210 break; | 214 break; |
211 case ui::VKEY_DOWN: | 215 case ui::VKEY_DOWN: |
216 num_key_presses_++; | |
212 Move(WindowSelector::DOWN); | 217 Move(WindowSelector::DOWN); |
213 break; | 218 break; |
214 case ui::VKEY_RIGHT: | 219 case ui::VKEY_RIGHT: |
220 num_key_presses_++; | |
215 Move(WindowSelector::RIGHT); | 221 Move(WindowSelector::RIGHT); |
216 break; | 222 break; |
217 case ui::VKEY_LEFT: | 223 case ui::VKEY_LEFT: |
224 num_key_presses_++; | |
218 Move(WindowSelector::LEFT); | 225 Move(WindowSelector::LEFT); |
219 break; | 226 break; |
220 case ui::VKEY_RETURN: | 227 case ui::VKEY_RETURN: |
221 // Ignore if no item is selected. | 228 // Ignore if no item is selected. |
222 if (!grid_list_[selected_grid_index_]->is_selecting()) | 229 if (!grid_list_[selected_grid_index_]->is_selecting()) |
223 return; | 230 return; |
231 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.ArrowKeyPresses", | |
232 num_key_presses_); | |
233 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
234 "Ash.WindowSelector.KeyPressesOverItemsRatio", | |
235 (num_key_presses_ * 100) / num_items_, 1, 300, 30); | |
236 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | |
237 UMA_WINDOW_OVERVIEW_ENTER_KEY); | |
224 wm::GetWindowState(grid_list_[selected_grid_index_]-> | 238 wm::GetWindowState(grid_list_[selected_grid_index_]-> |
225 SelectedWindow()->SelectionWindow())->Activate(); | 239 SelectedWindow()->SelectionWindow())->Activate(); |
226 break; | 240 break; |
227 default: | 241 default: |
228 // Not a key we are interested in. | 242 // Not a key we are interested in. |
229 return; | 243 return; |
230 } | 244 } |
231 event->StopPropagation(); | 245 event->StopPropagation(); |
232 } | 246 } |
233 | 247 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 // root window, identify it and call Move() on it to initialize the | 379 // root window, identify it and call Move() on it to initialize the |
366 // selection widget. | 380 // selection widget. |
367 // TODO(nsatragno): If there are more than two monitors, move between grids | 381 // TODO(nsatragno): If there are more than two monitors, move between grids |
368 // in the requested direction. | 382 // in the requested direction. |
369 selected_grid_index_ = (selected_grid_index_ + 1) % grid_list_.size(); | 383 selected_grid_index_ = (selected_grid_index_ + 1) % grid_list_.size(); |
370 grid_list_[selected_grid_index_]->Move(direction); | 384 grid_list_[selected_grid_index_]->Move(direction); |
371 } | 385 } |
372 } | 386 } |
373 | 387 |
374 } // namespace ash | 388 } // namespace ash |
OLD | NEW |