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

Side by Side Diff: ash/wm/ash_focus_rules.cc

Issue 2033843003: Makes ash/mus use RootWindowControllerCommon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_mash_wm
Patch Set: merge fail Created 4 years, 6 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/sysui/sysui_application.cc ('k') | ui/aura/window.h » ('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/wm/ash_focus_rules.h" 5 #include "ash/wm/ash_focus_rules.h"
6 6
7 #include "ash/common/shell_window_ids.h" 7 #include "ash/common/shell_window_ids.h"
8 #include "ash/common/wm/window_state.h" 8 #include "ash/common/wm/window_state.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
11 #include "ash/wm/mru_window_tracker.h" 11 #include "ash/wm/mru_window_tracker.h"
12 #include "ash/wm/window_state_aura.h" 12 #include "ash/wm/window_state_aura.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 14
15 namespace ash { 15 namespace ash {
16 namespace wm { 16 namespace wm {
17 namespace { 17 namespace {
18 18
19 // These are the list of container ids of containers which may contain windows
20 // that need to be activated in the order that they should be activated.
21 const int kWindowContainerIds[] = {
22 kShellWindowId_OverlayContainer,
23 kShellWindowId_LockSystemModalContainer,
24 kShellWindowId_SettingBubbleContainer,
25 kShellWindowId_LockScreenContainer,
26 kShellWindowId_SystemModalContainer,
27 kShellWindowId_AlwaysOnTopContainer,
28 kShellWindowId_AppListContainer,
29 kShellWindowId_DefaultContainer,
30
31 // Docked, panel, launcher and status are intentionally checked after other
32 // containers even though these layers are higher. The user expects their
33 // windows to be focused before these elements.
34 kShellWindowId_DockedContainer,
35 kShellWindowId_PanelContainer,
36 kShellWindowId_ShelfContainer,
37 kShellWindowId_StatusContainer, };
38
39 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window, 19 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window,
40 int container_id) { 20 int container_id) {
41 for (; window; window = window->parent()) { 21 for (; window; window = window->parent()) {
42 if (window->id() >= container_id) 22 if (window->id() >= container_id)
43 return true; 23 return true;
44 } 24 }
45 return false; 25 return false;
46 } 26 }
47 27
48 } // namespace 28 } // namespace
(...skipping 19 matching lines...) Expand all
68 return true; 48 return true;
69 } 49 }
70 50
71 //////////////////////////////////////////////////////////////////////////////// 51 ////////////////////////////////////////////////////////////////////////////////
72 // AshFocusRules, ::wm::FocusRules: 52 // AshFocusRules, ::wm::FocusRules:
73 53
74 bool AshFocusRules::SupportsChildActivation(aura::Window* window) const { 54 bool AshFocusRules::SupportsChildActivation(aura::Window* window) const {
75 if (window->id() == kShellWindowId_DefaultContainer) 55 if (window->id() == kShellWindowId_DefaultContainer)
76 return true; 56 return true;
77 57
78 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) { 58 for (size_t i = 0; i < kNumActivatableShellWindowIds; i++) {
79 if (window->id() == kWindowContainerIds[i]) 59 if (window->id() == kActivatableShellWindowIds[i])
80 return true; 60 return true;
81 } 61 }
82 return false; 62 return false;
83 } 63 }
84 64
85 bool AshFocusRules::IsWindowConsideredVisibleForActivation( 65 bool AshFocusRules::IsWindowConsideredVisibleForActivation(
86 aura::Window* window) const { 66 aura::Window* window) const {
87 // If the |window| doesn't belong to the current active user and also doesn't 67 // If the |window| doesn't belong to the current active user and also doesn't
88 // show for the current active user, then it should not be activated. 68 // show for the current active user, then it should not be activated.
89 if (!Shell::GetInstance()->delegate()->CanShowWindowForUser(window)) 69 if (!Shell::GetInstance()->delegate()->CanShowWindowForUser(window))
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 std::vector<aura::Window*> windows = mru->BuildMruWindowList(); 109 std::vector<aura::Window*> windows = mru->BuildMruWindowList();
130 aura::Window* starting_window = windows.empty() ? ignore : windows[0]; 110 aura::Window* starting_window = windows.empty() ? ignore : windows[0];
131 111
132 // Look for windows to focus in |starting_window|'s container. If none are 112 // Look for windows to focus in |starting_window|'s container. If none are
133 // found, we look in all the containers in front of |starting_window|'s 113 // found, we look in all the containers in front of |starting_window|'s
134 // container, then all behind. 114 // container, then all behind.
135 int starting_container_index = 0; 115 int starting_container_index = 0;
136 aura::Window* root = starting_window->GetRootWindow(); 116 aura::Window* root = starting_window->GetRootWindow();
137 if (!root) 117 if (!root)
138 root = Shell::GetTargetRootWindow(); 118 root = Shell::GetTargetRootWindow();
139 int container_count = static_cast<int>(arraysize(kWindowContainerIds)); 119 int container_count = static_cast<int>(kNumActivatableShellWindowIds);
140 for (int i = 0; i < container_count; i++) { 120 for (int i = 0; i < container_count; i++) {
141 aura::Window* container = Shell::GetContainer(root, kWindowContainerIds[i]); 121 aura::Window* container =
122 Shell::GetContainer(root, kActivatableShellWindowIds[i]);
142 if (container && container->Contains(starting_window)) { 123 if (container && container->Contains(starting_window)) {
143 starting_container_index = i; 124 starting_container_index = i;
144 break; 125 break;
145 } 126 }
146 } 127 }
147 128
148 aura::Window* window = nullptr; 129 aura::Window* window = nullptr;
149 for (int i = starting_container_index; !window && i < container_count; i++) 130 for (int i = starting_container_index; !window && i < container_count; i++)
150 window = GetTopmostWindowToActivateForContainerIndex(i, ignore); 131 window = GetTopmostWindowToActivateForContainerIndex(i, ignore);
151 if (!window && starting_container_index > 0) { 132 if (!window && starting_container_index > 0) {
152 for (int i = starting_container_index - 1; !window && i >= 0; i--) 133 for (int i = starting_container_index - 1; !window && i >= 0; i--)
153 window = GetTopmostWindowToActivateForContainerIndex(i, ignore); 134 window = GetTopmostWindowToActivateForContainerIndex(i, ignore);
154 } 135 }
155 return window; 136 return window;
156 } 137 }
157 138
158 //////////////////////////////////////////////////////////////////////////////// 139 ////////////////////////////////////////////////////////////////////////////////
159 // AshFocusRules, private: 140 // AshFocusRules, private:
160 141
161 aura::Window* AshFocusRules::GetTopmostWindowToActivateForContainerIndex( 142 aura::Window* AshFocusRules::GetTopmostWindowToActivateForContainerIndex(
162 int index, 143 int index,
163 aura::Window* ignore) const { 144 aura::Window* ignore) const {
164 aura::Window* window = NULL; 145 aura::Window* window = NULL;
165 aura::Window* root = ignore ? ignore->GetRootWindow() : NULL; 146 aura::Window* root = ignore ? ignore->GetRootWindow() : NULL;
166 aura::Window::Windows containers = Shell::GetContainersFromAllRootWindows( 147 aura::Window::Windows containers = Shell::GetContainersFromAllRootWindows(
167 kWindowContainerIds[index], root); 148 kActivatableShellWindowIds[index], root);
168 for (aura::Window::Windows::const_iterator iter = containers.begin(); 149 for (aura::Window::Windows::const_iterator iter = containers.begin();
169 iter != containers.end() && !window; ++iter) { 150 iter != containers.end() && !window; ++iter) {
170 window = GetTopmostWindowToActivateInContainer((*iter), ignore); 151 window = GetTopmostWindowToActivateInContainer((*iter), ignore);
171 } 152 }
172 return window; 153 return window;
173 } 154 }
174 155
175 aura::Window* AshFocusRules::GetTopmostWindowToActivateInContainer( 156 aura::Window* AshFocusRules::GetTopmostWindowToActivateInContainer(
176 aura::Window* container, 157 aura::Window* container,
177 aura::Window* ignore) const { 158 aura::Window* ignore) const {
178 for (aura::Window::Windows::const_reverse_iterator i = 159 for (aura::Window::Windows::const_reverse_iterator i =
179 container->children().rbegin(); 160 container->children().rbegin();
180 i != container->children().rend(); 161 i != container->children().rend();
181 ++i) { 162 ++i) {
182 WindowState* window_state = GetWindowState(*i); 163 WindowState* window_state = GetWindowState(*i);
183 if (*i != ignore && 164 if (*i != ignore &&
184 window_state->CanActivate() && 165 window_state->CanActivate() &&
185 !window_state->IsMinimized()) 166 !window_state->IsMinimized())
186 return *i; 167 return *i;
187 } 168 }
188 return NULL; 169 return NULL;
189 } 170 }
190 171
191 } // namespace wm 172 } // namespace wm
192 } // namespace ash 173 } // namespace ash
OLDNEW
« no previous file with comments | « ash/sysui/sysui_application.cc ('k') | ui/aura/window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698