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/wm/container_finder.h" | 9 #include "ash/wm/container_finder.h" |
10 #include "ash/wm/focus_rules.h" | 10 #include "ash/wm/focus_rules.h" |
11 #include "ash/wm/mru_window_tracker.h" | 11 #include "ash/wm/mru_window_tracker.h" |
12 #include "ash/wm/window_state.h" | 12 #include "ash/wm/window_state.h" |
13 #include "ash/wm/window_state_aura.h" | 13 #include "ash/wm/window_state_aura.h" |
14 #include "ash/wm_shell.h" | 14 #include "ash/wm_shell.h" |
15 #include "ash/wm_window.h" | 15 #include "ash/wm_window.h" |
| 16 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/events/event.h" |
17 | 19 |
18 namespace ash { | 20 namespace ash { |
19 namespace wm { | 21 namespace wm { |
20 namespace { | 22 namespace { |
21 | 23 |
22 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window, | 24 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window, |
23 int container_id) { | 25 int container_id) { |
24 for (; window; window = window->parent()) { | 26 for (; window; window = window->parent()) { |
25 if (window->id() >= container_id) | 27 if (window->id() >= container_id) |
26 return true; | 28 return true; |
27 } | 29 } |
28 return false; | 30 return false; |
29 } | 31 } |
30 | 32 |
31 } // namespace | 33 } // namespace |
32 | 34 |
33 //////////////////////////////////////////////////////////////////////////////// | 35 //////////////////////////////////////////////////////////////////////////////// |
34 // AshFocusRules, public: | 36 // AshFocusRules, public: |
35 | 37 |
36 AshFocusRules::AshFocusRules() {} | 38 AshFocusRules::AshFocusRules() = default; |
37 | 39 |
38 AshFocusRules::~AshFocusRules() {} | 40 AshFocusRules::~AshFocusRules() = default; |
39 | |
40 bool AshFocusRules::IsWindowConsideredActivatable(aura::Window* window) const { | |
41 return ash::IsWindowConsideredActivatable(WmWindow::Get(window)); | |
42 } | |
43 | 41 |
44 //////////////////////////////////////////////////////////////////////////////// | 42 //////////////////////////////////////////////////////////////////////////////// |
45 // AshFocusRules, ::wm::FocusRules: | 43 // AshFocusRules, ::wm::FocusRules: |
46 | 44 |
47 bool AshFocusRules::IsToplevelWindow(aura::Window* window) const { | 45 bool AshFocusRules::IsToplevelWindow(aura::Window* window) const { |
48 return ash::IsToplevelWindow(WmWindow::Get(window)); | 46 return ash::IsToplevelWindow(WmWindow::Get(window)); |
49 } | 47 } |
50 | 48 |
51 bool AshFocusRules::SupportsChildActivation(aura::Window* window) const { | 49 bool AshFocusRules::SupportsChildActivation(aura::Window* window) const { |
52 return ash::IsActivatableShellWindowId(window->id()); | 50 return ash::IsActivatableShellWindowId(window->id()); |
(...skipping 13 matching lines...) Expand all Loading... |
66 return false; | 64 return false; |
67 | 65 |
68 if (WmShell::Get()->IsSystemModalWindowOpen()) { | 66 if (WmShell::Get()->IsSystemModalWindowOpen()) { |
69 return BelongsToContainerWithEqualOrGreaterId( | 67 return BelongsToContainerWithEqualOrGreaterId( |
70 window, kShellWindowId_SystemModalContainer); | 68 window, kShellWindowId_SystemModalContainer); |
71 } | 69 } |
72 | 70 |
73 return true; | 71 return true; |
74 } | 72 } |
75 | 73 |
| 74 bool AshFocusRules::IsWindowConsideredActivatableForEvent( |
| 75 aura::Window* window, |
| 76 ui::Event* event) const { |
| 77 if (!window) |
| 78 return true; |
| 79 |
| 80 if (event->IsMouseEvent()) |
| 81 return window->GetProperty(aura::client::kActivateOnClickKey); |
| 82 |
| 83 return true; |
| 84 } |
| 85 |
76 aura::Window* AshFocusRules::GetNextActivatableWindow( | 86 aura::Window* AshFocusRules::GetNextActivatableWindow( |
77 aura::Window* ignore) const { | 87 aura::Window* ignore) const { |
78 DCHECK(ignore); | 88 DCHECK(ignore); |
79 | 89 |
80 // Start from the container of the most-recently-used window. If the list of | 90 // Start from the container of the most-recently-used window. If the list of |
81 // MRU windows is empty, then start from the container of the window that just | 91 // MRU windows is empty, then start from the container of the window that just |
82 // lost focus |ignore|. | 92 // lost focus |ignore|. |
83 MruWindowTracker* mru = Shell::Get()->mru_window_tracker(); | 93 MruWindowTracker* mru = Shell::Get()->mru_window_tracker(); |
84 std::vector<WmWindow*> windows = mru->BuildMruWindowList(); | 94 std::vector<WmWindow*> windows = mru->BuildMruWindowList(); |
85 aura::Window* starting_window = | 95 aura::Window* starting_window = |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 aura::Window* container, | 144 aura::Window* container, |
135 aura::Window* ignore) const { | 145 aura::Window* ignore) const { |
136 for (aura::Window::Windows::const_reverse_iterator i = | 146 for (aura::Window::Windows::const_reverse_iterator i = |
137 container->children().rbegin(); | 147 container->children().rbegin(); |
138 i != container->children().rend(); ++i) { | 148 i != container->children().rend(); ++i) { |
139 WindowState* window_state = GetWindowState(*i); | 149 WindowState* window_state = GetWindowState(*i); |
140 if (*i != ignore && window_state->CanActivate() && | 150 if (*i != ignore && window_state->CanActivate() && |
141 !window_state->IsMinimized()) | 151 !window_state->IsMinimized()) |
142 return *i; | 152 return *i; |
143 } | 153 } |
144 return NULL; | 154 return nullptr; |
145 } | 155 } |
146 | 156 |
147 } // namespace wm | 157 } // namespace wm |
148 } // namespace ash | 158 } // namespace ash |
OLD | NEW |