| 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/shell.h" |
| 6 |
| 7 #include "ui/aura/desktop.h" |
| 8 #include "ui/aura/toplevel_window_container.h" |
| 9 #include "ui/aura/window.h" |
| 10 #include "ui/aura/window_types.h" |
| 11 #include "ui/aura_shell/desktop_layout_manager.h" |
| 12 #include "ui/aura_shell/shell_factory.h" |
| 13 #include "ui/aura_shell/shell_window_ids.h" |
| 14 #include "views/widget/widget.h" |
| 15 |
| 16 namespace aura_shell { |
| 17 |
| 18 namespace { |
| 19 // Creates each of the special window containers that holds windows of various |
| 20 // types in the shell UI. They are added to |containers| from back to front in |
| 21 // the z-index. |
| 22 void CreateSpecialContainers(aura::Window::Windows* containers) { |
| 23 aura::Window* background_container = new aura::Window(NULL); |
| 24 background_container->set_id( |
| 25 internal::kShellWindowId_DesktopBackgroundContainer); |
| 26 containers->push_back(background_container); |
| 27 |
| 28 aura::Window* default_container = new aura::ToplevelWindowContainer; |
| 29 default_container->set_id(internal::kShellWindowId_DefaultContainer); |
| 30 containers->push_back(default_container); |
| 31 |
| 32 aura::Window* always_on_top_container = new aura::ToplevelWindowContainer; |
| 33 always_on_top_container->set_id( |
| 34 internal::kShellWindowId_AlwaysOnTopContainer); |
| 35 containers->push_back(always_on_top_container); |
| 36 |
| 37 aura::Window* launcher_container = new aura::Window(NULL); |
| 38 launcher_container->set_id(internal::kShellWindowId_LauncherContainer); |
| 39 containers->push_back(launcher_container); |
| 40 |
| 41 aura::Window* lock_container = new aura::Window(NULL); |
| 42 lock_container->set_stops_event_propagation(true); |
| 43 lock_container->set_id(internal::kShellWindowId_LockScreenContainer); |
| 44 containers->push_back(lock_container); |
| 45 |
| 46 aura::Window* status_container = new aura::Window(NULL); |
| 47 status_container->set_id(internal::kShellWindowId_StatusContainer); |
| 48 containers->push_back(status_container); |
| 49 |
| 50 aura::Window* menu_container = new aura::Window(NULL); |
| 51 menu_container->set_id(internal::kShellWindowId_MenusAndTooltipsContainer); |
| 52 containers->push_back(menu_container); |
| 53 } |
| 54 } // namespace |
| 55 |
| 56 Shell::Shell() { |
| 57 } |
| 58 |
| 59 Shell::~Shell() { |
| 60 } |
| 61 |
| 62 void Shell::Init() { |
| 63 aura::Desktop::GetInstance()->set_delegate(this); |
| 64 aura::Window::Windows containers; |
| 65 CreateSpecialContainers(&containers); |
| 66 aura::Window::Windows::const_iterator i; |
| 67 for (i = containers.begin(); i != containers.end(); ++i) { |
| 68 (*i)->Init(); |
| 69 aura::Desktop::GetInstance()->window()->AddChild(*i); |
| 70 (*i)->Show(); |
| 71 } |
| 72 |
| 73 aura::Window* root_window = aura::Desktop::GetInstance()->window(); |
| 74 internal::DesktopLayoutManager* desktop_layout = |
| 75 new internal::DesktopLayoutManager(root_window); |
| 76 root_window->SetLayoutManager(desktop_layout); |
| 77 |
| 78 desktop_layout->set_background_widget(internal::CreateDesktopBackground()); |
| 79 desktop_layout->set_launcher_widget(internal::CreateLauncher()); |
| 80 desktop_layout->set_status_area_widget(internal::CreateStatusArea()); |
| 81 } |
| 82 |
| 83 aura::Window* Shell::GetContainer(int container_id) { |
| 84 return const_cast<aura::Window*>( |
| 85 const_cast<const aura_shell::Shell*>(this)->GetContainer(container_id)); |
| 86 } |
| 87 |
| 88 const aura::Window* Shell::GetContainer(int container_id) const { |
| 89 return aura::Desktop::GetInstance()->window()->GetChildById(container_id); |
| 90 } |
| 91 |
| 92 void Shell::AddChildToDefaultParent(aura::Window* window) { |
| 93 aura::Window* parent = NULL; |
| 94 switch (window->type()) { |
| 95 case aura::kWindowType_Toplevel: |
| 96 parent = GetContainer(internal::kShellWindowId_DefaultContainer); |
| 97 break; |
| 98 case aura::kWindowType_Menu: |
| 99 case aura::kWindowType_Tooltip: |
| 100 parent = GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer); |
| 101 break; |
| 102 default: |
| 103 // This will crash for controls, since they can't be parented to anything. |
| 104 break; |
| 105 } |
| 106 parent->AddChild(window); |
| 107 } |
| 108 |
| 109 aura::Window* Shell::GetTopmostWindowToActivate(aura::Window* ignore) const { |
| 110 const aura::ToplevelWindowContainer* container = |
| 111 GetContainer(internal::kShellWindowId_DefaultContainer)-> |
| 112 AsToplevelWindowContainer(); |
| 113 return container->GetTopmostWindowToActivate(ignore); |
| 114 } |
| 115 |
| 116 } // namespace aura_shell |
| OLD | NEW |