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

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

Issue 11414304: Fleshes out the basic set of focus rules a bit more. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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"
8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/window_util.h"
7 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
8 11
9 namespace ash { 12 namespace ash {
10 namespace wm { 13 namespace wm {
14 namespace {
15
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.
18 const int kWindowContainerIds[] = {
19 internal::kShellWindowId_LockSystemModalContainer,
20 internal::kShellWindowId_SettingBubbleContainer,
21 internal::kShellWindowId_LockScreenContainer,
22 internal::kShellWindowId_SystemModalContainer,
23 internal::kShellWindowId_AlwaysOnTopContainer,
24 internal::kShellWindowId_AppListContainer,
25 internal::kShellWindowId_DefaultContainer,
26
27 // Panel, launcher and status are intentionally checked after other
28 // containers even though these layers are higher. The user expects their
29 // windows to be focused before these elements.
30 internal::kShellWindowId_PanelContainer,
31 internal::kShellWindowId_LauncherContainer,
32 internal::kShellWindowId_StatusContainer,
33 };
34
35 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window,
36 int container_id) {
37 for (; window; window = window->parent()) {
38 if (window->id() >= container_id)
39 return true;
40 }
41 return false;
42 }
43
44 } // namespace
11 45
12 //////////////////////////////////////////////////////////////////////////////// 46 ////////////////////////////////////////////////////////////////////////////////
13 // AshFocusRules, public: 47 // AshFocusRules, public:
14 48
15 AshFocusRules::AshFocusRules() { 49 AshFocusRules::AshFocusRules() {
16 } 50 }
17 51
18 AshFocusRules::~AshFocusRules() { 52 AshFocusRules::~AshFocusRules() {
19 } 53 }
20 54
21 //////////////////////////////////////////////////////////////////////////////// 55 ////////////////////////////////////////////////////////////////////////////////
22 // AshFocusRules, views::corewm::FocusRules: 56 // AshFocusRules, views::corewm::FocusRules:
23 57
24 bool AshFocusRules::CanActivateWindow(aura::Window* window) { 58 bool AshFocusRules::SupportsChildActivation(aura::Window* window) {
25 return window && !!window->parent(); 59 if (window->id() == internal::kShellWindowId_WorkspaceContainer)
60 return true;
61
sadrul 2012/12/04 16:19:40 Perhaps return false earlier here if window->id()
62 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) {
63 if (window->id() == kWindowContainerIds[i] &&
64 window->id() != internal::kShellWindowId_DefaultContainer) {
65 return true;
66 }
67 }
68 return false;
26 } 69 }
27 70
28 bool AshFocusRules::CanFocusWindow(aura::Window* window) { 71 bool AshFocusRules::IsWindowConsideredVisibleForActivation(
29 aura::Window* activatable = GetActivatableWindow(window); 72 aura::Window* window) {
30 return activatable->Contains(window) && window->CanFocus(); 73 if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window))
74 return true;
75
76 // Minimized windows are hidden in their minimized state, but they can always
77 // be activated.
78 if (wm::IsWindowMinimized(window))
79 return true;
80
81 return window->TargetVisibility() && (window->parent()->id() ==
82 internal::kShellWindowId_WorkspaceContainer || window->parent()->id() ==
83 internal::kShellWindowId_LockScreenContainer);
31 } 84 }
32 85
33 aura::Window* AshFocusRules::GetActivatableWindow(aura::Window* window) { 86 bool AshFocusRules::CanActivateWindow(aura::Window* window) {
34 return window; 87 if (!BaseFocusRules::CanActivateWindow(window))
35 } 88 return false;
36 89
37 aura::Window* AshFocusRules::GetFocusableWindow(aura::Window* window) { 90 if (Shell::GetInstance()->IsSystemModalWindowOpen()) {
38 return window; 91 return BelongsToContainerWithEqualOrGreaterId(
39 } 92 window, internal::kShellWindowId_SystemModalContainer);
93 }
40 94
41 aura::Window* AshFocusRules::GetNextActivatableWindow(aura::Window* ignore) { 95 return true;
42 return NULL;
43 }
44
45 aura::Window* AshFocusRules::GetNextFocusableWindow(aura::Window* ignore) {
46 return GetFocusableWindow(ignore->parent());
47 } 96 }
48 97
49 } // namespace wm 98 } // namespace wm
50 } // namespace ash 99 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698