Commit 40b3fb1f authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

cros: Fix missing gaia in single process mash

In single process mash, gaia dialog widget goes through the
following stack:
  WindowServiceDelegateImpl::SetModalType ->
  wm::GetDefaultParent ->
  GetSystemModalContainer

It does not have a |transient_parent| and hence assumed to be
a user window and put into SystemModalContainer instead of
LockSystemModalContainer.

Since the dialog widget is created with a proper container parent,
the CL fixes the issue by re-using existing container parent in
GetSystemModalContainer.

Bug: 876329
Change-Id: Iaf38273e852738b7d258a82f76dae9952051a08d
Reviewed-on: https://chromium-review.googlesource.com/1185406
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585278}
parent 0a840142
...@@ -184,6 +184,12 @@ const int32_t kAllShellContainerIds[] = { ...@@ -184,6 +184,12 @@ const int32_t kAllShellContainerIds[] = {
kShellWindowId_PowerButtonAnimationContainer, kShellWindowId_PowerButtonAnimationContainer,
}; };
// A list of system modal container IDs. The order of the list is important that
// the more restrictive container appears before the less restrictive ones.
const int32_t kSystemModalContainerIds[] = {
kShellWindowId_LockSystemModalContainer,
kShellWindowId_SystemModalContainer};
// These are the list of container ids of containers which may contain windows // These are the list of container ids of containers which may contain windows
// that need to be activated. // that need to be activated.
ASH_PUBLIC_EXPORT extern const int32_t kActivatableShellWindowIds[]; ASH_PUBLIC_EXPORT extern const int32_t kActivatableShellWindowIds[];
......
...@@ -365,12 +365,8 @@ int Shell::GetOpenSystemModalWindowContainerId() { ...@@ -365,12 +365,8 @@ int Shell::GetOpenSystemModalWindowContainerId() {
// Traverse all system modal containers, and find its direct child window // Traverse all system modal containers, and find its direct child window
// with "SystemModal" setting, and visible. // with "SystemModal" setting, and visible.
// Note: LockSystemModalContainer is more restrictive, so make it preferable
// to SystemModalCotainer.
constexpr int modal_window_ids[] = {kShellWindowId_LockSystemModalContainer,
kShellWindowId_SystemModalContainer};
for (aura::Window* root : Shell::GetAllRootWindows()) { for (aura::Window* root : Shell::GetAllRootWindows()) {
for (int modal_window_id : modal_window_ids) { for (int modal_window_id : kSystemModalContainerIds) {
aura::Window* system_modal = root->GetChildById(modal_window_id); aura::Window* system_modal = root->GetChildById(modal_window_id);
if (!system_modal) if (!system_modal)
continue; continue;
......
...@@ -35,10 +35,18 @@ bool HasTransientParentWindow(const aura::Window* window) { ...@@ -35,10 +35,18 @@ bool HasTransientParentWindow(const aura::Window* window) {
aura::Window* GetSystemModalContainer(aura::Window* root, aura::Window* GetSystemModalContainer(aura::Window* root,
aura::Window* window) { aura::Window* window) {
aura::Window* transient_parent = ::wm::GetTransientParent(window);
DCHECK_EQ(ui::MODAL_TYPE_SYSTEM, DCHECK_EQ(ui::MODAL_TYPE_SYSTEM,
window->GetProperty(aura::client::kModalKey)); window->GetProperty(aura::client::kModalKey));
// If |window| is already in a system modal container in |root|, re-use it.
for (auto modal_container_id : kSystemModalContainerIds) {
aura::Window* modal_container = root->GetChildById(modal_container_id);
if (window->parent() == modal_container)
return modal_container;
}
aura::Window* transient_parent = ::wm::GetTransientParent(window);
// If screen lock is not active and user session is active, // If screen lock is not active and user session is active,
// all modal windows are placed into the normal modal container. // all modal windows are placed into the normal modal container.
// In case of missing transient parent (it could happen for alerts from // In case of missing transient parent (it could happen for alerts from
......
...@@ -195,8 +195,12 @@ void WindowServiceDelegateImpl::SetModalType(aura::Window* window, ...@@ -195,8 +195,12 @@ void WindowServiceDelegateImpl::SetModalType(aura::Window* window,
window->SetProperty(aura::client::kModalKey, type); window->SetProperty(aura::client::kModalKey, type);
// Reparent the window if it will become, or will no longer be, system modal. // Reparent the window if it will become, or will no longer be, system modal.
if (type == ui::MODAL_TYPE_SYSTEM || old_type == ui::MODAL_TYPE_SYSTEM) if (type == ui::MODAL_TYPE_SYSTEM || old_type == ui::MODAL_TYPE_SYSTEM) {
wm::GetDefaultParent(window, window->GetBoundsInScreen())->AddChild(window); aura::Window* const parent =
wm::GetDefaultParent(window, window->GetBoundsInScreen());
if (parent != window->parent())
parent->AddChild(window);
}
} }
ui::SystemInputInjector* WindowServiceDelegateImpl::GetSystemInputInjector() { ui::SystemInputInjector* WindowServiceDelegateImpl::GetSystemInputInjector() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment