| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/aura_shell/stacking_controller.h" | |
| 6 | |
| 7 #include "ui/aura/client/aura_constants.h" | |
| 8 #include "ui/aura/root_window.h" | |
| 9 #include "ui/aura/window.h" | |
| 10 #include "ui/aura_shell/always_on_top_controller.h" | |
| 11 #include "ui/aura_shell/shell.h" | |
| 12 #include "ui/aura_shell/shell_window_ids.h" | |
| 13 | |
| 14 namespace aura_shell { | |
| 15 namespace internal { | |
| 16 namespace { | |
| 17 | |
| 18 aura::Window* GetContainer(int id) { | |
| 19 return Shell::GetInstance()->GetContainer(id); | |
| 20 } | |
| 21 | |
| 22 bool IsWindowModal(aura::Window* window) { | |
| 23 return window->transient_parent() && | |
| 24 window->GetIntProperty(aura::client::kModalKey); | |
| 25 } | |
| 26 | |
| 27 } // namespace | |
| 28 | |
| 29 //////////////////////////////////////////////////////////////////////////////// | |
| 30 // StackingController, public: | |
| 31 | |
| 32 StackingController::StackingController() { | |
| 33 aura::client::SetStackingClient(this); | |
| 34 always_on_top_controller_.reset(new internal::AlwaysOnTopController); | |
| 35 always_on_top_controller_->SetContainers( | |
| 36 GetContainer(internal::kShellWindowId_DefaultContainer), | |
| 37 GetContainer(internal::kShellWindowId_AlwaysOnTopContainer)); | |
| 38 } | |
| 39 | |
| 40 StackingController::~StackingController() { | |
| 41 } | |
| 42 | |
| 43 //////////////////////////////////////////////////////////////////////////////// | |
| 44 // StackingController, aura::StackingClient implementation: | |
| 45 | |
| 46 aura::Window* StackingController::GetDefaultParent(aura::Window* window) { | |
| 47 switch (window->type()) { | |
| 48 case aura::client::WINDOW_TYPE_NORMAL: | |
| 49 case aura::client::WINDOW_TYPE_POPUP: | |
| 50 if (IsWindowModal(window)) | |
| 51 return GetModalContainer(window); | |
| 52 return always_on_top_controller_->GetContainer(window); | |
| 53 case aura::client::WINDOW_TYPE_MENU: | |
| 54 case aura::client::WINDOW_TYPE_TOOLTIP: | |
| 55 return GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer); | |
| 56 default: | |
| 57 NOTREACHED() << "Window " << window->id() | |
| 58 << " has unhandled type " << window->type(); | |
| 59 break; | |
| 60 } | |
| 61 return NULL; | |
| 62 } | |
| 63 | |
| 64 //////////////////////////////////////////////////////////////////////////////// | |
| 65 // StackingController, private: | |
| 66 | |
| 67 aura::Window* StackingController::GetModalContainer( | |
| 68 aura::Window* window) const { | |
| 69 if (!IsWindowModal(window)) | |
| 70 return NULL; | |
| 71 | |
| 72 // If screen lock is not active, all modal windows are placed into the | |
| 73 // normal modal container. | |
| 74 aura::Window* lock_container = | |
| 75 GetContainer(internal::kShellWindowId_LockScreenContainer); | |
| 76 if (!lock_container->children().size()) | |
| 77 return GetContainer(internal::kShellWindowId_ModalContainer); | |
| 78 | |
| 79 // Otherwise those that originate from LockScreen container and above are | |
| 80 // placed in the screen lock modal container. | |
| 81 int lock_container_id = lock_container->id(); | |
| 82 int window_container_id = window->transient_parent()->parent()->id(); | |
| 83 | |
| 84 aura::Window* container = NULL; | |
| 85 if (window_container_id < lock_container_id) | |
| 86 container = GetContainer(internal::kShellWindowId_ModalContainer); | |
| 87 else | |
| 88 container = GetContainer(internal::kShellWindowId_LockModalContainer); | |
| 89 | |
| 90 return container; | |
| 91 } | |
| 92 | |
| 93 } // namespace internal | |
| 94 } // namespace aura_shell | |
| OLD | NEW |