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

Side by Side Diff: ash/common/focus_cycler.cc

Issue 2798333005: Moves WmWindow::GetInternalWidget() into a standalone function (Closed)
Patch Set: Created 3 years, 8 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/common/devtools/ash_devtools_unittest.cc ('k') | ash/common/system/tray/system_tray.cc » ('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 (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/common/focus_cycler.h" 5 #include "ash/common/focus_cycler.h"
6 6
7 #include "ash/common/wm/mru_window_tracker.h" 7 #include "ash/common/wm/mru_window_tracker.h"
8 #include "ash/common/wm/window_state.h" 8 #include "ash/common/wm/window_state.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/common/wm_window.h" 10 #include "ash/common/wm_window.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/wm/widget_finder.h"
12 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
13 #include "ui/views/accessible_pane_view.h" 14 #include "ui/views/accessible_pane_view.h"
14 #include "ui/views/focus/focus_search.h" 15 #include "ui/views/focus/focus_search.h"
15 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
16 #include "ui/wm/public/activation_client.h" 17 #include "ui/wm/public/activation_client.h"
17 18
18 namespace ash { 19 namespace ash {
19 20
20 namespace { 21 namespace {
21 22
(...skipping 13 matching lines...) Expand all
35 36
36 void FocusCycler::RemoveWidget(views::Widget* widget) { 37 void FocusCycler::RemoveWidget(views::Widget* widget) {
37 auto iter = std::find(widgets_.begin(), widgets_.end(), widget); 38 auto iter = std::find(widgets_.begin(), widgets_.end(), widget);
38 if (iter != widgets_.end()) 39 if (iter != widgets_.end())
39 widgets_.erase(iter); 40 widgets_.erase(iter);
40 } 41 }
41 42
42 void FocusCycler::RotateFocus(Direction direction) { 43 void FocusCycler::RotateFocus(Direction direction) {
43 WmWindow* window = WmWindow::Get(wm::GetActiveWindow()); 44 WmWindow* window = WmWindow::Get(wm::GetActiveWindow());
44 if (window) { 45 if (window) {
45 views::Widget* widget = window->GetInternalWidget(); 46 views::Widget* widget = GetInternalWidgetForWindow(window->aura_window());
46 // First try to rotate focus within the active widget. If that succeeds, 47 // First try to rotate focus within the active widget. If that succeeds,
47 // we're done. 48 // we're done.
48 if (widget && 49 if (widget &&
49 widget->GetFocusManager()->RotatePaneFocus( 50 widget->GetFocusManager()->RotatePaneFocus(
50 direction == BACKWARD ? views::FocusManager::kBackward 51 direction == BACKWARD ? views::FocusManager::kBackward
51 : views::FocusManager::kForward, 52 : views::FocusManager::kForward,
52 views::FocusManager::kNoWrap)) { 53 views::FocusManager::kNoWrap)) {
53 return; 54 return;
54 } 55 }
55 } 56 }
(...skipping 24 matching lines...) Expand all
80 break; 81 break;
81 82
82 if (index == browser_index) { 83 if (index == browser_index) {
83 // Activate the most recently active browser window. 84 // Activate the most recently active browser window.
84 MruWindowTracker::WindowList mru_windows( 85 MruWindowTracker::WindowList mru_windows(
85 Shell::Get()->mru_window_tracker()->BuildMruWindowList()); 86 Shell::Get()->mru_window_tracker()->BuildMruWindowList());
86 if (mru_windows.empty()) 87 if (mru_windows.empty())
87 break; 88 break;
88 WmWindow* window = mru_windows.front(); 89 WmWindow* window = mru_windows.front();
89 window->GetWindowState()->Activate(); 90 window->GetWindowState()->Activate();
90 views::Widget* widget = window->GetInternalWidget(); 91 views::Widget* widget = GetInternalWidgetForWindow(window->aura_window());
91 if (!widget) 92 if (!widget)
92 break; 93 break;
93 views::FocusManager* focus_manager = widget->GetFocusManager(); 94 views::FocusManager* focus_manager = widget->GetFocusManager();
94 focus_manager->ClearFocus(); 95 focus_manager->ClearFocus();
95 focus_manager->RotatePaneFocus(direction == BACKWARD 96 focus_manager->RotatePaneFocus(direction == BACKWARD
96 ? views::FocusManager::kBackward 97 ? views::FocusManager::kBackward
97 : views::FocusManager::kForward, 98 : views::FocusManager::kForward,
98 views::FocusManager::kWrap); 99 views::FocusManager::kWrap);
99 break; 100 break;
100 } else { 101 } else {
101 if (FocusWidget(widgets_[index])) 102 if (FocusWidget(widgets_[index]))
102 break; 103 break;
103 } 104 }
104 } 105 }
105 } 106 }
106 107
107 bool FocusCycler::FocusWidget(views::Widget* widget) { 108 bool FocusCycler::FocusWidget(views::Widget* widget) {
108 // Note: It is not necessary to set the focus directly to the pane since that 109 // Note: It is not necessary to set the focus directly to the pane since that
109 // will be taken care of by the widget activation. 110 // will be taken care of by the widget activation.
110 widget_activating_ = widget; 111 widget_activating_ = widget;
111 widget->Activate(); 112 widget->Activate();
112 widget_activating_ = NULL; 113 widget_activating_ = NULL;
113 return widget->IsActive(); 114 return widget->IsActive();
114 } 115 }
115 116
116 } // namespace ash 117 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/devtools/ash_devtools_unittest.cc ('k') | ash/common/system/tray/system_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698