| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/accelerators/focus_manager_factory.h" | 10 #include "ash/accelerators/focus_manager_factory.h" |
| 11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
| 12 #include "ash/caps_lock_delegate.h" | 12 #include "ash/caps_lock_delegate.h" |
| 13 #include "ash/desktop_background/desktop_background_controller.h" | 13 #include "ash/desktop_background/desktop_background_controller.h" |
| 14 #include "ash/desktop_background/desktop_background_resources.h" | 14 #include "ash/desktop_background/desktop_background_resources.h" |
| 15 #include "ash/desktop_background/desktop_background_view.h" | 15 #include "ash/desktop_background/desktop_background_view.h" |
| 16 #include "ash/desktop_background/user_wallpaper_delegate.h" | 16 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| 17 #include "ash/display/display_controller.h" | 17 #include "ash/display/display_controller.h" |
| 18 #include "ash/display/mouse_cursor_event_filter.h" | 18 #include "ash/display/mouse_cursor_event_filter.h" |
| 19 #include "ash/display/multi_display_manager.h" | 19 #include "ash/display/display_manager.h" |
| 20 #include "ash/display/screen_position_controller.h" | 20 #include "ash/display/screen_position_controller.h" |
| 21 #include "ash/drag_drop/drag_drop_controller.h" | 21 #include "ash/drag_drop/drag_drop_controller.h" |
| 22 #include "ash/focus_cycler.h" | 22 #include "ash/focus_cycler.h" |
| 23 #include "ash/high_contrast/high_contrast_controller.h" | 23 #include "ash/high_contrast/high_contrast_controller.h" |
| 24 #include "ash/magnifier/magnification_controller.h" | 24 #include "ash/magnifier/magnification_controller.h" |
| 25 #include "ash/root_window_controller.h" | 25 #include "ash/root_window_controller.h" |
| 26 #include "ash/screen_ash.h" | 26 #include "ash/screen_ash.h" |
| 27 #include "ash/shell_delegate.h" | 27 #include "ash/shell_delegate.h" |
| 28 #include "ash/shell_factory.h" | 28 #include "ash/shell_factory.h" |
| 29 #include "ash/shell_window_ids.h" | 29 #include "ash/shell_window_ids.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 #include "ash/wm/window_modality_controller.h" | 63 #include "ash/wm/window_modality_controller.h" |
| 64 #include "ash/wm/window_properties.h" | 64 #include "ash/wm/window_properties.h" |
| 65 #include "ash/wm/window_util.h" | 65 #include "ash/wm/window_util.h" |
| 66 #include "ash/wm/workspace_controller.h" | 66 #include "ash/wm/workspace_controller.h" |
| 67 #include "base/bind.h" | 67 #include "base/bind.h" |
| 68 #include "base/command_line.h" | 68 #include "base/command_line.h" |
| 69 #include "base/debug/leak_annotations.h" | 69 #include "base/debug/leak_annotations.h" |
| 70 #include "ui/aura/client/aura_constants.h" | 70 #include "ui/aura/client/aura_constants.h" |
| 71 #include "ui/aura/client/stacking_client.h" | 71 #include "ui/aura/client/stacking_client.h" |
| 72 #include "ui/aura/client/user_action_client.h" | 72 #include "ui/aura/client/user_action_client.h" |
| 73 #include "ui/aura/display_manager.h" | |
| 74 #include "ui/aura/env.h" | 73 #include "ui/aura/env.h" |
| 75 #include "ui/aura/focus_manager.h" | 74 #include "ui/aura/focus_manager.h" |
| 76 #include "ui/aura/layout_manager.h" | 75 #include "ui/aura/layout_manager.h" |
| 77 #include "ui/aura/root_window.h" | 76 #include "ui/aura/root_window.h" |
| 78 #include "ui/aura/ui_controls_aura.h" | 77 #include "ui/aura/ui_controls_aura.h" |
| 79 #include "ui/aura/window.h" | 78 #include "ui/aura/window.h" |
| 80 #include "ui/compositor/layer.h" | 79 #include "ui/compositor/layer.h" |
| 81 #include "ui/compositor/layer_animator.h" | 80 #include "ui/compositor/layer_animator.h" |
| 82 #include "ui/gfx/display.h" | 81 #include "ui/gfx/display.h" |
| 83 #include "ui/gfx/image/image_skia.h" | 82 #include "ui/gfx/image/image_skia.h" |
| 84 #include "ui/gfx/screen.h" | 83 #include "ui/gfx/screen.h" |
| 85 #include "ui/gfx/size.h" | 84 #include "ui/gfx/size.h" |
| 86 #include "ui/ui_controls/ui_controls.h" | 85 #include "ui/ui_controls/ui_controls.h" |
| 87 #include "ui/views/corewm/compound_event_filter.h" | 86 #include "ui/views/corewm/compound_event_filter.h" |
| 88 #include "ui/views/corewm/input_method_event_filter.h" | 87 #include "ui/views/corewm/input_method_event_filter.h" |
| 89 #include "ui/views/focus/focus_manager_factory.h" | 88 #include "ui/views/focus/focus_manager_factory.h" |
| 90 #include "ui/views/widget/native_widget_aura.h" | 89 #include "ui/views/widget/native_widget_aura.h" |
| 91 #include "ui/views/widget/widget.h" | 90 #include "ui/views/widget/widget.h" |
| 92 | 91 |
| 93 #if !defined(OS_MACOSX) | 92 #if !defined(OS_MACOSX) |
| 94 #include "ash/accelerators/accelerator_controller.h" | 93 #include "ash/accelerators/accelerator_controller.h" |
| 95 #include "ash/accelerators/accelerator_filter.h" | 94 #include "ash/accelerators/accelerator_filter.h" |
| 96 #include "ash/accelerators/nested_dispatcher_controller.h" | 95 #include "ash/accelerators/nested_dispatcher_controller.h" |
| 97 #endif | 96 #endif |
| 98 | 97 |
| 99 #if defined(OS_CHROMEOS) | 98 #if defined(OS_CHROMEOS) |
| 99 #include "ash/display/display_change_observer_x11.h" |
| 100 #include "ash/display/output_configurator_animation.h" | 100 #include "ash/display/output_configurator_animation.h" |
| 101 #include "base/chromeos/chromeos_version.h" |
| 101 #include "base/message_pump_aurax11.h" | 102 #include "base/message_pump_aurax11.h" |
| 102 #include "chromeos/display/output_configurator.h" | 103 #include "chromeos/display/output_configurator.h" |
| 103 #include "content/public/browser/gpu_data_manager.h" | 104 #include "content/public/browser/gpu_data_manager.h" |
| 104 #include "content/public/common/gpu_feature_type.h" | 105 #include "content/public/common/gpu_feature_type.h" |
| 105 #endif // defined(OS_CHROMEOS) | 106 #endif // defined(OS_CHROMEOS) |
| 106 | 107 |
| 107 namespace ash { | 108 namespace ash { |
| 108 | 109 |
| 109 namespace { | 110 namespace { |
| 110 | 111 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 active_root_window_(NULL), | 196 active_root_window_(NULL), |
| 196 delegate_(delegate), | 197 delegate_(delegate), |
| 197 #if defined(OS_CHROMEOS) | 198 #if defined(OS_CHROMEOS) |
| 198 output_configurator_(new chromeos::OutputConfigurator()), | 199 output_configurator_(new chromeos::OutputConfigurator()), |
| 199 output_configurator_animation_( | 200 output_configurator_animation_( |
| 200 new internal::OutputConfiguratorAnimation()), | 201 new internal::OutputConfiguratorAnimation()), |
| 201 #endif // defined(OS_CHROMEOS) | 202 #endif // defined(OS_CHROMEOS) |
| 202 browser_context_(NULL), | 203 browser_context_(NULL), |
| 203 simulate_modal_window_open_for_testing_(false) { | 204 simulate_modal_window_open_for_testing_(false) { |
| 204 DCHECK(delegate_.get()); | 205 DCHECK(delegate_.get()); |
| 206 display_manager_.reset(new internal::DisplayManager); |
| 205 ANNOTATE_LEAKING_OBJECT_PTR(screen_); // see crbug.com/156466 | 207 ANNOTATE_LEAKING_OBJECT_PTR(screen_); // see crbug.com/156466 |
| 206 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_); | 208 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_); |
| 207 if (!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)) | 209 if (!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)) |
| 208 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_); | 210 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_); |
| 209 ui_controls::InstallUIControlsAura(internal::CreateUIControls()); | 211 ui_controls::InstallUIControlsAura(internal::CreateUIControls()); |
| 210 #if defined(OS_CHROMEOS) | 212 #if defined(OS_CHROMEOS) |
| 211 content::GpuFeatureType blacklisted_features = | 213 content::GpuFeatureType blacklisted_features = |
| 212 content::GpuDataManager::GetInstance()->GetBlacklistedFeatures(); | 214 content::GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 213 bool is_panel_fitting_disabled = | 215 bool is_panel_fitting_disabled = |
| 214 (blacklisted_features & content::GPU_FEATURE_TYPE_PANEL_FITTING) || | 216 (blacklisted_features & content::GPU_FEATURE_TYPE_PANEL_FITTING) || |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 #if defined(OS_CHROMEOS) | 299 #if defined(OS_CHROMEOS) |
| 298 output_configurator_->RemoveObserver(output_configurator_animation_.get()); | 300 output_configurator_->RemoveObserver(output_configurator_animation_.get()); |
| 299 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow( | 301 base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow( |
| 300 output_configurator()); | 302 output_configurator()); |
| 301 #endif // defined(OS_CHROMEOS) | 303 #endif // defined(OS_CHROMEOS) |
| 302 } | 304 } |
| 303 | 305 |
| 304 // static | 306 // static |
| 305 Shell* Shell::CreateInstance(ShellDelegate* delegate) { | 307 Shell* Shell::CreateInstance(ShellDelegate* delegate) { |
| 306 CHECK(!instance_); | 308 CHECK(!instance_); |
| 307 aura::Env::GetInstance()->SetDisplayManager( | |
| 308 new internal::MultiDisplayManager()); | |
| 309 instance_ = new Shell(delegate); | 309 instance_ = new Shell(delegate); |
| 310 instance_->Init(); | 310 instance_->Init(); |
| 311 return instance_; | 311 return instance_; |
| 312 } | 312 } |
| 313 | 313 |
| 314 // static | 314 // static |
| 315 Shell* Shell::GetInstance() { | 315 Shell* Shell::GetInstance() { |
| 316 DCHECK(instance_); | 316 DCHECK(instance_); |
| 317 return instance_; | 317 return instance_; |
| 318 } | 318 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 return containers; | 385 return containers; |
| 386 } | 386 } |
| 387 | 387 |
| 388 // static | 388 // static |
| 389 bool Shell::IsLauncherPerDisplayEnabled() { | 389 bool Shell::IsLauncherPerDisplayEnabled() { |
| 390 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 390 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 391 return command_line->HasSwitch(switches::kAshLauncherPerDisplay); | 391 return command_line->HasSwitch(switches::kAshLauncherPerDisplay); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void Shell::Init() { | 394 void Shell::Init() { |
| 395 #if defined(OS_CHROMEOS) |
| 396 if (base::chromeos::IsRunningOnChromeOS()) { |
| 397 display_change_observer_.reset(new internal::DisplayChangeObserverX11); |
| 398 display_change_observer_->NotifyDisplayChange(); |
| 399 } |
| 400 #endif |
| 401 |
| 395 // Install the custom factory first so that views::FocusManagers for Tray, | 402 // Install the custom factory first so that views::FocusManagers for Tray, |
| 396 // Launcher, and WallPaper could be created by the factory. | 403 // Launcher, and WallPaper could be created by the factory. |
| 397 views::FocusManagerFactory::Install(new AshFocusManagerFactory); | 404 views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
| 398 | 405 |
| 399 env_filter_.reset(new views::corewm::CompoundEventFilter); | 406 env_filter_.reset(new views::corewm::CompoundEventFilter); |
| 400 AddPreTargetHandler(env_filter_.get()); | 407 AddPreTargetHandler(env_filter_.get()); |
| 401 | 408 |
| 402 focus_manager_.reset(new aura::FocusManager); | 409 focus_manager_.reset(new aura::FocusManager); |
| 403 activation_controller_.reset( | 410 activation_controller_.reset( |
| 404 new internal::ActivationController(focus_manager_.get())); | 411 new internal::ActivationController(focus_manager_.get())); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 } | 612 } |
| 606 | 613 |
| 607 void Shell::RotateFocus(Direction direction) { | 614 void Shell::RotateFocus(Direction direction) { |
| 608 focus_cycler_->RotateFocus( | 615 focus_cycler_->RotateFocus( |
| 609 direction == FORWARD ? internal::FocusCycler::FORWARD : | 616 direction == FORWARD ? internal::FocusCycler::FORWARD : |
| 610 internal::FocusCycler::BACKWARD); | 617 internal::FocusCycler::BACKWARD); |
| 611 } | 618 } |
| 612 | 619 |
| 613 void Shell::SetDisplayWorkAreaInsets(Window* contains, | 620 void Shell::SetDisplayWorkAreaInsets(Window* contains, |
| 614 const gfx::Insets& insets) { | 621 const gfx::Insets& insets) { |
| 615 internal::MultiDisplayManager* display_manager = | 622 if (!display_manager_->UpdateWorkAreaOfDisplayNearestWindow(contains, insets)) |
| 616 static_cast<internal::MultiDisplayManager*>( | |
| 617 aura::Env::GetInstance()->display_manager()); | |
| 618 if (!display_manager->UpdateWorkAreaOfDisplayNearestWindow(contains, insets)) | |
| 619 return; | 623 return; |
| 620 FOR_EACH_OBSERVER(ShellObserver, observers_, | 624 FOR_EACH_OBSERVER(ShellObserver, observers_, |
| 621 OnDisplayWorkAreaInsetsChanged()); | 625 OnDisplayWorkAreaInsetsChanged()); |
| 622 } | 626 } |
| 623 | 627 |
| 624 void Shell::OnLoginStateChanged(user::LoginStatus status) { | 628 void Shell::OnLoginStateChanged(user::LoginStatus status) { |
| 625 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); | 629 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); |
| 626 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 630 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 627 for (RootWindowControllerList::iterator iter = controllers.begin(); | 631 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 628 iter != controllers.end(); ++iter) | 632 iter != controllers.end(); ++iter) |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 | 848 |
| 845 bool Shell::CanAcceptEvents() { | 849 bool Shell::CanAcceptEvents() { |
| 846 return true; | 850 return true; |
| 847 } | 851 } |
| 848 | 852 |
| 849 ui::EventTarget* Shell::GetParentTarget() { | 853 ui::EventTarget* Shell::GetParentTarget() { |
| 850 return NULL; | 854 return NULL; |
| 851 } | 855 } |
| 852 | 856 |
| 853 } // namespace ash | 857 } // namespace ash |
| OLD | NEW |