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/wm/ash_focus_rules.h" | 5 #include "ash/wm/ash_focus_rules.h" |
6 | 6 |
7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_port.h" | 9 #include "ash/shell_port.h" |
10 #include "ash/wm/container_finder.h" | 10 #include "ash/wm/container_finder.h" |
11 #include "ash/wm/focus_rules.h" | 11 #include "ash/wm/focus_rules.h" |
12 #include "ash/wm/mru_window_tracker.h" | 12 #include "ash/wm/mru_window_tracker.h" |
13 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
14 #include "ash/wm_window.h" | |
15 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
17 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
18 | 17 |
19 namespace ash { | 18 namespace ash { |
20 namespace wm { | 19 namespace wm { |
21 namespace { | 20 namespace { |
22 | 21 |
23 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window, | 22 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window, |
24 int container_id) { | 23 int container_id) { |
(...skipping 10 matching lines...) Expand all Loading... |
35 // AshFocusRules, public: | 34 // AshFocusRules, public: |
36 | 35 |
37 AshFocusRules::AshFocusRules() = default; | 36 AshFocusRules::AshFocusRules() = default; |
38 | 37 |
39 AshFocusRules::~AshFocusRules() = default; | 38 AshFocusRules::~AshFocusRules() = default; |
40 | 39 |
41 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
42 // AshFocusRules, ::wm::FocusRules: | 41 // AshFocusRules, ::wm::FocusRules: |
43 | 42 |
44 bool AshFocusRules::IsToplevelWindow(aura::Window* window) const { | 43 bool AshFocusRules::IsToplevelWindow(aura::Window* window) const { |
45 return ash::IsToplevelWindow(WmWindow::Get(window)); | 44 return ash::IsToplevelWindow(window); |
46 } | 45 } |
47 | 46 |
48 bool AshFocusRules::SupportsChildActivation(aura::Window* window) const { | 47 bool AshFocusRules::SupportsChildActivation(aura::Window* window) const { |
49 return ash::IsActivatableShellWindowId(window->id()); | 48 return ash::IsActivatableShellWindowId(window->id()); |
50 } | 49 } |
51 | 50 |
52 bool AshFocusRules::IsWindowConsideredVisibleForActivation( | 51 bool AshFocusRules::IsWindowConsideredVisibleForActivation( |
53 aura::Window* window) const { | 52 aura::Window* window) const { |
54 return ash::IsWindowConsideredVisibleForActivation(WmWindow::Get(window)); | 53 return ash::IsWindowConsideredVisibleForActivation(window); |
55 } | 54 } |
56 | 55 |
57 bool AshFocusRules::CanActivateWindow(aura::Window* window) const { | 56 bool AshFocusRules::CanActivateWindow(aura::Window* window) const { |
58 // Clearing activation is always permissible. | 57 // Clearing activation is always permissible. |
59 if (!window) | 58 if (!window) |
60 return true; | 59 return true; |
61 | 60 |
62 if (!BaseFocusRules::CanActivateWindow(window)) | 61 if (!BaseFocusRules::CanActivateWindow(window)) |
63 return false; | 62 return false; |
64 | 63 |
(...skipping 19 matching lines...) Expand all Loading... |
84 } | 83 } |
85 | 84 |
86 aura::Window* AshFocusRules::GetNextActivatableWindow( | 85 aura::Window* AshFocusRules::GetNextActivatableWindow( |
87 aura::Window* ignore) const { | 86 aura::Window* ignore) const { |
88 DCHECK(ignore); | 87 DCHECK(ignore); |
89 | 88 |
90 // Start from the container of the most-recently-used window. If the list of | 89 // Start from the container of the most-recently-used window. If the list of |
91 // MRU windows is empty, then start from the container of the window that just | 90 // MRU windows is empty, then start from the container of the window that just |
92 // lost focus |ignore|. | 91 // lost focus |ignore|. |
93 MruWindowTracker* mru = Shell::Get()->mru_window_tracker(); | 92 MruWindowTracker* mru = Shell::Get()->mru_window_tracker(); |
94 std::vector<WmWindow*> windows = mru->BuildMruWindowList(); | 93 aura::Window::Windows windows = mru->BuildMruWindowList(); |
95 aura::Window* starting_window = | 94 aura::Window* starting_window = windows.empty() ? ignore : windows[0]; |
96 windows.empty() ? ignore : WmWindow::GetAuraWindow(windows[0]); | |
97 | 95 |
98 // Look for windows to focus in |starting_window|'s container. If none are | 96 // Look for windows to focus in |starting_window|'s container. If none are |
99 // found, we look in all the containers in front of |starting_window|'s | 97 // found, we look in all the containers in front of |starting_window|'s |
100 // container, then all behind. | 98 // container, then all behind. |
101 int starting_container_index = 0; | 99 int starting_container_index = 0; |
102 aura::Window* root = starting_window->GetRootWindow(); | 100 aura::Window* root = starting_window->GetRootWindow(); |
103 if (!root) | 101 if (!root) |
104 root = Shell::GetRootWindowForNewWindows(); | 102 root = Shell::GetRootWindowForNewWindows(); |
105 int container_count = static_cast<int>(kNumActivatableShellWindowIds); | 103 int container_count = static_cast<int>(kNumActivatableShellWindowIds); |
106 for (int i = 0; i < container_count; i++) { | 104 for (int i = 0; i < container_count; i++) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 WindowState* window_state = GetWindowState(*i); | 147 WindowState* window_state = GetWindowState(*i); |
150 if (*i != ignore && window_state->CanActivate() && | 148 if (*i != ignore && window_state->CanActivate() && |
151 !window_state->IsMinimized()) | 149 !window_state->IsMinimized()) |
152 return *i; | 150 return *i; |
153 } | 151 } |
154 return nullptr; | 152 return nullptr; |
155 } | 153 } |
156 | 154 |
157 } // namespace wm | 155 } // namespace wm |
158 } // namespace ash | 156 } // namespace ash |
OLD | NEW |