blob: 1bc3c6f8ff7d9f9117f891d7d66ef8458acb2a71 (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// Copyright (c) 2012 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/stacking_controller.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/always_on_top_controller.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
namespace ash {
namespace internal {
namespace {
aura::Window* GetContainer(int id) {
return Shell::GetInstance()->GetContainer(id);
}
bool IsSystemModal(aura::Window* window) {
return window->transient_parent() &&
window->GetIntProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM;
}
} // namespace
////////////////////////////////////////////////////////////////////////////////
// StackingController, public:
StackingController::StackingController() {
aura::client::SetStackingClient(this);
always_on_top_controller_.reset(new internal::AlwaysOnTopController);
always_on_top_controller_->SetContainers(
GetContainer(internal::kShellWindowId_DefaultContainer),
GetContainer(internal::kShellWindowId_AlwaysOnTopContainer));
}
StackingController::~StackingController() {
}
////////////////////////////////////////////////////////////////////////////////
// StackingController, aura::StackingClient implementation:
aura::Window* StackingController::GetDefaultParent(aura::Window* window) {
switch (window->type()) {
case aura::client::WINDOW_TYPE_NORMAL:
case aura::client::WINDOW_TYPE_POPUP:
if (IsSystemModal(window))
return GetSystemModalContainer(window);
return always_on_top_controller_->GetContainer(window);
case aura::client::WINDOW_TYPE_PANEL:
return GetContainer(internal::kShellWindowId_PanelContainer);
case aura::client::WINDOW_TYPE_MENU:
case aura::client::WINDOW_TYPE_TOOLTIP:
return GetContainer(internal::kShellWindowId_MenuAndTooltipContainer);
default:
NOTREACHED() << "Window " << window->id()
<< " has unhandled type " << window->type();
break;
}
return NULL;
}
////////////////////////////////////////////////////////////////////////////////
// StackingController, private:
aura::Window* StackingController::GetSystemModalContainer(
aura::Window* window) const {
if (!IsSystemModal(window))
return NULL;
// If screen lock is not active, all modal windows are placed into the
// normal modal container.
aura::Window* lock_container =
GetContainer(internal::kShellWindowId_LockScreenContainer);
if (!lock_container->children().size())
return GetContainer(internal::kShellWindowId_SystemModalContainer);
// Otherwise those that originate from LockScreen container and above are
// placed in the screen lock modal container.
int lock_container_id = lock_container->id();
int window_container_id = window->transient_parent()->parent()->id();
aura::Window* container = NULL;
if (window_container_id < lock_container_id)
container = GetContainer(internal::kShellWindowId_SystemModalContainer);
else
container = GetContainer(internal::kShellWindowId_LockSystemModalContainer);
return container;
}
} // namespace internal
} // namespace ash
|