OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/focus_rules.h" | 5 #include "ash/wm/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_delegate.h" | 9 #include "ash/shell_delegate.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
11 #include "ash/wm_window.h" | |
12 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
13 | 12 |
14 namespace ash { | 13 namespace ash { |
15 | 14 |
16 bool IsToplevelWindow(aura::Window* window) { | 15 bool IsToplevelWindow(aura::Window* window) { |
17 DCHECK(window); | 16 DCHECK(window); |
18 // The window must in a valid hierarchy. | 17 // The window must in a valid hierarchy. |
19 if (!window->GetRootWindow()) | 18 if (!window->GetRootWindow()) |
20 return false; | 19 return false; |
21 | 20 |
22 // The window must exist within a container that supports activation. | 21 // The window must exist within a container that supports activation. |
23 // The window cannot be blocked by a modal transient. | 22 // The window cannot be blocked by a modal transient. |
24 return IsActivatableShellWindowId(window->parent()->id()); | 23 return IsActivatableShellWindowId(window->parent()->id()); |
25 } | 24 } |
26 | 25 |
27 bool IsWindowConsideredActivatable(aura::Window* window) { | 26 bool IsWindowConsideredActivatable(aura::Window* window) { |
28 DCHECK(window); | 27 DCHECK(window); |
29 // Only toplevel windows can be activated. | 28 // Only toplevel windows can be activated. |
30 if (!IsToplevelWindow(window)) | 29 if (!IsToplevelWindow(window)) |
31 return false; | 30 return false; |
32 | 31 |
33 // The window must be visible. | 32 // The window must be visible. |
34 return IsWindowConsideredVisibleForActivation(window); | 33 return IsWindowConsideredVisibleForActivation(window); |
35 } | 34 } |
36 | 35 |
37 bool IsWindowConsideredVisibleForActivation(aura::Window* window) { | 36 bool IsWindowConsideredVisibleForActivation(aura::Window* window) { |
38 DCHECK(window); | 37 DCHECK(window); |
39 // If the |window| doesn't belong to the current active user and also doesn't | 38 // If the |window| doesn't belong to the current active user and also doesn't |
40 // show for the current active user, then it should not be activated. | 39 // show for the current active user, then it should not be activated. |
41 if (!Shell::Get()->shell_delegate()->CanShowWindowForUser( | 40 if (!Shell::Get()->shell_delegate()->CanShowWindowForUser(window)) |
42 WmWindow::Get(window))) | |
43 return false; | 41 return false; |
44 | 42 |
45 if (window->IsVisible()) | 43 if (window->IsVisible()) |
46 return true; | 44 return true; |
47 | 45 |
48 // Minimized windows are hidden in their minimized state, but they can always | 46 // Minimized windows are hidden in their minimized state, but they can always |
49 // be activated. | 47 // be activated. |
50 if (wm::GetWindowState(window)->IsMinimized()) | 48 if (wm::GetWindowState(window)->IsMinimized()) |
51 return true; | 49 return true; |
52 | 50 |
53 if (!window->TargetVisibility()) | 51 if (!window->TargetVisibility()) |
54 return false; | 52 return false; |
55 | 53 |
56 const int parent_shell_window_id = window->parent()->id(); | 54 const int parent_shell_window_id = window->parent()->id(); |
57 return parent_shell_window_id == kShellWindowId_DefaultContainer || | 55 return parent_shell_window_id == kShellWindowId_DefaultContainer || |
58 parent_shell_window_id == kShellWindowId_LockScreenContainer; | 56 parent_shell_window_id == kShellWindowId_LockScreenContainer; |
59 } | 57 } |
60 | 58 |
61 } // namespace ash | 59 } // namespace ash |
OLD | NEW |