OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/stacking_controller.h" | 5 #include "ash/wm/stacking_controller.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/session_state_delegate.h" | 8 #include "ash/session_state_delegate.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 bool IsSystemModal(aura::Window* window) { | 37 bool IsSystemModal(aura::Window* window) { |
38 return window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; | 38 return window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; |
39 } | 39 } |
40 | 40 |
41 bool HasTransientParentWindow(const aura::Window* window) { | 41 bool HasTransientParentWindow(const aura::Window* window) { |
42 return ::wm::GetTransientParent(window) && | 42 return ::wm::GetTransientParent(window) && |
43 ::wm::GetTransientParent(window)->type() != | 43 ::wm::GetTransientParent(window)->type() != |
44 ui::wm::WINDOW_TYPE_UNKNOWN; | 44 ui::wm::WINDOW_TYPE_UNKNOWN; |
45 } | 45 } |
46 | 46 |
47 internal::AlwaysOnTopController* | 47 AlwaysOnTopController* GetAlwaysOnTopController(aura::Window* root_window) { |
48 GetAlwaysOnTopController(aura::Window* root_window) { | 48 return GetRootWindowController(root_window)->always_on_top_controller(); |
49 return internal::GetRootWindowController(root_window)-> | |
50 always_on_top_controller(); | |
51 } | 49 } |
52 | 50 |
53 } // namespace | 51 } // namespace |
54 | 52 |
55 //////////////////////////////////////////////////////////////////////////////// | 53 //////////////////////////////////////////////////////////////////////////////// |
56 // StackingController, public: | 54 // StackingController, public: |
57 | 55 |
58 StackingController::StackingController() { | 56 StackingController::StackingController() { |
59 } | 57 } |
60 | 58 |
(...skipping 14 matching lines...) Expand all Loading... |
75 } else { | 73 } else { |
76 target_root = FindContainerRoot(bounds); | 74 target_root = FindContainerRoot(bounds); |
77 } | 75 } |
78 | 76 |
79 switch (window->type()) { | 77 switch (window->type()) { |
80 case ui::wm::WINDOW_TYPE_NORMAL: | 78 case ui::wm::WINDOW_TYPE_NORMAL: |
81 case ui::wm::WINDOW_TYPE_POPUP: | 79 case ui::wm::WINDOW_TYPE_POPUP: |
82 if (IsSystemModal(window)) | 80 if (IsSystemModal(window)) |
83 return GetSystemModalContainer(target_root, window); | 81 return GetSystemModalContainer(target_root, window); |
84 else if (HasTransientParentWindow(window)) | 82 else if (HasTransientParentWindow(window)) |
85 return internal::RootWindowController::GetContainerForWindow( | 83 return RootWindowController::GetContainerForWindow( |
86 ::wm::GetTransientParent(window)); | 84 ::wm::GetTransientParent(window)); |
87 return GetAlwaysOnTopController(target_root)->GetContainer(window); | 85 return GetAlwaysOnTopController(target_root)->GetContainer(window); |
88 case ui::wm::WINDOW_TYPE_CONTROL: | 86 case ui::wm::WINDOW_TYPE_CONTROL: |
89 return GetContainerById( | 87 return GetContainerById(target_root, |
90 target_root, internal::kShellWindowId_UnparentedControlContainer); | 88 kShellWindowId_UnparentedControlContainer); |
91 case ui::wm::WINDOW_TYPE_PANEL: | 89 case ui::wm::WINDOW_TYPE_PANEL: |
92 if (wm::GetWindowState(window)->panel_attached()) | 90 if (wm::GetWindowState(window)->panel_attached()) |
93 return GetContainerById(target_root, | 91 return GetContainerById(target_root, kShellWindowId_PanelContainer); |
94 internal::kShellWindowId_PanelContainer); | |
95 else | 92 else |
96 return GetAlwaysOnTopController(target_root)->GetContainer(window); | 93 return GetAlwaysOnTopController(target_root)->GetContainer(window); |
97 case ui::wm::WINDOW_TYPE_MENU: | 94 case ui::wm::WINDOW_TYPE_MENU: |
98 return GetContainerById( | 95 return GetContainerById(target_root, kShellWindowId_MenuContainer); |
99 target_root, internal::kShellWindowId_MenuContainer); | |
100 case ui::wm::WINDOW_TYPE_TOOLTIP: | 96 case ui::wm::WINDOW_TYPE_TOOLTIP: |
101 return GetContainerById( | 97 return GetContainerById(target_root, |
102 target_root, internal::kShellWindowId_DragImageAndTooltipContainer); | 98 kShellWindowId_DragImageAndTooltipContainer); |
103 default: | 99 default: |
104 NOTREACHED() << "Window " << window->id() | 100 NOTREACHED() << "Window " << window->id() |
105 << " has unhandled type " << window->type(); | 101 << " has unhandled type " << window->type(); |
106 break; | 102 break; |
107 } | 103 } |
108 return NULL; | 104 return NULL; |
109 } | 105 } |
110 | 106 |
111 //////////////////////////////////////////////////////////////////////////////// | 107 //////////////////////////////////////////////////////////////////////////////// |
112 // StackingController, private: | 108 // StackingController, private: |
113 | 109 |
114 aura::Window* StackingController::GetSystemModalContainer( | 110 aura::Window* StackingController::GetSystemModalContainer( |
115 aura::Window* root, | 111 aura::Window* root, |
116 aura::Window* window) const { | 112 aura::Window* window) const { |
117 DCHECK(IsSystemModal(window)); | 113 DCHECK(IsSystemModal(window)); |
118 | 114 |
119 // If screen lock is not active and user session is active, | 115 // If screen lock is not active and user session is active, |
120 // all modal windows are placed into the normal modal container. | 116 // all modal windows are placed into the normal modal container. |
121 // In case of missing transient parent (it could happen for alerts from | 117 // In case of missing transient parent (it could happen for alerts from |
122 // background pages) assume that the window belongs to user session. | 118 // background pages) assume that the window belongs to user session. |
123 SessionStateDelegate* session_state_delegate = | 119 SessionStateDelegate* session_state_delegate = |
124 Shell::GetInstance()->session_state_delegate(); | 120 Shell::GetInstance()->session_state_delegate(); |
125 if (!session_state_delegate->IsUserSessionBlocked() || | 121 if (!session_state_delegate->IsUserSessionBlocked() || |
126 !::wm::GetTransientParent(window)) { | 122 !::wm::GetTransientParent(window)) { |
127 return GetContainerById(root, | 123 return GetContainerById(root, kShellWindowId_SystemModalContainer); |
128 internal::kShellWindowId_SystemModalContainer); | |
129 } | 124 } |
130 | 125 |
131 // Otherwise those that originate from LockScreen container and above are | 126 // Otherwise those that originate from LockScreen container and above are |
132 // placed in the screen lock modal container. | 127 // placed in the screen lock modal container. |
133 int window_container_id = | 128 int window_container_id = |
134 ::wm::GetTransientParent(window)->parent()->id(); | 129 ::wm::GetTransientParent(window)->parent()->id(); |
135 aura::Window* container = NULL; | 130 aura::Window* container = NULL; |
136 if (window_container_id < internal::kShellWindowId_LockScreenContainer) { | 131 if (window_container_id < kShellWindowId_LockScreenContainer) { |
137 container = GetContainerById( | 132 container = GetContainerById(root, kShellWindowId_SystemModalContainer); |
138 root, internal::kShellWindowId_SystemModalContainer); | |
139 } else { | 133 } else { |
140 container = GetContainerById( | 134 container = GetContainerById(root, kShellWindowId_LockSystemModalContainer); |
141 root, internal::kShellWindowId_LockSystemModalContainer); | |
142 } | 135 } |
143 | 136 |
144 return container; | 137 return container; |
145 } | 138 } |
146 | 139 |
147 } // namespace ash | 140 } // namespace ash |
OLD | NEW |