Chromium Code Reviews| 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 // The window must in a valid hierarchy. | |
| 16 if (!window->GetRootWindow()) | |
| 17 return false; | |
| 18 | |
| 19 // The window must exist within a container that supports activation. | |
| 20 // The window cannot be blocked by a modal transient. | |
| 21 return IsActivatableShellWindowId(window->GetParent()->GetShellWindowId()); | |
| 22 } | |
| 23 | |
| 24 bool IsWindowConsideredActivatable(WmWindow* window) { | |
|
James Cook
2016/06/07 01:21:04
Do you need to handle a null window? I see the Bas
sky
2016/06/07 02:46:21
Seem weird to me to null check. I added a DCHECK.
| |
| 25 // Only toplevel windows can be activated. | |
| 26 if (!IsToplevelWindow(window)) | |
| 27 return false; | |
| 28 | |
| 29 // The window must be visible. | |
| 30 return IsWindowConsideredVisibleForActivation(window); | |
| 31 } | |
| 32 | |
| 33 bool IsWindowConsideredVisibleForActivation(WmWindow* window) { | |
| 34 // If the |window| doesn't belong to the current active user and also doesn't | |
| 35 // show for the current active user, then it should not be activated. | |
| 36 if (!WmShell::Get()->CanShowWindowForUser(window)) | |
| 37 return false; | |
| 38 | |
| 39 if (window->IsVisible()) | |
| 40 return true; | |
| 41 | |
| 42 // Minimized windows are hidden in their minimized state, but they can always | |
| 43 // be activated. | |
| 44 if (window->GetWindowState()->IsMinimized()) | |
| 45 return true; | |
| 46 | |
| 47 if (!window->GetTargetVisibility()) | |
| 48 return false; | |
| 49 | |
| 50 const int parent_shell_window_id = window->GetParent()->GetShellWindowId(); | |
| 51 return parent_shell_window_id == kShellWindowId_DefaultContainer || | |
| 52 parent_shell_window_id == kShellWindowId_LockScreenContainer; | |
| 53 } | |
| 54 | |
| 55 } // namespace ash | |
| OLD | NEW |