forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfullscreen_window_finder.cc
54 lines (49 loc) · 1.95 KB
/
fullscreen_window_finder.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/fullscreen_window_finder.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/wm/switchable_windows.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/wm/core/window_util.h"
namespace ash {
namespace wm {
aura::Window* GetWindowForFullscreenMode(aura::Window* context) {
aura::Window* topmost_window = nullptr;
aura::Window* active_window = GetActiveWindow();
if (active_window &&
active_window->GetRootWindow() == context->GetRootWindow() &&
IsSwitchableContainer(active_window->parent())) {
// Use the active window when it is on the current root window to determine
// the fullscreen state to allow temporarily using a panel (which is always
// above the default container) while a fullscreen window is open. We only
// use the active window when in a switchable container as the launcher
// should not exit fullscreen mode.
topmost_window = active_window;
} else {
// Otherwise, use the topmost window on the root window's default container
// when there is no active window on this root window.
const std::vector<aura::Window*>& windows =
context->GetRootWindow()
->GetChildById(kShellWindowId_DefaultContainer)
->children();
for (auto iter = windows.rbegin(); iter != windows.rend(); ++iter) {
if (GetWindowState(*iter)->IsUserPositionable() &&
(*iter)->layer()->GetTargetVisibility()) {
topmost_window = *iter;
break;
}
}
}
while (topmost_window) {
if (GetWindowState(topmost_window)->IsFullscreen())
return topmost_window;
topmost_window = ::wm::GetTransientParent(topmost_window);
}
return nullptr;
}
} // namespace wm
} // namespace ash