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

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

Issue 224113005: Eliminate ash::internal namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 11
12 namespace ash { 12 namespace ash {
13 namespace wm { 13 namespace wm {
14 namespace { 14 namespace {
15 15
16 // These are the list of container ids of containers which may contain windows 16 // These are the list of container ids of containers which may contain windows
17 // that need to be activated in the order that they should be activated. 17 // that need to be activated in the order that they should be activated.
18 const int kWindowContainerIds[] = { 18 const int kWindowContainerIds[] = {
19 internal::kShellWindowId_OverlayContainer, 19 kShellWindowId_OverlayContainer,
20 internal::kShellWindowId_LockSystemModalContainer, 20 kShellWindowId_LockSystemModalContainer,
21 internal::kShellWindowId_SettingBubbleContainer, 21 kShellWindowId_SettingBubbleContainer,
22 internal::kShellWindowId_LockScreenContainer, 22 kShellWindowId_LockScreenContainer,
23 internal::kShellWindowId_SystemModalContainer, 23 kShellWindowId_SystemModalContainer,
24 internal::kShellWindowId_AlwaysOnTopContainer, 24 kShellWindowId_AlwaysOnTopContainer,
25 internal::kShellWindowId_AppListContainer, 25 kShellWindowId_AppListContainer,
26 internal::kShellWindowId_DefaultContainer, 26 kShellWindowId_DefaultContainer,
27 27
28 // Docked, panel, launcher and status are intentionally checked after other 28 // Docked, panel, launcher and status are intentionally checked after other
29 // containers even though these layers are higher. The user expects their 29 // containers even though these layers are higher. The user expects their
30 // windows to be focused before these elements. 30 // windows to be focused before these elements.
31 internal::kShellWindowId_DockedContainer, 31 kShellWindowId_DockedContainer,
32 internal::kShellWindowId_PanelContainer, 32 kShellWindowId_PanelContainer,
33 internal::kShellWindowId_ShelfContainer, 33 kShellWindowId_ShelfContainer,
34 internal::kShellWindowId_StatusContainer, 34 kShellWindowId_StatusContainer, };
35 };
36 35
37 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window, 36 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window,
38 int container_id) { 37 int container_id) {
39 for (; window; window = window->parent()) { 38 for (; window; window = window->parent()) {
40 if (window->id() >= container_id) 39 if (window->id() >= container_id)
41 return true; 40 return true;
42 } 41 }
43 return false; 42 return false;
44 } 43 }
45 44
46 } // namespace 45 } // namespace
47 46
48 //////////////////////////////////////////////////////////////////////////////// 47 ////////////////////////////////////////////////////////////////////////////////
49 // AshFocusRules, public: 48 // AshFocusRules, public:
50 49
51 AshFocusRules::AshFocusRules() { 50 AshFocusRules::AshFocusRules() {
52 } 51 }
53 52
54 AshFocusRules::~AshFocusRules() { 53 AshFocusRules::~AshFocusRules() {
55 } 54 }
56 55
57 //////////////////////////////////////////////////////////////////////////////// 56 ////////////////////////////////////////////////////////////////////////////////
58 // AshFocusRules, ::wm::FocusRules: 57 // AshFocusRules, ::wm::FocusRules:
59 58
60 bool AshFocusRules::SupportsChildActivation(aura::Window* window) const { 59 bool AshFocusRules::SupportsChildActivation(aura::Window* window) const {
61 if (window->id() == internal::kShellWindowId_DefaultContainer) 60 if (window->id() == kShellWindowId_DefaultContainer)
62 return true; 61 return true;
63 62
64 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) { 63 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) {
65 if (window->id() == kWindowContainerIds[i]) 64 if (window->id() == kWindowContainerIds[i])
66 return true; 65 return true;
67 } 66 }
68 return false; 67 return false;
69 } 68 }
70 69
71 bool AshFocusRules::IsWindowConsideredVisibleForActivation( 70 bool AshFocusRules::IsWindowConsideredVisibleForActivation(
72 aura::Window* window) const { 71 aura::Window* window) const {
73 if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window)) 72 if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window))
74 return true; 73 return true;
75 74
76 // Minimized windows are hidden in their minimized state, but they can always 75 // Minimized windows are hidden in their minimized state, but they can always
77 // be activated. 76 // be activated.
78 if (wm::GetWindowState(window)->IsMinimized()) 77 if (wm::GetWindowState(window)->IsMinimized())
79 return true; 78 return true;
80 79
81 return window->TargetVisibility() && (window->parent()->id() == 80 return window->TargetVisibility() &&
82 internal::kShellWindowId_DefaultContainer || window->parent()->id() == 81 (window->parent()->id() == kShellWindowId_DefaultContainer ||
83 internal::kShellWindowId_LockScreenContainer); 82 window->parent()->id() == kShellWindowId_LockScreenContainer);
84 } 83 }
85 84
86 bool AshFocusRules::CanActivateWindow(aura::Window* window) const { 85 bool AshFocusRules::CanActivateWindow(aura::Window* window) const {
87 // Clearing activation is always permissible. 86 // Clearing activation is always permissible.
88 if (!window) 87 if (!window)
89 return true; 88 return true;
90 89
91 if (!BaseFocusRules::CanActivateWindow(window)) 90 if (!BaseFocusRules::CanActivateWindow(window))
92 return false; 91 return false;
93 92
94 if (Shell::GetInstance()->IsSystemModalWindowOpen()) { 93 if (Shell::GetInstance()->IsSystemModalWindowOpen()) {
95 return BelongsToContainerWithEqualOrGreaterId( 94 return BelongsToContainerWithEqualOrGreaterId(
96 window, internal::kShellWindowId_SystemModalContainer); 95 window, kShellWindowId_SystemModalContainer);
97 } 96 }
98 97
99 return true; 98 return true;
100 } 99 }
101 100
102 aura::Window* AshFocusRules::GetNextActivatableWindow( 101 aura::Window* AshFocusRules::GetNextActivatableWindow(
103 aura::Window* ignore) const { 102 aura::Window* ignore) const {
104 DCHECK(ignore); 103 DCHECK(ignore);
105 104
106 int starting_container_index = 0; 105 int starting_container_index = 0;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (*i != ignore && 158 if (*i != ignore &&
160 window_state->CanActivate() && 159 window_state->CanActivate() &&
161 !window_state->IsMinimized()) 160 !window_state->IsMinimized())
162 return *i; 161 return *i;
163 } 162 }
164 return NULL; 163 return NULL;
165 } 164 }
166 165
167 } // namespace wm 166 } // namespace wm
168 } // namespace ash 167 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/app_list_controller_unittest.cc ('k') | ash/wm/ash_native_cursor_manager_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698