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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "ash/shell_window_ids.h" | 29 #include "ash/shell_window_ids.h" |
30 #include "ash/system/status_area_widget.h" | 30 #include "ash/system/status_area_widget.h" |
31 #include "ash/system/tray/system_tray_delegate.h" | 31 #include "ash/system/tray/system_tray_delegate.h" |
32 #include "ash/system/tray/system_tray_notifier.h" | 32 #include "ash/system/tray/system_tray_notifier.h" |
33 #include "ash/tooltips/tooltip_controller.h" | 33 #include "ash/tooltips/tooltip_controller.h" |
34 #include "ash/touch/touch_observer_hud.h" | 34 #include "ash/touch/touch_observer_hud.h" |
35 #include "ash/wm/activation_controller.h" | 35 #include "ash/wm/activation_controller.h" |
36 #include "ash/wm/always_on_top_controller.h" | 36 #include "ash/wm/always_on_top_controller.h" |
37 #include "ash/wm/app_list_controller.h" | 37 #include "ash/wm/app_list_controller.h" |
38 #include "ash/wm/ash_activation_controller.h" | 38 #include "ash/wm/ash_activation_controller.h" |
| 39 #include "ash/wm/ash_focus_rules.h" |
39 #include "ash/wm/base_layout_manager.h" | 40 #include "ash/wm/base_layout_manager.h" |
40 #include "ash/wm/capture_controller.h" | 41 #include "ash/wm/capture_controller.h" |
41 #include "ash/wm/coordinate_conversion.h" | 42 #include "ash/wm/coordinate_conversion.h" |
42 #include "ash/wm/custom_frame_view_ash.h" | 43 #include "ash/wm/custom_frame_view_ash.h" |
43 #include "ash/wm/dialog_frame_view.h" | 44 #include "ash/wm/dialog_frame_view.h" |
44 #include "ash/wm/event_client_impl.h" | 45 #include "ash/wm/event_client_impl.h" |
45 #include "ash/wm/event_rewriter_event_filter.h" | 46 #include "ash/wm/event_rewriter_event_filter.h" |
46 #include "ash/wm/overlay_event_filter.h" | 47 #include "ash/wm/overlay_event_filter.h" |
47 #include "ash/wm/power_button_controller.h" | 48 #include "ash/wm/power_button_controller.h" |
48 #include "ash/wm/property_util.h" | 49 #include "ash/wm/property_util.h" |
(...skipping 27 matching lines...) Expand all Loading... |
76 #include "ui/aura/ui_controls_aura.h" | 77 #include "ui/aura/ui_controls_aura.h" |
77 #include "ui/aura/window.h" | 78 #include "ui/aura/window.h" |
78 #include "ui/compositor/layer.h" | 79 #include "ui/compositor/layer.h" |
79 #include "ui/compositor/layer_animator.h" | 80 #include "ui/compositor/layer_animator.h" |
80 #include "ui/gfx/display.h" | 81 #include "ui/gfx/display.h" |
81 #include "ui/gfx/image/image_skia.h" | 82 #include "ui/gfx/image/image_skia.h" |
82 #include "ui/gfx/screen.h" | 83 #include "ui/gfx/screen.h" |
83 #include "ui/gfx/size.h" | 84 #include "ui/gfx/size.h" |
84 #include "ui/ui_controls/ui_controls.h" | 85 #include "ui/ui_controls/ui_controls.h" |
85 #include "ui/views/corewm/compound_event_filter.h" | 86 #include "ui/views/corewm/compound_event_filter.h" |
| 87 #include "ui/views/corewm/corewm_switches.h" |
| 88 #include "ui/views/corewm/focus_controller.h" |
86 #include "ui/views/corewm/input_method_event_filter.h" | 89 #include "ui/views/corewm/input_method_event_filter.h" |
87 #include "ui/views/corewm/shadow_controller.h" | 90 #include "ui/views/corewm/shadow_controller.h" |
88 #include "ui/views/corewm/visibility_controller.h" | 91 #include "ui/views/corewm/visibility_controller.h" |
89 #include "ui/views/corewm/window_modality_controller.h" | 92 #include "ui/views/corewm/window_modality_controller.h" |
90 #include "ui/views/focus/focus_manager_factory.h" | 93 #include "ui/views/focus/focus_manager_factory.h" |
91 #include "ui/views/widget/native_widget_aura.h" | 94 #include "ui/views/widget/native_widget_aura.h" |
92 #include "ui/views/widget/widget.h" | 95 #include "ui/views/widget/widget.h" |
93 | 96 |
94 #if !defined(OS_MACOSX) | 97 #if !defined(OS_MACOSX) |
95 #include "ash/accelerators/accelerator_controller.h" | 98 #include "ash/accelerators/accelerator_controller.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Overridden from views::corewm::VisibilityController: | 169 // Overridden from views::corewm::VisibilityController: |
167 virtual bool CallAnimateOnChildWindowVisibilityChanged( | 170 virtual bool CallAnimateOnChildWindowVisibilityChanged( |
168 aura::Window* window, | 171 aura::Window* window, |
169 bool visible) OVERRIDE { | 172 bool visible) OVERRIDE { |
170 return AnimateOnChildWindowVisibilityChanged(window, visible); | 173 return AnimateOnChildWindowVisibilityChanged(window, visible); |
171 } | 174 } |
172 | 175 |
173 DISALLOW_COPY_AND_ASSIGN(AshVisibilityController); | 176 DISALLOW_COPY_AND_ASSIGN(AshVisibilityController); |
174 }; | 177 }; |
175 | 178 |
| 179 bool UseFocusController() { |
| 180 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 181 views::corewm::switches::kUseFocusController); |
| 182 } |
| 183 |
176 } // namespace | 184 } // namespace |
177 | 185 |
178 // static | 186 // static |
179 Shell* Shell::instance_ = NULL; | 187 Shell* Shell::instance_ = NULL; |
180 // static | 188 // static |
181 bool Shell::initially_hide_cursor_ = false; | 189 bool Shell::initially_hide_cursor_ = false; |
182 | 190 |
183 //////////////////////////////////////////////////////////////////////////////// | 191 //////////////////////////////////////////////////////////////////////////////// |
184 // Shell::TestApi | 192 // Shell::TestApi |
185 | 193 |
(...skipping 22 matching lines...) Expand all Loading... |
208 return shell_->screen_position_controller_.get(); | 216 return shell_->screen_position_controller_.get(); |
209 } | 217 } |
210 | 218 |
211 //////////////////////////////////////////////////////////////////////////////// | 219 //////////////////////////////////////////////////////////////////////////////// |
212 // Shell, public: | 220 // Shell, public: |
213 | 221 |
214 Shell::Shell(ShellDelegate* delegate) | 222 Shell::Shell(ShellDelegate* delegate) |
215 : screen_(new ScreenAsh), | 223 : screen_(new ScreenAsh), |
216 active_root_window_(NULL), | 224 active_root_window_(NULL), |
217 delegate_(delegate), | 225 delegate_(delegate), |
| 226 activation_client_(NULL), |
218 #if defined(OS_CHROMEOS) | 227 #if defined(OS_CHROMEOS) |
219 output_configurator_(new chromeos::OutputConfigurator()), | 228 output_configurator_(new chromeos::OutputConfigurator()), |
220 output_configurator_animation_( | 229 output_configurator_animation_( |
221 new internal::OutputConfiguratorAnimation()), | 230 new internal::OutputConfiguratorAnimation()), |
222 #endif // defined(OS_CHROMEOS) | 231 #endif // defined(OS_CHROMEOS) |
223 browser_context_(NULL), | 232 browser_context_(NULL), |
224 simulate_modal_window_open_for_testing_(false) { | 233 simulate_modal_window_open_for_testing_(false) { |
225 DCHECK(delegate_.get()); | 234 DCHECK(delegate_.get()); |
226 display_manager_.reset(new internal::DisplayManager); | 235 display_manager_.reset(new internal::DisplayManager); |
227 ANNOTATE_LEAKING_OBJECT_PTR(screen_); // see crbug.com/156466 | 236 ANNOTATE_LEAKING_OBJECT_PTR(screen_); // see crbug.com/156466 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 } | 430 } |
422 #endif | 431 #endif |
423 | 432 |
424 // Install the custom factory first so that views::FocusManagers for Tray, | 433 // Install the custom factory first so that views::FocusManagers for Tray, |
425 // Launcher, and WallPaper could be created by the factory. | 434 // Launcher, and WallPaper could be created by the factory. |
426 views::FocusManagerFactory::Install(new AshFocusManagerFactory); | 435 views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
427 | 436 |
428 env_filter_.reset(new views::corewm::CompoundEventFilter); | 437 env_filter_.reset(new views::corewm::CompoundEventFilter); |
429 AddPreTargetHandler(env_filter_.get()); | 438 AddPreTargetHandler(env_filter_.get()); |
430 | 439 |
431 focus_client_.reset(new aura::FocusManager); | 440 if (UseFocusController()) { |
432 activation_controller_.reset( | 441 views::corewm::FocusController* focus_controller = |
433 new internal::ActivationController( | 442 new views::corewm::FocusController(new wm::AshFocusRules); |
434 focus_client_.get(), | 443 focus_client_.reset(focus_controller); |
435 new internal::AshActivationController)); | 444 activation_client_ = focus_controller; |
436 AddPreTargetHandler(activation_controller_.get()); | 445 } else { |
| 446 focus_client_.reset(new aura::FocusManager); |
| 447 activation_controller_.reset( |
| 448 new internal::ActivationController( |
| 449 focus_client_.get(), |
| 450 new internal::AshActivationController)); |
| 451 activation_client_ = activation_controller_.get(); |
| 452 AddPreTargetHandler(activation_controller_.get()); |
| 453 } |
437 | 454 |
438 focus_cycler_.reset(new internal::FocusCycler()); | 455 focus_cycler_.reset(new internal::FocusCycler()); |
439 | 456 |
440 screen_position_controller_.reset(new internal::ScreenPositionController); | 457 screen_position_controller_.reset(new internal::ScreenPositionController); |
441 display_controller_.reset(new DisplayController); | 458 display_controller_.reset(new DisplayController); |
442 display_controller_->InitPrimaryDisplay(); | 459 display_controller_->InitPrimaryDisplay(); |
443 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); | 460 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); |
444 active_root_window_ = root_window; | 461 active_root_window_ = root_window; |
445 | 462 |
446 cursor_manager_.SetDeviceScaleFactor( | 463 cursor_manager_.SetDeviceScaleFactor( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 AddPreTargetHandler(window_modality_controller_.get()); | 530 AddPreTargetHandler(window_modality_controller_.get()); |
514 | 531 |
515 magnification_controller_.reset( | 532 magnification_controller_.reset( |
516 MagnificationController::CreateInstance()); | 533 MagnificationController::CreateInstance()); |
517 | 534 |
518 partial_magnification_controller_.reset( | 535 partial_magnification_controller_.reset( |
519 new PartialMagnificationController()); | 536 new PartialMagnificationController()); |
520 | 537 |
521 high_contrast_controller_.reset(new HighContrastController); | 538 high_contrast_controller_.reset(new HighContrastController); |
522 video_detector_.reset(new VideoDetector); | 539 video_detector_.reset(new VideoDetector); |
523 window_cycle_controller_.reset( | 540 window_cycle_controller_.reset(new WindowCycleController(activation_client_)); |
524 new WindowCycleController(activation_controller_.get())); | |
525 | 541 |
526 tooltip_controller_.reset(new internal::TooltipController( | 542 tooltip_controller_.reset(new internal::TooltipController( |
527 drag_drop_controller_.get())); | 543 drag_drop_controller_.get())); |
528 AddPreTargetHandler(tooltip_controller_.get()); | 544 AddPreTargetHandler(tooltip_controller_.get()); |
529 | 545 |
530 event_client_.reset(new internal::EventClientImpl); | 546 event_client_.reset(new internal::EventClientImpl); |
531 | 547 |
532 InitRootWindowController(root_window_controller); | 548 InitRootWindowController(root_window_controller); |
533 | 549 |
534 // This controller needs to be set before SetupManagedWindowMode. | 550 // This controller needs to be set before SetupManagedWindowMode. |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 DoInitialAnimation(); | 831 DoInitialAnimation(); |
816 } | 832 } |
817 | 833 |
818 aura::client::StackingClient* Shell::stacking_client() { | 834 aura::client::StackingClient* Shell::stacking_client() { |
819 return stacking_client_.get(); | 835 return stacking_client_.get(); |
820 } | 836 } |
821 | 837 |
822 void Shell::InitRootWindowController( | 838 void Shell::InitRootWindowController( |
823 internal::RootWindowController* controller) { | 839 internal::RootWindowController* controller) { |
824 aura::RootWindow* root_window = controller->root_window(); | 840 aura::RootWindow* root_window = controller->root_window(); |
825 DCHECK(activation_controller_.get()); | 841 DCHECK(activation_client_); |
826 DCHECK(visibility_controller_.get()); | 842 DCHECK(visibility_controller_.get()); |
827 DCHECK(drag_drop_controller_.get()); | 843 DCHECK(drag_drop_controller_.get()); |
828 DCHECK(capture_controller_.get()); | 844 DCHECK(capture_controller_.get()); |
829 DCHECK(window_cycle_controller_.get()); | 845 DCHECK(window_cycle_controller_.get()); |
830 | 846 |
831 aura::client::SetFocusClient(root_window, focus_client_.get()); | 847 aura::client::SetFocusClient(root_window, focus_client_.get()); |
832 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); | 848 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); |
833 aura::client::SetActivationClient(root_window, activation_controller_.get()); | 849 aura::client::SetActivationClient(root_window, activation_client_); |
| 850 if (UseFocusController()) { |
| 851 views::corewm::FocusController* controller = |
| 852 static_cast<views::corewm::FocusController*>(activation_client_); |
| 853 root_window->AddPreTargetHandler(controller); |
| 854 } |
834 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); | 855 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
835 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); | 856 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
836 aura::client::SetCaptureClient(root_window, capture_controller_.get()); | 857 aura::client::SetCaptureClient(root_window, capture_controller_.get()); |
837 aura::client::SetScreenPositionClient(root_window, | 858 aura::client::SetScreenPositionClient(root_window, |
838 screen_position_controller_.get()); | 859 screen_position_controller_.get()); |
839 aura::client::SetCursorClient(root_window, &cursor_manager_); | 860 aura::client::SetCursorClient(root_window, &cursor_manager_); |
840 aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); | 861 aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); |
841 aura::client::SetEventClient(root_window, event_client_.get()); | 862 aura::client::SetEventClient(root_window, event_client_.get()); |
842 | 863 |
843 if (nested_dispatcher_controller_.get()) { | 864 if (nested_dispatcher_controller_.get()) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 | 904 |
884 bool Shell::CanAcceptEvents() { | 905 bool Shell::CanAcceptEvents() { |
885 return true; | 906 return true; |
886 } | 907 } |
887 | 908 |
888 ui::EventTarget* Shell::GetParentTarget() { | 909 ui::EventTarget* Shell::GetParentTarget() { |
889 return NULL; | 910 return NULL; |
890 } | 911 } |
891 | 912 |
892 } // namespace ash | 913 } // namespace ash |
OLD | NEW |