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/shell.h" | 5 #include "ui/aura_shell/shell.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "ui/aura/aura_switches.h" | 9 #include "ui/aura/aura_switches.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
11 #include "ui/aura/client/drag_drop_client.h" | 11 #include "ui/aura/client/drag_drop_client.h" |
12 #include "ui/aura/desktop.h" | 12 #include "ui/aura/root_window.h" |
13 #include "ui/aura/layout_manager.h" | 13 #include "ui/aura/layout_manager.h" |
14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
15 #include "ui/aura/window_types.h" | 15 #include "ui/aura/window_types.h" |
16 #include "ui/aura_shell/app_list.h" | 16 #include "ui/aura_shell/app_list.h" |
17 #include "ui/aura_shell/default_container_event_filter.h" | 17 #include "ui/aura_shell/default_container_event_filter.h" |
18 #include "ui/aura_shell/default_container_layout_manager.h" | 18 #include "ui/aura_shell/default_container_layout_manager.h" |
19 #include "ui/aura_shell/desktop_event_filter.h" | 19 #include "ui/aura_shell/root_window_event_filter.h" |
20 #include "ui/aura_shell/desktop_layout_manager.h" | 20 #include "ui/aura_shell/root_window_layout_manager.h" |
21 #include "ui/aura_shell/drag_drop_controller.h" | 21 #include "ui/aura_shell/drag_drop_controller.h" |
22 #include "ui/aura_shell/launcher/launcher.h" | 22 #include "ui/aura_shell/launcher/launcher.h" |
23 #include "ui/aura_shell/modal_container_layout_manager.h" | 23 #include "ui/aura_shell/modal_container_layout_manager.h" |
24 #include "ui/aura_shell/shadow_controller.h" | 24 #include "ui/aura_shell/shadow_controller.h" |
25 #include "ui/aura_shell/shelf_layout_manager.h" | 25 #include "ui/aura_shell/shelf_layout_manager.h" |
26 #include "ui/aura_shell/shell_accelerator_controller.h" | 26 #include "ui/aura_shell/shell_accelerator_controller.h" |
27 #include "ui/aura_shell/shell_accelerator_filter.h" | 27 #include "ui/aura_shell/shell_accelerator_filter.h" |
28 #include "ui/aura_shell/shell_delegate.h" | 28 #include "ui/aura_shell/shell_delegate.h" |
29 #include "ui/aura_shell/shell_factory.h" | 29 #include "ui/aura_shell/shell_factory.h" |
30 #include "ui/aura_shell/shell_tooltip_manager.h" | 30 #include "ui/aura_shell/shell_tooltip_manager.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // static | 108 // static |
109 Shell* Shell::instance_ = NULL; | 109 Shell* Shell::instance_ = NULL; |
110 | 110 |
111 //////////////////////////////////////////////////////////////////////////////// | 111 //////////////////////////////////////////////////////////////////////////////// |
112 // Shell, public: | 112 // Shell, public: |
113 | 113 |
114 Shell::Shell(ShellDelegate* delegate) | 114 Shell::Shell(ShellDelegate* delegate) |
115 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 115 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
116 accelerator_controller_(new ShellAcceleratorController), | 116 accelerator_controller_(new ShellAcceleratorController), |
117 delegate_(delegate) { | 117 delegate_(delegate) { |
118 aura::Desktop::GetInstance()->SetEventFilter( | 118 aura::RootWindow::GetInstance()->SetEventFilter( |
119 new internal::DesktopEventFilter); | 119 new internal::RootWindowEventFilter); |
120 aura::Desktop::GetInstance()->SetStackingClient( | 120 aura::RootWindow::GetInstance()->SetStackingClient( |
121 new internal::StackingController); | 121 new internal::StackingController); |
122 } | 122 } |
123 | 123 |
124 Shell::~Shell() { | 124 Shell::~Shell() { |
125 RemoveDesktopEventFilter(accelerator_filter_.get()); | 125 RemoveRootWindowEventFilter(accelerator_filter_.get()); |
126 | 126 |
127 // ShellTooltipManager needs a valid shell instance. We delete it before | 127 // ShellTooltipManager needs a valid shell instance. We delete it before |
128 // deleting the shell |instance_|. | 128 // deleting the shell |instance_|. |
129 RemoveDesktopEventFilter(tooltip_manager_.get()); | 129 RemoveRootWindowEventFilter(tooltip_manager_.get()); |
130 aura::Desktop::GetInstance()->SetProperty(aura::kDesktopTooltipClientKey, | 130 aura::RootWindow::GetInstance()->SetProperty( |
| 131 aura::kRootWindowTooltipClientKey, |
131 NULL); | 132 NULL); |
132 | 133 |
133 // Make sure we delete WorkspaceController before launcher is | 134 // Make sure we delete WorkspaceController before launcher is |
134 // deleted as it has a reference to launcher model. | 135 // deleted as it has a reference to launcher model. |
135 workspace_controller_.reset(); | 136 workspace_controller_.reset(); |
136 launcher_.reset(); | 137 launcher_.reset(); |
137 | 138 |
138 // Delete containers now so that child windows does not access | 139 // Delete containers now so that child windows does not access |
139 // observers when they are destructed. This has to be after launcher | 140 // observers when they are destructed. This has to be after launcher |
140 // is destructed because launcher closes the widget in its destructor. | 141 // is destructed because launcher closes the widget in its destructor. |
141 aura::Desktop* desktop_window = aura::Desktop::GetInstance(); | 142 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
142 while (!desktop_window->children().empty()) { | 143 while (!root_window->children().empty()) { |
143 aura::Window* child = desktop_window->children()[0]; | 144 aura::Window* child = root_window->children()[0]; |
144 delete child; | 145 delete child; |
145 } | 146 } |
146 | 147 |
147 tooltip_manager_.reset(); | 148 tooltip_manager_.reset(); |
148 | 149 |
149 // Drag drop controller needs a valid shell instance. We destroy it first. | 150 // Drag drop controller needs a valid shell instance. We destroy it first. |
150 drag_drop_controller_.reset(); | 151 drag_drop_controller_.reset(); |
151 | 152 |
152 DCHECK(instance_ == this); | 153 DCHECK(instance_ == this); |
153 instance_ = NULL; | 154 instance_ = NULL; |
(...skipping 13 matching lines...) Expand all Loading... |
167 return instance_; | 168 return instance_; |
168 } | 169 } |
169 | 170 |
170 // static | 171 // static |
171 void Shell::DeleteInstance() { | 172 void Shell::DeleteInstance() { |
172 delete instance_; | 173 delete instance_; |
173 instance_ = NULL; | 174 instance_ = NULL; |
174 } | 175 } |
175 | 176 |
176 void Shell::Init() { | 177 void Shell::Init() { |
177 aura::Desktop* desktop_window = aura::Desktop::GetInstance(); | 178 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
178 desktop_window->SetCursor(aura::kCursorPointer); | 179 root_window->SetCursor(aura::kCursorPointer); |
179 | 180 |
180 aura::Window::Windows containers; | 181 aura::Window::Windows containers; |
181 CreateSpecialContainers(&containers); | 182 CreateSpecialContainers(&containers); |
182 aura::Window::Windows::const_iterator i; | 183 aura::Window::Windows::const_iterator i; |
183 for (i = containers.begin(); i != containers.end(); ++i) { | 184 for (i = containers.begin(); i != containers.end(); ++i) { |
184 (*i)->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 185 (*i)->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); |
185 desktop_window->AddChild(*i); | 186 root_window->AddChild(*i); |
186 (*i)->Show(); | 187 (*i)->Show(); |
187 } | 188 } |
188 | 189 |
189 internal::StackingController* stacking_controller = | 190 internal::StackingController* stacking_controller = |
190 static_cast<internal::StackingController*>( | 191 static_cast<internal::StackingController*>( |
191 desktop_window->stacking_client()); | 192 root_window->stacking_client()); |
192 stacking_controller->Init(); | 193 stacking_controller->Init(); |
193 | 194 |
194 internal::DesktopLayoutManager* desktop_layout = | 195 internal::RootWindowLayoutManager* root_window_layout = |
195 new internal::DesktopLayoutManager(desktop_window); | 196 new internal::RootWindowLayoutManager(root_window); |
196 desktop_window->SetLayoutManager(desktop_layout); | 197 root_window->SetLayoutManager(root_window_layout); |
197 | 198 |
198 desktop_layout->set_background_widget(internal::CreateDesktopBackground()); | 199 root_window_layout->set_background_widget( |
| 200 internal::CreateDesktopBackground()); |
199 aura::Window* default_container = | 201 aura::Window* default_container = |
200 GetContainer(internal::kShellWindowId_DefaultContainer); | 202 GetContainer(internal::kShellWindowId_DefaultContainer); |
201 launcher_.reset(new Launcher(default_container)); | 203 launcher_.reset(new Launcher(default_container)); |
202 | 204 |
203 views::Widget* status_widget = NULL; | 205 views::Widget* status_widget = NULL; |
204 if (delegate_.get()) | 206 if (delegate_.get()) |
205 status_widget = delegate_->CreateStatusArea(); | 207 status_widget = delegate_->CreateStatusArea(); |
206 if (!status_widget) | 208 if (!status_widget) |
207 status_widget = internal::CreateStatusArea(); | 209 status_widget = internal::CreateStatusArea(); |
208 | 210 |
(...skipping 13 matching lines...) Expand all Loading... |
222 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAuraWindows)) { | 224 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAuraWindows)) { |
223 EnableWorkspaceManager(); | 225 EnableWorkspaceManager(); |
224 } else { | 226 } else { |
225 internal::ToplevelLayoutManager* toplevel_layout_manager = | 227 internal::ToplevelLayoutManager* toplevel_layout_manager = |
226 new internal::ToplevelLayoutManager(); | 228 new internal::ToplevelLayoutManager(); |
227 default_container->SetLayoutManager(toplevel_layout_manager); | 229 default_container->SetLayoutManager(toplevel_layout_manager); |
228 toplevel_layout_manager->set_shelf(shelf_layout_manager); | 230 toplevel_layout_manager->set_shelf(shelf_layout_manager); |
229 } | 231 } |
230 | 232 |
231 // Force a layout. | 233 // Force a layout. |
232 desktop_layout->OnWindowResized(); | 234 root_window_layout->OnWindowResized(); |
233 | 235 |
234 // Initialize ShellAcceleratorFilter | 236 // Initialize ShellAcceleratorFilter |
235 accelerator_filter_.reset(new internal::ShellAcceleratorFilter); | 237 accelerator_filter_.reset(new internal::ShellAcceleratorFilter); |
236 AddDesktopEventFilter(accelerator_filter_.get()); | 238 AddRootWindowEventFilter(accelerator_filter_.get()); |
237 | 239 |
238 // Initialize ShellTooltipManager | 240 // Initialize ShellTooltipManager |
239 tooltip_manager_.reset(new ShellTooltipManager); | 241 tooltip_manager_.reset(new ShellTooltipManager); |
240 aura::Desktop::GetInstance()->SetProperty(aura::kDesktopTooltipClientKey, | 242 aura::RootWindow::GetInstance()->SetProperty( |
| 243 aura::kRootWindowTooltipClientKey, |
241 static_cast<aura::TooltipClient*>(tooltip_manager_.get())); | 244 static_cast<aura::TooltipClient*>(tooltip_manager_.get())); |
242 AddDesktopEventFilter(tooltip_manager_.get()); | 245 AddRootWindowEventFilter(tooltip_manager_.get()); |
243 | 246 |
244 // Initialize drag drop controller. | 247 // Initialize drag drop controller. |
245 drag_drop_controller_.reset(new internal::DragDropController); | 248 drag_drop_controller_.reset(new internal::DragDropController); |
246 aura::Desktop::GetInstance()->SetProperty(aura::kDesktopDragDropClientKey, | 249 aura::RootWindow::GetInstance()->SetProperty( |
| 250 aura::kRootWindowDragDropClientKey, |
247 static_cast<aura::DragDropClient*>(drag_drop_controller_.get())); | 251 static_cast<aura::DragDropClient*>(drag_drop_controller_.get())); |
248 } | 252 } |
249 | 253 |
250 aura::Window* Shell::GetContainer(int container_id) { | 254 aura::Window* Shell::GetContainer(int container_id) { |
251 return const_cast<aura::Window*>( | 255 return const_cast<aura::Window*>( |
252 const_cast<const aura_shell::Shell*>(this)->GetContainer(container_id)); | 256 const_cast<const aura_shell::Shell*>(this)->GetContainer(container_id)); |
253 } | 257 } |
254 | 258 |
255 const aura::Window* Shell::GetContainer(int container_id) const { | 259 const aura::Window* Shell::GetContainer(int container_id) const { |
256 return aura::Desktop::GetInstance()->GetChildById(container_id); | 260 return aura::RootWindow::GetInstance()->GetChildById(container_id); |
257 } | 261 } |
258 | 262 |
259 void Shell::AddDesktopEventFilter(aura::EventFilter* filter) { | 263 void Shell::AddRootWindowEventFilter(aura::EventFilter* filter) { |
260 static_cast<internal::DesktopEventFilter*>( | 264 static_cast<internal::RootWindowEventFilter*>( |
261 aura::Desktop::GetInstance()->event_filter())->AddFilter(filter); | 265 aura::RootWindow::GetInstance()->event_filter())->AddFilter(filter); |
262 } | 266 } |
263 | 267 |
264 void Shell::RemoveDesktopEventFilter(aura::EventFilter* filter) { | 268 void Shell::RemoveRootWindowEventFilter(aura::EventFilter* filter) { |
265 static_cast<internal::DesktopEventFilter*>( | 269 static_cast<internal::RootWindowEventFilter*>( |
266 aura::Desktop::GetInstance()->event_filter())->RemoveFilter(filter); | 270 aura::RootWindow::GetInstance()->event_filter())->RemoveFilter(filter); |
267 } | 271 } |
268 | 272 |
269 void Shell::ToggleOverview() { | 273 void Shell::ToggleOverview() { |
270 if (workspace_controller_.get()) | 274 if (workspace_controller_.get()) |
271 workspace_controller_->ToggleOverview(); | 275 workspace_controller_->ToggleOverview(); |
272 } | 276 } |
273 | 277 |
274 void Shell::ToggleAppList() { | 278 void Shell::ToggleAppList() { |
275 if (!app_list_.get()) | 279 if (!app_list_.get()) |
276 app_list_.reset(new internal::AppList); | 280 app_list_.reset(new internal::AppList); |
(...skipping 11 matching lines...) Expand all Loading... |
288 new internal::WorkspaceController(default_container)); | 292 new internal::WorkspaceController(default_container)); |
289 workspace_controller_->SetLauncherModel(launcher_->model()); | 293 workspace_controller_->SetLauncherModel(launcher_->model()); |
290 default_container->SetEventFilter( | 294 default_container->SetEventFilter( |
291 new internal::DefaultContainerEventFilter(default_container)); | 295 new internal::DefaultContainerEventFilter(default_container)); |
292 default_container->SetLayoutManager( | 296 default_container->SetLayoutManager( |
293 new internal::DefaultContainerLayoutManager( | 297 new internal::DefaultContainerLayoutManager( |
294 workspace_controller_->workspace_manager())); | 298 workspace_controller_->workspace_manager())); |
295 } | 299 } |
296 | 300 |
297 } // namespace aura_shell | 301 } // namespace aura_shell |
OLD | NEW |