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/ash_switches.h" | 10 #include "ash/ash_switches.h" |
11 #include "ash/desktop_background/desktop_background_controller.h" | 11 #include "ash/desktop_background/desktop_background_controller.h" |
12 #include "ash/desktop_background/desktop_background_resources.h" | 12 #include "ash/desktop_background/desktop_background_resources.h" |
13 #include "ash/desktop_background/desktop_background_view.h" | 13 #include "ash/desktop_background/desktop_background_view.h" |
14 #include "ash/drag_drop/drag_drop_controller.h" | 14 #include "ash/drag_drop/drag_drop_controller.h" |
15 #include "ash/focus_cycler.h" | 15 #include "ash/focus_cycler.h" |
16 #include "ash/ime/input_method_event_filter.h" | |
17 #include "ash/launcher/launcher.h" | 16 #include "ash/launcher/launcher.h" |
18 #include "ash/magnifier/magnification_controller.h" | 17 #include "ash/magnifier/magnification_controller.h" |
19 #include "ash/monitor/monitor_controller.h" | 18 #include "ash/monitor/monitor_controller.h" |
20 #include "ash/monitor/multi_monitor_manager.h" | 19 #include "ash/monitor/multi_monitor_manager.h" |
21 #include "ash/screen_ash.h" | 20 #include "ash/screen_ash.h" |
22 #include "ash/shell_context_menu.h" | 21 #include "ash/shell_context_menu.h" |
23 #include "ash/shell_delegate.h" | 22 #include "ash/shell_delegate.h" |
24 #include "ash/shell_factory.h" | 23 #include "ash/shell_factory.h" |
25 #include "ash/shell_window_ids.h" | 24 #include "ash/shell_window_ids.h" |
26 #include "ash/system/bluetooth/bluetooth_observer.h" | 25 #include "ash/system/bluetooth/bluetooth_observer.h" |
27 #include "ash/system/network/network_observer.h" | 26 #include "ash/system/network/network_observer.h" |
28 #include "ash/system/tray/system_tray.h" | 27 #include "ash/system/tray/system_tray.h" |
29 #include "ash/system/tray/system_tray_delegate.h" | 28 #include "ash/system/tray/system_tray_delegate.h" |
30 #include "ash/tooltips/tooltip_controller.h" | 29 #include "ash/tooltips/tooltip_controller.h" |
31 #include "ash/wm/activation_controller.h" | 30 #include "ash/wm/activation_controller.h" |
32 #include "ash/wm/app_list_controller.h" | 31 #include "ash/wm/app_list_controller.h" |
33 #include "ash/wm/base_layout_manager.h" | 32 #include "ash/wm/base_layout_manager.h" |
34 #include "ash/wm/custom_frame_view_ash.h" | 33 #include "ash/wm/custom_frame_view_ash.h" |
35 #include "ash/wm/dialog_frame_view.h" | 34 #include "ash/wm/dialog_frame_view.h" |
36 #include "ash/wm/event_client_impl.h" | 35 #include "ash/wm/event_client_impl.h" |
37 #include "ash/wm/key_rewriter_event_filter.h" | 36 #include "ash/wm/key_rewriter_event_filter.h" |
38 #include "ash/wm/panel_layout_manager.h" | 37 #include "ash/wm/panel_layout_manager.h" |
39 #include "ash/wm/panel_window_event_filter.h" | 38 #include "ash/wm/panel_window_event_filter.h" |
40 #include "ash/wm/partial_screenshot_event_filter.h" | 39 #include "ash/wm/partial_screenshot_event_filter.h" |
41 #include "ash/wm/power_button_controller.h" | 40 #include "ash/wm/power_button_controller.h" |
42 #include "ash/wm/resize_shadow_controller.h" | 41 #include "ash/wm/resize_shadow_controller.h" |
43 #include "ash/wm/root_window_event_filter.h" | |
44 #include "ash/wm/root_window_layout_manager.h" | 42 #include "ash/wm/root_window_layout_manager.h" |
45 #include "ash/wm/screen_dimmer.h" | 43 #include "ash/wm/screen_dimmer.h" |
46 #include "ash/wm/shadow_controller.h" | 44 #include "ash/wm/shadow_controller.h" |
47 #include "ash/wm/shelf_layout_manager.h" | 45 #include "ash/wm/shelf_layout_manager.h" |
48 #include "ash/wm/stacking_controller.h" | 46 #include "ash/wm/stacking_controller.h" |
49 #include "ash/wm/status_area_layout_manager.h" | 47 #include "ash/wm/status_area_layout_manager.h" |
50 #include "ash/wm/system_gesture_event_filter.h" | 48 #include "ash/wm/system_gesture_event_filter.h" |
51 #include "ash/wm/system_modal_container_layout_manager.h" | 49 #include "ash/wm/system_modal_container_layout_manager.h" |
52 #include "ash/wm/toplevel_window_event_filter.h" | 50 #include "ash/wm/toplevel_window_event_filter.h" |
53 #include "ash/wm/video_detector.h" | 51 #include "ash/wm/video_detector.h" |
54 #include "ash/wm/visibility_controller.h" | 52 #include "ash/wm/visibility_controller.h" |
55 #include "ash/wm/window_cycle_controller.h" | 53 #include "ash/wm/window_cycle_controller.h" |
56 #include "ash/wm/window_modality_controller.h" | 54 #include "ash/wm/window_modality_controller.h" |
57 #include "ash/wm/window_util.h" | 55 #include "ash/wm/window_util.h" |
58 #include "ash/wm/workspace/workspace_event_filter.h" | 56 #include "ash/wm/workspace/workspace_event_filter.h" |
59 #include "ash/wm/workspace/workspace_layout_manager.h" | 57 #include "ash/wm/workspace/workspace_layout_manager.h" |
60 #include "ash/wm/workspace/workspace_manager.h" | 58 #include "ash/wm/workspace/workspace_manager.h" |
61 #include "ash/wm/workspace_controller.h" | 59 #include "ash/wm/workspace_controller.h" |
62 #include "base/bind.h" | 60 #include "base/bind.h" |
63 #include "base/command_line.h" | 61 #include "base/command_line.h" |
64 #include "grit/ui_resources.h" | 62 #include "grit/ui_resources.h" |
65 #include "third_party/skia/include/core/SkBitmap.h" | 63 #include "third_party/skia/include/core/SkBitmap.h" |
66 #include "ui/aura/client/aura_constants.h" | 64 #include "ui/aura/client/aura_constants.h" |
67 #include "ui/aura/env.h" | 65 #include "ui/aura/env.h" |
68 #include "ui/aura/layout_manager.h" | 66 #include "ui/aura/layout_manager.h" |
69 #include "ui/aura/monitor_manager.h" | 67 #include "ui/aura/monitor_manager.h" |
70 #include "ui/aura/root_window.h" | 68 #include "ui/aura/root_window.h" |
69 #include "ui/aura/shared/input_method_event_filter.h" | |
70 #include "ui/aura/shared/root_window_event_filter.h" | |
71 #include "ui/aura/ui_controls_aura.h" | 71 #include "ui/aura/ui_controls_aura.h" |
72 #include "ui/aura/window.h" | 72 #include "ui/aura/window.h" |
73 #include "ui/compositor/layer.h" | 73 #include "ui/compositor/layer.h" |
74 #include "ui/compositor/layer_animator.h" | 74 #include "ui/compositor/layer_animator.h" |
75 #include "ui/gfx/monitor.h" | 75 #include "ui/gfx/monitor.h" |
76 #include "ui/gfx/screen.h" | 76 #include "ui/gfx/screen.h" |
77 #include "ui/gfx/size.h" | 77 #include "ui/gfx/size.h" |
78 #include "ui/ui_controls/ui_controls.h" | 78 #include "ui/ui_controls/ui_controls.h" |
79 #include "ui/views/widget/native_widget_aura.h" | 79 #include "ui/views/widget/native_widget_aura.h" |
80 #include "ui/views/widget/widget.h" | 80 #include "ui/views/widget/widget.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 | 508 |
509 //////////////////////////////////////////////////////////////////////////////// | 509 //////////////////////////////////////////////////////////////////////////////// |
510 // Shell::TestApi | 510 // Shell::TestApi |
511 | 511 |
512 Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {} | 512 Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {} |
513 | 513 |
514 internal::RootWindowLayoutManager* Shell::TestApi::root_window_layout() { | 514 internal::RootWindowLayoutManager* Shell::TestApi::root_window_layout() { |
515 return shell_->root_window_layout_; | 515 return shell_->root_window_layout_; |
516 } | 516 } |
517 | 517 |
518 internal::InputMethodEventFilter* Shell::TestApi::input_method_event_filter() { | 518 aura::shared::InputMethodEventFilter* |
519 Shell::TestApi::input_method_event_filter() { | |
Ben Goodger (Google)
2012/05/15 17:35:13
nit indent 4 spaces
| |
519 return shell_->input_method_filter_.get(); | 520 return shell_->input_method_filter_.get(); |
520 } | 521 } |
521 | 522 |
522 internal::SystemGestureEventFilter* | 523 internal::SystemGestureEventFilter* |
523 Shell::TestApi::system_gesture_event_filter() { | 524 Shell::TestApi::system_gesture_event_filter() { |
524 return shell_->system_gesture_filter_.get(); | 525 return shell_->system_gesture_filter_.get(); |
525 } | 526 } |
526 | 527 |
527 internal::WorkspaceController* Shell::TestApi::workspace_controller() { | 528 internal::WorkspaceController* Shell::TestApi::workspace_controller() { |
528 return shell_->workspace_controller_.get(); | 529 return shell_->workspace_controller_.get(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
633 instance_ = NULL; | 634 instance_ = NULL; |
634 } | 635 } |
635 | 636 |
636 // static | 637 // static |
637 aura::RootWindow* Shell::GetRootWindow() { | 638 aura::RootWindow* Shell::GetRootWindow() { |
638 return GetInstance()->root_window_.get(); | 639 return GetInstance()->root_window_.get(); |
639 } | 640 } |
640 | 641 |
641 void Shell::Init() { | 642 void Shell::Init() { |
642 aura::RootWindow* root_window = GetRootWindow(); | 643 aura::RootWindow* root_window = GetRootWindow(); |
643 root_filter_ = new internal::RootWindowEventFilter(root_window); | 644 root_filter_ = new aura::shared::RootWindowEventFilter(root_window); |
644 #if !defined(OS_MACOSX) | 645 #if !defined(OS_MACOSX) |
645 nested_dispatcher_controller_.reset(new NestedDispatcherController); | 646 nested_dispatcher_controller_.reset(new NestedDispatcherController); |
646 accelerator_controller_.reset(new AcceleratorController); | 647 accelerator_controller_.reset(new AcceleratorController); |
647 #endif | 648 #endif |
648 shell_context_menu_.reset(new internal::ShellContextMenu); | 649 shell_context_menu_.reset(new internal::ShellContextMenu); |
649 // Pass ownership of the filter to the root window. | 650 // Pass ownership of the filter to the root window. |
650 GetRootWindow()->SetEventFilter(root_filter_); | 651 GetRootWindow()->SetEventFilter(root_filter_); |
651 | 652 |
652 // KeyRewriterEventFilter must be the first one. | 653 // KeyRewriterEventFilter must be the first one. |
653 DCHECK(!GetRootWindowEventFilterCount()); | 654 DCHECK(!GetRootWindowEventFilterCount()); |
654 key_rewriter_filter_.reset(new internal::KeyRewriterEventFilter); | 655 key_rewriter_filter_.reset(new internal::KeyRewriterEventFilter); |
655 AddRootWindowEventFilter(key_rewriter_filter_.get()); | 656 AddRootWindowEventFilter(key_rewriter_filter_.get()); |
656 | 657 |
657 // PartialScreenshotEventFilter must be the second one to capture key | 658 // PartialScreenshotEventFilter must be the second one to capture key |
658 // events when the taking partial screenshot UI is there. | 659 // events when the taking partial screenshot UI is there. |
659 DCHECK_EQ(1U, GetRootWindowEventFilterCount()); | 660 DCHECK_EQ(1U, GetRootWindowEventFilterCount()); |
660 partial_screenshot_filter_.reset(new internal::PartialScreenshotEventFilter); | 661 partial_screenshot_filter_.reset(new internal::PartialScreenshotEventFilter); |
661 AddRootWindowEventFilter(partial_screenshot_filter_.get()); | 662 AddRootWindowEventFilter(partial_screenshot_filter_.get()); |
662 AddShellObserver(partial_screenshot_filter_.get()); | 663 AddShellObserver(partial_screenshot_filter_.get()); |
663 | 664 |
664 // InputMethodEventFilter must be the third one. It has to be added before | 665 // InputMethodEventFilter must be the third one. It has to be added before |
665 // AcceleratorFilter. | 666 // AcceleratorFilter. |
666 DCHECK_EQ(2U, GetRootWindowEventFilterCount()); | 667 DCHECK_EQ(2U, GetRootWindowEventFilterCount()); |
667 input_method_filter_.reset(new internal::InputMethodEventFilter); | 668 input_method_filter_.reset( |
669 new aura::shared::InputMethodEventFilter(root_window)); | |
668 AddRootWindowEventFilter(input_method_filter_.get()); | 670 AddRootWindowEventFilter(input_method_filter_.get()); |
669 #if !defined(OS_MACOSX) | 671 #if !defined(OS_MACOSX) |
670 accelerator_filter_.reset(new internal::AcceleratorFilter); | 672 accelerator_filter_.reset(new internal::AcceleratorFilter); |
671 AddRootWindowEventFilter(accelerator_filter_.get()); | 673 AddRootWindowEventFilter(accelerator_filter_.get()); |
672 #endif | 674 #endif |
673 | 675 |
674 system_gesture_filter_.reset(new internal::SystemGestureEventFilter); | 676 system_gesture_filter_.reset(new internal::SystemGestureEventFilter); |
675 AddRootWindowEventFilter(system_gesture_filter_.get()); | 677 AddRootWindowEventFilter(system_gesture_filter_.get()); |
676 | 678 |
677 root_window->SetCursor(ui::kCursorPointer); | 679 root_window->SetCursor(ui::kCursorPointer); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 aura::Window* Shell::GetContainer(int container_id) { | 749 aura::Window* Shell::GetContainer(int container_id) { |
748 return const_cast<aura::Window*>( | 750 return const_cast<aura::Window*>( |
749 const_cast<const Shell*>(this)->GetContainer(container_id)); | 751 const_cast<const Shell*>(this)->GetContainer(container_id)); |
750 } | 752 } |
751 | 753 |
752 const aura::Window* Shell::GetContainer(int container_id) const { | 754 const aura::Window* Shell::GetContainer(int container_id) const { |
753 return GetRootWindow()->GetChildById(container_id); | 755 return GetRootWindow()->GetChildById(container_id); |
754 } | 756 } |
755 | 757 |
756 void Shell::AddRootWindowEventFilter(aura::EventFilter* filter) { | 758 void Shell::AddRootWindowEventFilter(aura::EventFilter* filter) { |
757 static_cast<internal::RootWindowEventFilter*>( | 759 static_cast<aura::shared::RootWindowEventFilter*>( |
758 GetRootWindow()->event_filter())->AddFilter(filter); | 760 GetRootWindow()->event_filter())->AddFilter(filter); |
759 } | 761 } |
760 | 762 |
761 void Shell::RemoveRootWindowEventFilter(aura::EventFilter* filter) { | 763 void Shell::RemoveRootWindowEventFilter(aura::EventFilter* filter) { |
762 static_cast<internal::RootWindowEventFilter*>( | 764 static_cast<aura::shared::RootWindowEventFilter*>( |
763 GetRootWindow()->event_filter())->RemoveFilter(filter); | 765 GetRootWindow()->event_filter())->RemoveFilter(filter); |
764 } | 766 } |
765 | 767 |
766 size_t Shell::GetRootWindowEventFilterCount() const { | 768 size_t Shell::GetRootWindowEventFilterCount() const { |
767 return static_cast<internal::RootWindowEventFilter*>( | 769 return static_cast<aura::shared::RootWindowEventFilter*>( |
768 GetRootWindow()->event_filter())->GetFilterCount(); | 770 GetRootWindow()->event_filter())->GetFilterCount(); |
769 } | 771 } |
770 | 772 |
771 void Shell::ShowBackgroundMenu(views::Widget* widget, | 773 void Shell::ShowBackgroundMenu(views::Widget* widget, |
772 const gfx::Point& location) { | 774 const gfx::Point& location) { |
773 if (shell_context_menu_.get()) | 775 if (shell_context_menu_.get()) |
774 shell_context_menu_->ShowMenu(widget, location); | 776 shell_context_menu_->ShowMenu(widget, location); |
775 } | 777 } |
776 | 778 |
777 void Shell::ToggleAppList() { | 779 void Shell::ToggleAppList() { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
938 panel_container->SetLayoutManager(panel_layout_manager_); | 940 panel_container->SetLayoutManager(panel_layout_manager_); |
939 } | 941 } |
940 } | 942 } |
941 | 943 |
942 void Shell::DisableWorkspaceGridLayout() { | 944 void Shell::DisableWorkspaceGridLayout() { |
943 if (workspace_controller_.get()) | 945 if (workspace_controller_.get()) |
944 workspace_controller_->workspace_manager()->set_grid_size(0); | 946 workspace_controller_->workspace_manager()->set_grid_size(0); |
945 } | 947 } |
946 | 948 |
947 } // namespace ash | 949 } // namespace ash |
OLD | NEW |