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