Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: ash/common/wm/focus_rules.cc

Issue 2042913002: Converts MruWindowTracker to work with common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: not equal Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/wm/focus_rules.h ('k') | ash/common/wm_shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « ash/common/wm/focus_rules.h ('k') | ash/common/wm_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698