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 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/accessibility_delegate.h" | 12 #include "ash/accessibility_delegate.h" |
13 #include "ash/ash_switches.h" | 13 #include "ash/ash_switches.h" |
14 #include "ash/metrics/user_metrics_recorder.h" | 14 #include "ash/metrics/user_metrics_recorder.h" |
15 #include "ash/root_window_controller.h" | 15 #include "ash/root_window_controller.h" |
16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
17 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
18 #include "ash/switchable_windows.h" | 18 #include "ash/switchable_windows.h" |
| 19 #include "ash/wm/mru_window_tracker.h" |
19 #include "ash/wm/overview/window_grid.h" | 20 #include "ash/wm/overview/window_grid.h" |
20 #include "ash/wm/overview/window_selector_delegate.h" | 21 #include "ash/wm/overview/window_selector_delegate.h" |
21 #include "ash/wm/overview/window_selector_item.h" | 22 #include "ash/wm/overview/window_selector_item.h" |
22 #include "ash/wm/panels/panel_layout_manager.h" | 23 #include "ash/wm/panels/panel_layout_manager.h" |
23 #include "ash/wm/window_state.h" | 24 #include "ash/wm/window_state.h" |
24 #include "base/auto_reset.h" | 25 #include "base/auto_reset.h" |
25 #include "base/command_line.h" | 26 #include "base/command_line.h" |
26 #include "base/metrics/histogram.h" | 27 #include "base/metrics/histogram.h" |
27 #include "third_party/skia/include/core/SkPaint.h" | 28 #include "third_party/skia/include/core/SkPaint.h" |
28 #include "third_party/skia/include/core/SkPath.h" | 29 #include "third_party/skia/include/core/SkPath.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 ScopedVector<WindowGrid>::iterator iter = | 387 ScopedVector<WindowGrid>::iterator iter = |
387 std::find(grid_list_.begin(), grid_list_.end(), grid); | 388 std::find(grid_list_.begin(), grid_list_.end(), grid); |
388 DCHECK(iter != grid_list_.end()); | 389 DCHECK(iter != grid_list_.end()); |
389 grid_list_.erase(iter); | 390 grid_list_.erase(iter); |
390 // TODO(flackr): Use the previous index for more than two displays. | 391 // TODO(flackr): Use the previous index for more than two displays. |
391 selected_grid_index_ = 0; | 392 selected_grid_index_ = 0; |
392 if (grid_list_.empty()) | 393 if (grid_list_.empty()) |
393 CancelSelection(); | 394 CancelSelection(); |
394 } | 395 } |
395 | 396 |
| 397 void WindowSelector::SelectWindow(aura::Window* window) { |
| 398 // Record UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED if the user is selecting |
| 399 // a window other than the window that was active prior to entering overview |
| 400 // mode (i.e., the window at the front of the MRU list). |
| 401 MruWindowTracker::WindowList window_list = |
| 402 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList(); |
| 403 if (window_list.size() > 0 && window_list[0] != window) { |
| 404 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 405 UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED); |
| 406 } |
| 407 |
| 408 wm::GetWindowState(window)->Activate(); |
| 409 } |
| 410 |
396 bool WindowSelector::HandleKeyEvent(views::Textfield* sender, | 411 bool WindowSelector::HandleKeyEvent(views::Textfield* sender, |
397 const ui::KeyEvent& key_event) { | 412 const ui::KeyEvent& key_event) { |
398 if (key_event.type() != ui::ET_KEY_PRESSED) | 413 if (key_event.type() != ui::ET_KEY_PRESSED) |
399 return false; | 414 return false; |
400 | 415 |
401 switch (key_event.key_code()) { | 416 switch (key_event.key_code()) { |
402 case ui::VKEY_ESCAPE: | 417 case ui::VKEY_ESCAPE: |
403 CancelSelection(); | 418 CancelSelection(); |
404 break; | 419 break; |
405 case ui::VKEY_UP: | 420 case ui::VKEY_UP: |
(...skipping 17 matching lines...) Expand all Loading... |
423 // Ignore if no item is selected. | 438 // Ignore if no item is selected. |
424 if (!grid_list_[selected_grid_index_]->is_selecting()) | 439 if (!grid_list_[selected_grid_index_]->is_selecting()) |
425 return false; | 440 return false; |
426 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.ArrowKeyPresses", | 441 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.ArrowKeyPresses", |
427 num_key_presses_); | 442 num_key_presses_); |
428 UMA_HISTOGRAM_CUSTOM_COUNTS( | 443 UMA_HISTOGRAM_CUSTOM_COUNTS( |
429 "Ash.WindowSelector.KeyPressesOverItemsRatio", | 444 "Ash.WindowSelector.KeyPressesOverItemsRatio", |
430 (num_key_presses_ * 100) / num_items_, 1, 300, 30); | 445 (num_key_presses_ * 100) / num_items_, 1, 300, 30); |
431 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 446 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
432 UMA_WINDOW_OVERVIEW_ENTER_KEY); | 447 UMA_WINDOW_OVERVIEW_ENTER_KEY); |
433 wm::GetWindowState(grid_list_[selected_grid_index_]-> | 448 SelectWindow( |
434 SelectedWindow()->GetWindow())->Activate(); | 449 grid_list_[selected_grid_index_]->SelectedWindow()->GetWindow()); |
435 break; | 450 break; |
436 default: | 451 default: |
437 // Not a key we are interested in, allow the textfield to handle it. | 452 // Not a key we are interested in, allow the textfield to handle it. |
438 return false; | 453 return false; |
439 } | 454 } |
440 return true; | 455 return true; |
441 } | 456 } |
442 | 457 |
443 void WindowSelector::OnDisplayAdded(const gfx::Display& display) { | 458 void WindowSelector::OnDisplayAdded(const gfx::Display& display) { |
444 } | 459 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 for (size_t i = 0; | 589 for (size_t i = 0; |
575 i <= grid_list_.size() && | 590 i <= grid_list_.size() && |
576 grid_list_[selected_grid_index_]->Move(direction, animate); i++) { | 591 grid_list_[selected_grid_index_]->Move(direction, animate); i++) { |
577 // TODO(flackr): If there are more than two monitors, move between grids | 592 // TODO(flackr): If there are more than two monitors, move between grids |
578 // in the requested direction. | 593 // in the requested direction. |
579 selected_grid_index_ = (selected_grid_index_ + 1) % grid_list_.size(); | 594 selected_grid_index_ = (selected_grid_index_ + 1) % grid_list_.size(); |
580 } | 595 } |
581 } | 596 } |
582 | 597 |
583 } // namespace ash | 598 } // namespace ash |
OLD | NEW |