| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "ui/aura_shell/stacking_controller.h" | 5 #include "ui/aura_shell/stacking_controller.h" |
| 6 | 6 |
| 7 #include "ui/aura/desktop.h" | 7 #include "ui/aura/desktop.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/aura_shell/always_on_top_controller.h" |
| 9 #include "ui/aura_shell/shell.h" | 10 #include "ui/aura_shell/shell.h" |
| 10 #include "ui/aura_shell/shell_window_ids.h" | 11 #include "ui/aura_shell/shell_window_ids.h" |
| 11 | 12 |
| 12 namespace aura_shell { | 13 namespace aura_shell { |
| 13 namespace internal { | 14 namespace internal { |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 aura::Window* GetContainer(int id) { | 17 aura::Window* GetContainer(int id) { |
| 17 return Shell::GetInstance()->GetContainer(id); | 18 return Shell::GetInstance()->GetContainer(id); |
| 18 } | 19 } |
| 19 | 20 |
| 20 // Returns true if children of |window| can be activated. | 21 // Returns true if children of |window| can be activated. |
| 21 bool SupportsChildActivation(aura::Window* window) { | 22 bool SupportsChildActivation(aura::Window* window) { |
| 22 return window->id() == kShellWindowId_DefaultContainer || | 23 return window->id() == kShellWindowId_DefaultContainer || |
| 23 window->id() == kShellWindowId_AlwaysOnTopContainer; | 24 window->id() == kShellWindowId_AlwaysOnTopContainer; |
| 24 } | 25 } |
| 25 | 26 |
| 26 } // namespace | 27 } // namespace |
| 27 | 28 |
| 28 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
| 29 // StackingController, public: | 30 // StackingController, public: |
| 30 | 31 |
| 31 StackingController::StackingController() { | 32 StackingController::StackingController() { |
| 32 aura::Desktop::GetInstance()->SetStackingClient(this); | 33 aura::Desktop::GetInstance()->SetStackingClient(this); |
| 33 } | 34 } |
| 34 | 35 |
| 35 StackingController::~StackingController() { | 36 StackingController::~StackingController() { |
| 36 } | 37 } |
| 37 | 38 |
| 39 void StackingController::Init() { |
| 40 always_on_top_controller_.reset(new internal::AlwaysOnTopController); |
| 41 always_on_top_controller_->SetContainers( |
| 42 GetContainer(internal::kShellWindowId_DefaultContainer), |
| 43 GetContainer(internal::kShellWindowId_AlwaysOnTopContainer)); |
| 44 } |
| 45 |
| 38 // static | 46 // static |
| 39 aura::Window* StackingController::GetActivatableWindow(aura::Window* window) { | 47 aura::Window* StackingController::GetActivatableWindow(aura::Window* window) { |
| 40 aura::Window* parent = window->parent(); | 48 aura::Window* parent = window->parent(); |
| 41 aura::Window* child = window; | 49 aura::Window* child = window; |
| 42 while (parent) { | 50 while (parent) { |
| 43 if (SupportsChildActivation(parent)) | 51 if (SupportsChildActivation(parent)) |
| 44 return child; | 52 return child; |
| 45 // If |child| isn't activatable, but has transient parent, trace | 53 // If |child| isn't activatable, but has transient parent, trace |
| 46 // that path instead. | 54 // that path instead. |
| 47 if (child->transient_parent()) | 55 if (child->transient_parent()) |
| 48 return GetActivatableWindow(child->transient_parent()); | 56 return GetActivatableWindow(child->transient_parent()); |
| 49 parent = parent->parent(); | 57 parent = parent->parent(); |
| 50 child = child->parent(); | 58 child = child->parent(); |
| 51 } | 59 } |
| 52 return NULL; | 60 return NULL; |
| 53 } | 61 } |
| 54 | 62 |
| 55 //////////////////////////////////////////////////////////////////////////////// | 63 //////////////////////////////////////////////////////////////////////////////// |
| 56 // StackingController, aura::StackingClient implementation: | 64 // StackingController, aura::StackingClient implementation: |
| 57 | 65 |
| 58 void StackingController::AddChildToDefaultParent(aura::Window* window) { | 66 void StackingController::AddChildToDefaultParent(aura::Window* window) { |
| 59 aura::Window* parent = NULL; | 67 aura::Window* parent = NULL; |
| 60 switch (window->type()) { | 68 switch (window->type()) { |
| 61 case aura::WINDOW_TYPE_NORMAL: | 69 case aura::WINDOW_TYPE_NORMAL: |
| 62 case aura::WINDOW_TYPE_POPUP: | 70 case aura::WINDOW_TYPE_POPUP: |
| 63 parent = GetContainer(internal::kShellWindowId_DefaultContainer); | 71 parent = always_on_top_controller_->GetContainer(window); |
| 64 break; | 72 break; |
| 65 case aura::WINDOW_TYPE_MENU: | 73 case aura::WINDOW_TYPE_MENU: |
| 66 case aura::WINDOW_TYPE_TOOLTIP: | 74 case aura::WINDOW_TYPE_TOOLTIP: |
| 67 parent = GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer); | 75 parent = GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer); |
| 68 break; | 76 break; |
| 69 default: | 77 default: |
| 70 NOTREACHED() << "Window " << window->id() | 78 NOTREACHED() << "Window " << window->id() |
| 71 << " has unhandled type " << window->type(); | 79 << " has unhandled type " << window->type(); |
| 72 break; | 80 break; |
| 73 } | 81 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 90 } | 98 } |
| 91 return NULL; | 99 return NULL; |
| 92 } | 100 } |
| 93 | 101 |
| 94 | 102 |
| 95 //////////////////////////////////////////////////////////////////////////////// | 103 //////////////////////////////////////////////////////////////////////////////// |
| 96 // StackingController, private: | 104 // StackingController, private: |
| 97 | 105 |
| 98 } // namespace internal | 106 } // namespace internal |
| 99 } // namespace aura_shell | 107 } // namespace aura_shell |
| OLD | NEW |