Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/focus_cycler.h" | 5 #include "ash/focus_cycler.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/mru_window_tracker.h" | 8 #include "ash/wm/mru_window_tracker.h" |
| 9 #include "ash/wm/window_cycle_controller.h" | 9 #include "ash/wm/window_state.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| 11 #include "ui/aura/client/activation_client.h" | 11 #include "ui/aura/client/activation_client.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 #include "ui/views/accessible_pane_view.h" | 13 #include "ui/views/accessible_pane_view.h" |
| 14 #include "ui/views/focus/focus_search.h" | 14 #include "ui/views/focus/focus_search.h" |
| 15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 16 | 16 |
| 17 namespace ash { | 17 namespace ash { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 index = (index + 1) % count; | 70 index = (index + 1) % count; |
| 71 else | 71 else |
| 72 index = ((index - 1) + count) % count; | 72 index = ((index - 1) + count) % count; |
| 73 | 73 |
| 74 // Ensure that we don't loop more than once. | 74 // Ensure that we don't loop more than once. |
| 75 if (index == start_index) | 75 if (index == start_index) |
| 76 break; | 76 break; |
| 77 | 77 |
| 78 if (index == browser_index) { | 78 if (index == browser_index) { |
| 79 // Activate the most recently active browser window. | 79 // Activate the most recently active browser window. |
| 80 ash::Shell::GetInstance()->window_cycle_controller()->HandleCycleWindow( | 80 MruWindowTracker::WindowList mru_windows( |
| 81 WindowCycleController::FORWARD, false); | 81 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList()); |
| 82 | 82 if (mru_windows.empty()) |
| 83 // Rotate pane focus within that window. | |
| 84 aura::Window* window = ash::wm::GetActiveWindow(); | |
| 85 if (!window) | |
| 86 break; | 83 break; |
| 84 aura::Window* window(mru_windows[mru_windows.size() > 1 ? 1 : 0]); | |
| 85 wm::GetWindowState(window)->Activate(); | |
|
oshima
2014/02/28 17:54:39
So this case, we're activating the top most (if th
flackr
2014/03/11 19:55:07
Looking into this we only ever expect to cycle foc
| |
| 87 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); | 86 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| 88 if (!widget) | 87 if (!widget) |
| 89 break; | 88 break; |
| 90 views::FocusManager* focus_manager = widget->GetFocusManager(); | 89 views::FocusManager* focus_manager = widget->GetFocusManager(); |
| 91 focus_manager->ClearFocus(); | 90 focus_manager->ClearFocus(); |
| 92 focus_manager->RotatePaneFocus( | 91 focus_manager->RotatePaneFocus( |
| 93 direction == BACKWARD ? | 92 direction == BACKWARD ? |
| 94 views::FocusManager::kBackward : views::FocusManager::kForward, | 93 views::FocusManager::kBackward : views::FocusManager::kForward, |
| 95 views::FocusManager::kWrap); | 94 views::FocusManager::kWrap); |
| 96 break; | 95 break; |
| 97 } else { | 96 } else { |
| 98 if (FocusWidget(widgets_[index])) | 97 if (FocusWidget(widgets_[index])) |
| 99 break; | 98 break; |
| 100 } | 99 } |
| 101 } | 100 } |
| 102 } | 101 } |
| 103 | 102 |
| 104 bool FocusCycler::FocusWidget(views::Widget* widget) { | 103 bool FocusCycler::FocusWidget(views::Widget* widget) { |
| 105 // Note: It is not necessary to set the focus directly to the pane since that | 104 // Note: It is not necessary to set the focus directly to the pane since that |
| 106 // will be taken care of by the widget activation. | 105 // will be taken care of by the widget activation. |
| 107 widget_activating_ = widget; | 106 widget_activating_ = widget; |
| 108 widget->Activate(); | 107 widget->Activate(); |
| 109 widget_activating_ = NULL; | 108 widget_activating_ = NULL; |
| 110 return widget->IsActive(); | 109 return widget->IsActive(); |
| 111 } | 110 } |
| 112 | 111 |
| 113 } // namespace internal | 112 } // namespace internal |
| 114 | 113 |
| 115 } // namespace ash | 114 } // namespace ash |
| OLD | NEW |