OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/window_cycle_controller.h" | 5 #include "ash/wm/window_cycle_controller.h" |
6 | 6 |
7 #include "ash/metrics/task_switch_source.h" | 7 #include "ash/metrics/task_switch_source.h" |
8 #include "ash/public/cpp/shell_window_ids.h" | 8 #include "ash/public/cpp/shell_window_ids.h" |
9 #include "ash/session/session_controller.h" | 9 #include "ash/session/session_controller.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 if (!CanCycle()) | 48 if (!CanCycle()) |
49 return; | 49 return; |
50 | 50 |
51 if (!IsCycling()) | 51 if (!IsCycling()) |
52 StartCycling(); | 52 StartCycling(); |
53 | 53 |
54 Step(direction); | 54 Step(direction); |
55 } | 55 } |
56 | 56 |
57 void WindowCycleController::StartCycling() { | 57 void WindowCycleController::StartCycling() { |
58 WindowCycleList::WindowList window_list = WmWindow::ToAuraWindows( | 58 WindowCycleList::WindowList window_list = |
59 Shell::Get()->mru_window_tracker()->BuildMruWindowList()); | 59 Shell::Get()->mru_window_tracker()->BuildMruWindowList(); |
60 // Exclude windows: | 60 // Exclude windows: |
61 // - non user positionable windows, such as extension popups. | 61 // - non user positionable windows, such as extension popups. |
62 // - windows being dragged | 62 // - windows being dragged |
63 // - the AppList window, which will hide as soon as cycling starts | 63 // - the AppList window, which will hide as soon as cycling starts |
64 // anyway. It doesn't make sense to count it as a "switchable" window, yet | 64 // anyway. It doesn't make sense to count it as a "switchable" window, yet |
65 // a lot of code relies on the MRU list returning the app window. If we | 65 // a lot of code relies on the MRU list returning the app window. If we |
66 // don't manually remove it, the window cycling UI won't crash or misbehave, | 66 // don't manually remove it, the window cycling UI won't crash or misbehave, |
67 // but there will be a flicker as the target window changes. Also exclude | 67 // but there will be a flicker as the target window changes. Also exclude |
68 // unselectable windows such as extension popups. | 68 // unselectable windows such as extension popups. |
69 auto window_is_ineligible = [](aura::Window* window) { | 69 auto window_is_ineligible = [](aura::Window* window) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 DCHECK(window_cycle_list_.get()); | 103 DCHECK(window_cycle_list_.get()); |
104 window_cycle_list_->Step(direction); | 104 window_cycle_list_->Step(direction); |
105 } | 105 } |
106 | 106 |
107 void WindowCycleController::StopCycling() { | 107 void WindowCycleController::StopCycling() { |
108 UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.SelectionDepth", | 108 UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.SelectionDepth", |
109 window_cycle_list_->current_index() + 1); | 109 window_cycle_list_->current_index() + 1); |
110 window_cycle_list_.reset(); | 110 window_cycle_list_.reset(); |
111 | 111 |
112 aura::Window* active_window_after_window_cycle = | 112 aura::Window* active_window_after_window_cycle = |
113 GetActiveWindow(WmWindow::ToAuraWindows( | 113 GetActiveWindow(Shell::Get()->mru_window_tracker()->BuildMruWindowList()); |
114 Shell::Get()->mru_window_tracker()->BuildMruWindowList())); | |
115 | 114 |
116 // Remove our key event filter. | 115 // Remove our key event filter. |
117 event_filter_.reset(); | 116 event_filter_.reset(); |
118 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowCycleController.CycleTime", | 117 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowCycleController.CycleTime", |
119 base::Time::Now() - cycle_start_time_); | 118 base::Time::Now() - cycle_start_time_); |
120 | 119 |
121 if (active_window_after_window_cycle != nullptr && | 120 if (active_window_after_window_cycle != nullptr && |
122 active_window_before_window_cycle_ != active_window_after_window_cycle) { | 121 active_window_before_window_cycle_ != active_window_after_window_cycle) { |
123 ShellPort::Get()->RecordTaskSwitchMetric( | 122 ShellPort::Get()->RecordTaskSwitchMetric( |
124 TaskSwitchSource::WINDOW_CYCLE_CONTROLLER); | 123 TaskSwitchSource::WINDOW_CYCLE_CONTROLLER); |
125 } | 124 } |
126 active_window_before_window_cycle_ = nullptr; | 125 active_window_before_window_cycle_ = nullptr; |
127 } | 126 } |
128 | 127 |
129 } // namespace ash | 128 } // namespace ash |
OLD | NEW |