Chromium Code Reviews| 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/root_window.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/root_window_event_filter.h" | 19 #include "ui/aura_shell/root_window_event_filter.h" |
| 20 #include "ui/aura_shell/root_window_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/laptop_mode_layout_manager.h" | |
| 22 #include "ui/aura_shell/launcher/launcher.h" | 23 #include "ui/aura_shell/launcher/launcher.h" |
| 23 #include "ui/aura_shell/modal_container_layout_manager.h" | 24 #include "ui/aura_shell/modal_container_layout_manager.h" |
| 24 #include "ui/aura_shell/shadow_controller.h" | 25 #include "ui/aura_shell/shadow_controller.h" |
| 25 #include "ui/aura_shell/shelf_layout_manager.h" | 26 #include "ui/aura_shell/shelf_layout_manager.h" |
| 26 #include "ui/aura_shell/shell_accelerator_controller.h" | 27 #include "ui/aura_shell/shell_accelerator_controller.h" |
| 27 #include "ui/aura_shell/shell_accelerator_filter.h" | 28 #include "ui/aura_shell/shell_accelerator_filter.h" |
| 28 #include "ui/aura_shell/shell_delegate.h" | 29 #include "ui/aura_shell/shell_delegate.h" |
| 29 #include "ui/aura_shell/shell_factory.h" | 30 #include "ui/aura_shell/shell_factory.h" |
| 30 #include "ui/aura_shell/shell_tooltip_manager.h" | 31 #include "ui/aura_shell/shell_tooltip_manager.h" |
| 31 #include "ui/aura_shell/shell_window_ids.h" | 32 #include "ui/aura_shell/shell_window_ids.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 49 // types in the shell UI. They are added to |containers| from back to front in | 50 // types in the shell UI. They are added to |containers| from back to front in |
| 50 // the z-index. | 51 // the z-index. |
| 51 void CreateSpecialContainers(aura::Window::Windows* containers) { | 52 void CreateSpecialContainers(aura::Window::Windows* containers) { |
| 52 aura::Window* background_container = new aura::Window(NULL); | 53 aura::Window* background_container = new aura::Window(NULL); |
| 53 background_container->set_id( | 54 background_container->set_id( |
| 54 internal::kShellWindowId_DesktopBackgroundContainer); | 55 internal::kShellWindowId_DesktopBackgroundContainer); |
| 55 containers->push_back(background_container); | 56 containers->push_back(background_container); |
| 56 | 57 |
| 57 aura::Window* default_container = new aura::Window(NULL); | 58 aura::Window* default_container = new aura::Window(NULL); |
| 58 default_container->SetEventFilter( | 59 default_container->SetEventFilter( |
| 59 new ToplevelWindowEventFilter(default_container)); | 60 new ToplevelWindowEventFilter(default_container)); |
|
sky
2011/12/12 15:46:29
Don't you want a different ToplevelWindowEventFilt
James Cook
2011/12/12 18:33:36
Hmm. If we want popups to be draggable windows, w
| |
| 60 default_container->set_id(internal::kShellWindowId_DefaultContainer); | 61 default_container->set_id(internal::kShellWindowId_DefaultContainer); |
| 61 containers->push_back(default_container); | 62 containers->push_back(default_container); |
| 62 | 63 |
| 63 aura::Window* always_on_top_container = new aura::Window(NULL); | 64 aura::Window* always_on_top_container = new aura::Window(NULL); |
| 64 always_on_top_container->SetEventFilter( | 65 always_on_top_container->SetEventFilter( |
| 65 new ToplevelWindowEventFilter(always_on_top_container)); | 66 new ToplevelWindowEventFilter(always_on_top_container)); |
| 66 always_on_top_container->set_id( | 67 always_on_top_container->set_id( |
| 67 internal::kShellWindowId_AlwaysOnTopContainer); | 68 internal::kShellWindowId_AlwaysOnTopContainer); |
| 68 containers->push_back(always_on_top_container); | 69 containers->push_back(always_on_top_container); |
| 69 | 70 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 (*i)->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 186 (*i)->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); |
| 186 root_window->AddChild(*i); | 187 root_window->AddChild(*i); |
| 187 (*i)->Show(); | 188 (*i)->Show(); |
| 188 } | 189 } |
| 189 | 190 |
| 190 internal::StackingController* stacking_controller = | 191 internal::StackingController* stacking_controller = |
| 191 static_cast<internal::StackingController*>( | 192 static_cast<internal::StackingController*>( |
| 192 root_window->stacking_client()); | 193 root_window->stacking_client()); |
| 193 stacking_controller->Init(); | 194 stacking_controller->Init(); |
| 194 | 195 |
| 196 InitLayoutManagers(root_window); | |
| 197 | |
| 198 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kAuraNoShadows)) | |
| 199 shadow_controller_.reset(new internal::ShadowController()); | |
| 200 | |
| 201 // Force a layout. | |
| 202 root_window->layout_manager()->OnWindowResized(); | |
| 203 | |
| 204 // Initialize ShellAcceleratorFilter | |
| 205 accelerator_filter_.reset(new internal::ShellAcceleratorFilter); | |
| 206 AddRootWindowEventFilter(accelerator_filter_.get()); | |
| 207 | |
| 208 // Initialize ShellTooltipManager | |
| 209 tooltip_manager_.reset(new ShellTooltipManager); | |
| 210 aura::RootWindow::GetInstance()->SetProperty( | |
| 211 aura::kRootWindowTooltipClientKey, | |
| 212 static_cast<aura::TooltipClient*>(tooltip_manager_.get())); | |
| 213 AddRootWindowEventFilter(tooltip_manager_.get()); | |
| 214 | |
| 215 // Initialize drag drop controller. | |
| 216 drag_drop_controller_.reset(new internal::DragDropController); | |
| 217 aura::RootWindow::GetInstance()->SetProperty( | |
| 218 aura::kRootWindowDragDropClientKey, | |
| 219 static_cast<aura::DragDropClient*>(drag_drop_controller_.get())); | |
| 220 } | |
| 221 | |
| 222 void Shell::InitLayoutManagers(aura::RootWindow* root_window) { | |
| 195 internal::RootWindowLayoutManager* root_window_layout = | 223 internal::RootWindowLayoutManager* root_window_layout = |
| 196 new internal::RootWindowLayoutManager(root_window); | 224 new internal::RootWindowLayoutManager(root_window); |
| 197 root_window->SetLayoutManager(root_window_layout); | 225 root_window->SetLayoutManager(root_window_layout); |
| 198 | 226 |
| 199 root_window_layout->set_background_widget( | |
| 200 internal::CreateDesktopBackground()); | |
| 201 aura::Window* default_container = | |
| 202 GetContainer(internal::kShellWindowId_DefaultContainer); | |
| 203 launcher_.reset(new Launcher(default_container)); | |
| 204 | |
| 205 views::Widget* status_widget = NULL; | 227 views::Widget* status_widget = NULL; |
| 206 if (delegate_.get()) | 228 if (delegate_.get()) |
| 207 status_widget = delegate_->CreateStatusArea(); | 229 status_widget = delegate_->CreateStatusArea(); |
| 208 if (!status_widget) | 230 if (!status_widget) |
| 209 status_widget = internal::CreateStatusArea(); | 231 status_widget = internal::CreateStatusArea(); |
| 210 | 232 |
| 233 aura::Window* default_container = | |
| 234 GetContainer(internal::kShellWindowId_DefaultContainer); | |
| 235 | |
| 236 // Laptop mode has a simplified layout manager and doesn't use the launcher, | |
| 237 // desktop background, shelf, etc. | |
| 238 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAuraLaptopMode)) { | |
| 239 default_container->SetLayoutManager( | |
| 240 new internal::LaptopModeLayoutManager()); | |
| 241 // TODO(jamescook): Adjust status area layout. | |
| 242 return; | |
| 243 } | |
| 244 | |
| 245 root_window_layout->set_background_widget( | |
| 246 internal::CreateDesktopBackground()); | |
| 247 launcher_.reset(new Launcher(default_container)); | |
| 248 | |
| 211 internal::ShelfLayoutManager* shelf_layout_manager = | 249 internal::ShelfLayoutManager* shelf_layout_manager = |
| 212 new internal::ShelfLayoutManager(launcher_->widget(), status_widget); | 250 new internal::ShelfLayoutManager(launcher_->widget(), status_widget); |
| 213 GetContainer(aura_shell::internal::kShellWindowId_LauncherContainer)-> | 251 GetContainer(aura_shell::internal::kShellWindowId_LauncherContainer)-> |
| 214 SetLayoutManager(shelf_layout_manager); | 252 SetLayoutManager(shelf_layout_manager); |
| 215 | 253 |
| 216 internal::StatusAreaLayoutManager* status_area_layout_manager = | 254 internal::StatusAreaLayoutManager* status_area_layout_manager = |
| 217 new internal::StatusAreaLayoutManager(shelf_layout_manager); | 255 new internal::StatusAreaLayoutManager(shelf_layout_manager); |
| 218 GetContainer(aura_shell::internal::kShellWindowId_StatusContainer)-> | 256 GetContainer(aura_shell::internal::kShellWindowId_StatusContainer)-> |
| 219 SetLayoutManager(status_area_layout_manager); | 257 SetLayoutManager(status_area_layout_manager); |
| 220 | 258 |
| 221 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kAuraNoShadows)) | 259 // Workspace manager has its own layout managers. |
| 222 shadow_controller_.reset(new internal::ShadowController()); | |
| 223 | |
| 224 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAuraWindows)) { | 260 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAuraWindows)) { |
| 225 EnableWorkspaceManager(); | 261 EnableWorkspaceManager(); |
| 226 } else { | 262 return; |
| 227 internal::ToplevelLayoutManager* toplevel_layout_manager = | |
| 228 new internal::ToplevelLayoutManager(); | |
| 229 default_container->SetLayoutManager(toplevel_layout_manager); | |
| 230 toplevel_layout_manager->set_shelf(shelf_layout_manager); | |
| 231 } | 263 } |
| 232 | 264 |
| 233 // Force a layout. | 265 // Default layout manager. |
| 234 root_window_layout->OnWindowResized(); | 266 internal::ToplevelLayoutManager* toplevel_layout_manager = |
| 235 | 267 new internal::ToplevelLayoutManager(); |
| 236 // Initialize ShellAcceleratorFilter | 268 default_container->SetLayoutManager(toplevel_layout_manager); |
| 237 accelerator_filter_.reset(new internal::ShellAcceleratorFilter); | 269 toplevel_layout_manager->set_shelf(shelf_layout_manager); |
| 238 AddRootWindowEventFilter(accelerator_filter_.get()); | |
| 239 | |
| 240 // Initialize ShellTooltipManager | |
| 241 tooltip_manager_.reset(new ShellTooltipManager); | |
| 242 aura::RootWindow::GetInstance()->SetProperty( | |
| 243 aura::kRootWindowTooltipClientKey, | |
| 244 static_cast<aura::TooltipClient*>(tooltip_manager_.get())); | |
| 245 AddRootWindowEventFilter(tooltip_manager_.get()); | |
| 246 | |
| 247 // Initialize drag drop controller. | |
| 248 drag_drop_controller_.reset(new internal::DragDropController); | |
| 249 aura::RootWindow::GetInstance()->SetProperty( | |
| 250 aura::kRootWindowDragDropClientKey, | |
| 251 static_cast<aura::DragDropClient*>(drag_drop_controller_.get())); | |
| 252 } | 270 } |
| 253 | 271 |
| 254 aura::Window* Shell::GetContainer(int container_id) { | 272 aura::Window* Shell::GetContainer(int container_id) { |
| 255 return const_cast<aura::Window*>( | 273 return const_cast<aura::Window*>( |
| 256 const_cast<const aura_shell::Shell*>(this)->GetContainer(container_id)); | 274 const_cast<const aura_shell::Shell*>(this)->GetContainer(container_id)); |
| 257 } | 275 } |
| 258 | 276 |
| 259 const aura::Window* Shell::GetContainer(int container_id) const { | 277 const aura::Window* Shell::GetContainer(int container_id) const { |
| 260 return aura::RootWindow::GetInstance()->GetChildById(container_id); | 278 return aura::RootWindow::GetInstance()->GetChildById(container_id); |
| 261 } | 279 } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 292 new internal::WorkspaceController(default_container)); | 310 new internal::WorkspaceController(default_container)); |
| 293 workspace_controller_->SetLauncherModel(launcher_->model()); | 311 workspace_controller_->SetLauncherModel(launcher_->model()); |
| 294 default_container->SetEventFilter( | 312 default_container->SetEventFilter( |
| 295 new internal::DefaultContainerEventFilter(default_container)); | 313 new internal::DefaultContainerEventFilter(default_container)); |
| 296 default_container->SetLayoutManager( | 314 default_container->SetLayoutManager( |
| 297 new internal::DefaultContainerLayoutManager( | 315 new internal::DefaultContainerLayoutManager( |
| 298 workspace_controller_->workspace_manager())); | 316 workspace_controller_->workspace_manager())); |
| 299 } | 317 } |
| 300 | 318 |
| 301 } // namespace aura_shell | 319 } // namespace aura_shell |
| OLD | NEW |