| 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" |
| 11 #include "ash/wm/always_on_top_controller.h" | 11 #include "ash/wm/always_on_top_controller.h" |
| 12 #include "ash/wm/coordinate_conversion.h" | 12 #include "ash/wm/coordinate_conversion.h" |
| 13 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
| 14 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
| 15 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/base/ui_base_types.h" | 17 #include "ui/base/ui_base_types.h" |
| 18 | 18 |
| 19 namespace ash { | 19 namespace ash { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Find a root window that matches the |bounds|. If the virtual screen | 22 // Find a root window that matches the |bounds|. If the virtual screen |
| 23 // coordinates is enabled and the bounds is specified, the root window | 23 // coordinates is enabled and the bounds is specified, the root window |
| 24 // that matches the window's bound will be used. Otherwise, it'll | 24 // that matches the window's bound will be used. Otherwise, it'll |
| 25 // return the active root window. | 25 // return the active root window. |
| 26 aura::RootWindow* FindContainerRoot(const gfx::Rect& bounds) { | 26 aura::Window* FindContainerRoot(const gfx::Rect& bounds) { |
| 27 if (bounds.x() == 0 && bounds.y() == 0 && bounds.IsEmpty()) | 27 if (bounds.x() == 0 && bounds.y() == 0 && bounds.IsEmpty()) |
| 28 return Shell::GetTargetRootWindow(); | 28 return Shell::GetTargetRootWindow(); |
| 29 return wm::GetRootWindowMatching(bounds); | 29 return wm::GetRootWindowMatching(bounds); |
| 30 } | 30 } |
| 31 | 31 |
| 32 aura::Window* GetContainerById(aura::RootWindow* root, int id) { | 32 aura::Window* GetContainerById(aura::Window* root, int id) { |
| 33 return Shell::GetContainer(root, id); | 33 return Shell::GetContainer(root, id); |
| 34 } | 34 } |
| 35 | 35 |
| 36 aura::Window* GetContainerForWindow(aura::Window* window) { | 36 aura::Window* GetContainerForWindow(aura::Window* window) { |
| 37 aura::Window* container = window->parent(); | 37 aura::Window* container = window->parent(); |
| 38 while (container && container->type() != aura::client::WINDOW_TYPE_UNKNOWN) | 38 while (container && container->type() != aura::client::WINDOW_TYPE_UNKNOWN) |
| 39 container = container->parent(); | 39 container = container->parent(); |
| 40 return container; | 40 return container; |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool IsSystemModal(aura::Window* window) { | 43 bool IsSystemModal(aura::Window* window) { |
| 44 return window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; | 44 return window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool HasTransientParentWindow(aura::Window* window) { | 47 bool HasTransientParentWindow(aura::Window* window) { |
| 48 return window->transient_parent() && | 48 return window->transient_parent() && |
| 49 window->transient_parent()->type() != aura::client::WINDOW_TYPE_UNKNOWN; | 49 window->transient_parent()->type() != aura::client::WINDOW_TYPE_UNKNOWN; |
| 50 } | 50 } |
| 51 | 51 |
| 52 internal::AlwaysOnTopController* | 52 internal::AlwaysOnTopController* |
| 53 GetAlwaysOnTopController(aura::RootWindow* root_window) { | 53 GetAlwaysOnTopController(aura::Window* root_window) { |
| 54 return internal::GetRootWindowController(root_window)-> | 54 return internal::GetRootWindowController(root_window)-> |
| 55 always_on_top_controller(); | 55 always_on_top_controller(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| 59 | 59 |
| 60 //////////////////////////////////////////////////////////////////////////////// | 60 //////////////////////////////////////////////////////////////////////////////// |
| 61 // StackingController, public: | 61 // StackingController, public: |
| 62 | 62 |
| 63 StackingController::StackingController() { | 63 StackingController::StackingController() { |
| 64 } | 64 } |
| 65 | 65 |
| 66 StackingController::~StackingController() { | 66 StackingController::~StackingController() { |
| 67 } | 67 } |
| 68 | 68 |
| 69 //////////////////////////////////////////////////////////////////////////////// | 69 //////////////////////////////////////////////////////////////////////////////// |
| 70 // StackingController, aura::client::WindowTreeClient implementation: | 70 // StackingController, aura::client::WindowTreeClient implementation: |
| 71 | 71 |
| 72 aura::Window* StackingController::GetDefaultParent(aura::Window* context, | 72 aura::Window* StackingController::GetDefaultParent(aura::Window* context, |
| 73 aura::Window* window, | 73 aura::Window* window, |
| 74 const gfx::Rect& bounds) { | 74 const gfx::Rect& bounds) { |
| 75 aura::RootWindow* target_root = NULL; | 75 aura::Window* target_root = NULL; |
| 76 if (window->transient_parent()) { | 76 if (window->transient_parent()) { |
| 77 // Transient window should use the same root as its transient parent. | 77 // Transient window should use the same root as its transient parent. |
| 78 target_root = window->transient_parent()->GetRootWindow(); | 78 target_root = window->transient_parent()->GetRootWindow(); |
| 79 } else { | 79 } else { |
| 80 target_root = FindContainerRoot(bounds); | 80 target_root = FindContainerRoot(bounds); |
| 81 } | 81 } |
| 82 | 82 |
| 83 switch (window->type()) { | 83 switch (window->type()) { |
| 84 case aura::client::WINDOW_TYPE_NORMAL: | 84 case aura::client::WINDOW_TYPE_NORMAL: |
| 85 case aura::client::WINDOW_TYPE_POPUP: | 85 case aura::client::WINDOW_TYPE_POPUP: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 108 << " has unhandled type " << window->type(); | 108 << " has unhandled type " << window->type(); |
| 109 break; | 109 break; |
| 110 } | 110 } |
| 111 return NULL; | 111 return NULL; |
| 112 } | 112 } |
| 113 | 113 |
| 114 //////////////////////////////////////////////////////////////////////////////// | 114 //////////////////////////////////////////////////////////////////////////////// |
| 115 // StackingController, private: | 115 // StackingController, private: |
| 116 | 116 |
| 117 aura::Window* StackingController::GetSystemModalContainer( | 117 aura::Window* StackingController::GetSystemModalContainer( |
| 118 aura::RootWindow* root, | 118 aura::Window* root, |
| 119 aura::Window* window) const { | 119 aura::Window* window) const { |
| 120 DCHECK(IsSystemModal(window)); | 120 DCHECK(IsSystemModal(window)); |
| 121 | 121 |
| 122 // If screen lock is not active and user session is active, | 122 // If screen lock is not active and user session is active, |
| 123 // all modal windows are placed into the normal modal container. | 123 // all modal windows are placed into the normal modal container. |
| 124 // In case of missing transient parent (it could happen for alerts from | 124 // In case of missing transient parent (it could happen for alerts from |
| 125 // background pages) assume that the window belongs to user session. | 125 // background pages) assume that the window belongs to user session. |
| 126 SessionStateDelegate* session_state_delegate = | 126 SessionStateDelegate* session_state_delegate = |
| 127 Shell::GetInstance()->session_state_delegate(); | 127 Shell::GetInstance()->session_state_delegate(); |
| 128 if (!session_state_delegate->IsUserSessionBlocked() || | 128 if (!session_state_delegate->IsUserSessionBlocked() || |
| (...skipping 11 matching lines...) Expand all Loading... |
| 140 root, internal::kShellWindowId_SystemModalContainer); | 140 root, internal::kShellWindowId_SystemModalContainer); |
| 141 } else { | 141 } else { |
| 142 container = GetContainerById( | 142 container = GetContainerById( |
| 143 root, internal::kShellWindowId_LockSystemModalContainer); | 143 root, internal::kShellWindowId_LockSystemModalContainer); |
| 144 } | 144 } |
| 145 | 145 |
| 146 return container; | 146 return container; |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace ash | 149 } // namespace ash |
| OLD | NEW |