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/accelerator_controller.h" | 10 #include "ash/accelerators/accelerator_controller.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 #include "ui/aura/root_window.h" | 86 #include "ui/aura/root_window.h" |
87 #include "ui/aura/window.h" | 87 #include "ui/aura/window.h" |
88 #include "ui/base/ui_base_switches.h" | 88 #include "ui/base/ui_base_switches.h" |
89 #include "ui/compositor/layer.h" | 89 #include "ui/compositor/layer.h" |
90 #include "ui/compositor/layer_animator.h" | 90 #include "ui/compositor/layer_animator.h" |
91 #include "ui/gfx/display.h" | 91 #include "ui/gfx/display.h" |
92 #include "ui/gfx/image/image_skia.h" | 92 #include "ui/gfx/image/image_skia.h" |
93 #include "ui/gfx/screen.h" | 93 #include "ui/gfx/screen.h" |
94 #include "ui/gfx/size.h" | 94 #include "ui/gfx/size.h" |
95 #include "ui/keyboard/keyboard.h" | 95 #include "ui/keyboard/keyboard.h" |
| 96 #include "ui/keyboard/keyboard_controller.h" |
96 #include "ui/keyboard/keyboard_util.h" | 97 #include "ui/keyboard/keyboard_util.h" |
97 #include "ui/message_center/message_center.h" | 98 #include "ui/message_center/message_center.h" |
98 #include "ui/views/corewm/compound_event_filter.h" | 99 #include "ui/views/corewm/compound_event_filter.h" |
99 #include "ui/views/corewm/corewm_switches.h" | 100 #include "ui/views/corewm/corewm_switches.h" |
100 #include "ui/views/corewm/focus_controller.h" | 101 #include "ui/views/corewm/focus_controller.h" |
101 #include "ui/views/corewm/input_method_event_filter.h" | 102 #include "ui/views/corewm/input_method_event_filter.h" |
102 #include "ui/views/corewm/shadow_controller.h" | 103 #include "ui/views/corewm/shadow_controller.h" |
103 #include "ui/views/corewm/tooltip_controller.h" | 104 #include "ui/views/corewm/tooltip_controller.h" |
104 #include "ui/views/corewm/visibility_controller.h" | 105 #include "ui/views/corewm/visibility_controller.h" |
105 #include "ui/views/corewm/window_modality_controller.h" | 106 #include "ui/views/corewm/window_modality_controller.h" |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 system_tray_notifier_.reset(new ash::SystemTrayNotifier()); | 552 system_tray_notifier_.reset(new ash::SystemTrayNotifier()); |
552 | 553 |
553 // Initialize system_tray_delegate_ before initializing StatusAreaWidget. | 554 // Initialize system_tray_delegate_ before initializing StatusAreaWidget. |
554 system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate()); | 555 system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate()); |
555 DCHECK(system_tray_delegate_.get()); | 556 DCHECK(system_tray_delegate_.get()); |
556 | 557 |
557 internal::RootWindowController* root_window_controller = | 558 internal::RootWindowController* root_window_controller = |
558 new internal::RootWindowController(root_window); | 559 new internal::RootWindowController(root_window); |
559 InitRootWindowController(root_window_controller, | 560 InitRootWindowController(root_window_controller, |
560 delegate_->IsFirstRunAfterBoot()); | 561 delegate_->IsFirstRunAfterBoot()); |
| 562 InitKeyboard(root_window_controller); |
561 | 563 |
562 locale_notification_controller_.reset( | 564 locale_notification_controller_.reset( |
563 new internal::LocaleNotificationController); | 565 new internal::LocaleNotificationController); |
564 | 566 |
565 // Initialize system_tray_delegate_ after StatusAreaWidget is created. | 567 // Initialize system_tray_delegate_ after StatusAreaWidget is created. |
566 system_tray_delegate_->Initialize(); | 568 system_tray_delegate_->Initialize(); |
567 | 569 |
568 display_controller_->InitSecondaryDisplays(); | 570 display_controller_->InitSecondaryDisplays(); |
569 | 571 |
570 // Force Layout | 572 // Force Layout |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 const gfx::Insets& insets) { | 680 const gfx::Insets& insets) { |
679 if (!display_controller_->UpdateWorkAreaOfDisplayNearestWindow( | 681 if (!display_controller_->UpdateWorkAreaOfDisplayNearestWindow( |
680 contains, insets)) { | 682 contains, insets)) { |
681 return; | 683 return; |
682 } | 684 } |
683 FOR_EACH_OBSERVER(ShellObserver, observers_, | 685 FOR_EACH_OBSERVER(ShellObserver, observers_, |
684 OnDisplayWorkAreaInsetsChanged()); | 686 OnDisplayWorkAreaInsetsChanged()); |
685 } | 687 } |
686 | 688 |
687 void Shell::OnLoginStateChanged(user::LoginStatus status) { | 689 void Shell::OnLoginStateChanged(user::LoginStatus status) { |
| 690 if (status != user::LOGGED_IN_NONE) { |
| 691 // TODO(bshe): Primary root window controller may not be the controller to |
| 692 // attach virtual keyboard. See http://crbug.com/303429 |
| 693 InitKeyboard(GetPrimaryRootWindowController()); |
| 694 } |
688 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); | 695 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); |
689 } | 696 } |
690 | 697 |
691 void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 698 void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
692 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 699 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
693 for (RootWindowControllerList::iterator iter = controllers.begin(); | 700 for (RootWindowControllerList::iterator iter = controllers.begin(); |
694 iter != controllers.end(); ++iter) | 701 iter != controllers.end(); ++iter) |
695 (*iter)->UpdateAfterLoginStatusChange(status); | 702 (*iter)->UpdateAfterLoginStatusChange(status); |
696 } | 703 } |
697 | 704 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 // Create a launcher if a user is already logged. | 868 // Create a launcher if a user is already logged. |
862 if (Shell::GetInstance()->session_state_delegate()->NumberOfLoggedInUsers()) | 869 if (Shell::GetInstance()->session_state_delegate()->NumberOfLoggedInUsers()) |
863 controller->shelf()->CreateLauncher(); | 870 controller->shelf()->CreateLauncher(); |
864 } | 871 } |
865 | 872 |
866 void Shell::DoInitialWorkspaceAnimation() { | 873 void Shell::DoInitialWorkspaceAnimation() { |
867 return GetPrimaryRootWindowController()->workspace_controller()-> | 874 return GetPrimaryRootWindowController()->workspace_controller()-> |
868 DoInitialAnimation(); | 875 DoInitialAnimation(); |
869 } | 876 } |
870 | 877 |
| 878 //////////////////////////////////////////////////////////////////////////////// |
| 879 // Shell, private: |
| 880 |
| 881 void Shell::InitKeyboard(internal::RootWindowController* root) { |
| 882 if (keyboard::IsKeyboardEnabled()) { |
| 883 keyboard::KeyboardControllerProxy* proxy = |
| 884 delegate_->CreateKeyboardControllerProxy(); |
| 885 keyboard_controller_.reset( |
| 886 new keyboard::KeyboardController(proxy)); |
| 887 std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( |
| 888 internal::kShellWindowId_VirtualKeyboardContainer, NULL); |
| 889 // Removes old keyboard container if any. |
| 890 if (!containers.empty()) { |
| 891 CHECK_EQ(1U, containers.size()); |
| 892 delete containers[0]; |
| 893 } |
| 894 root->EnableKeyboard(keyboard_controller_.get()); |
| 895 } |
| 896 } |
| 897 |
871 void Shell::InitRootWindowController( | 898 void Shell::InitRootWindowController( |
872 internal::RootWindowController* controller, | 899 internal::RootWindowController* controller, |
873 bool first_run_after_boot) { | 900 bool first_run_after_boot) { |
874 | 901 |
875 aura::RootWindow* root_window = controller->root_window(); | 902 aura::RootWindow* root_window = controller->root_window(); |
876 DCHECK(activation_client_); | 903 DCHECK(activation_client_); |
877 DCHECK(visibility_controller_.get()); | 904 DCHECK(visibility_controller_.get()); |
878 DCHECK(drag_drop_controller_.get()); | 905 DCHECK(drag_drop_controller_.get()); |
879 DCHECK(window_cycle_controller_.get()); | 906 DCHECK(window_cycle_controller_.get()); |
880 | 907 |
(...skipping 14 matching lines...) Expand all Loading... |
895 if (nested_dispatcher_controller_) { | 922 if (nested_dispatcher_controller_) { |
896 aura::client::SetDispatcherClient(root_window, | 923 aura::client::SetDispatcherClient(root_window, |
897 nested_dispatcher_controller_.get()); | 924 nested_dispatcher_controller_.get()); |
898 } | 925 } |
899 if (user_action_client_) | 926 if (user_action_client_) |
900 aura::client::SetUserActionClient(root_window, user_action_client_.get()); | 927 aura::client::SetUserActionClient(root_window, user_action_client_.get()); |
901 | 928 |
902 controller->Init(first_run_after_boot); | 929 controller->Init(first_run_after_boot); |
903 } | 930 } |
904 | 931 |
905 //////////////////////////////////////////////////////////////////////////////// | |
906 // Shell, private: | |
907 | |
908 bool Shell::CanWindowReceiveEvents(aura::Window* window) { | 932 bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
909 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 933 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
910 for (RootWindowControllerList::iterator iter = controllers.begin(); | 934 for (RootWindowControllerList::iterator iter = controllers.begin(); |
911 iter != controllers.end(); ++iter) { | 935 iter != controllers.end(); ++iter) { |
912 internal::SystemModalContainerLayoutManager* layout_manager = | 936 internal::SystemModalContainerLayoutManager* layout_manager = |
913 (*iter)->GetSystemModalLayoutManager(window); | 937 (*iter)->GetSystemModalLayoutManager(window); |
914 if (layout_manager && layout_manager->CanWindowReceiveEvents(window)) | 938 if (layout_manager && layout_manager->CanWindowReceiveEvents(window)) |
915 return true; | 939 return true; |
916 } | 940 } |
917 return false; | 941 return false; |
(...skipping 16 matching lines...) Expand all Loading... |
934 //////////////////////////////////////////////////////////////////////////////// | 958 //////////////////////////////////////////////////////////////////////////////// |
935 // Shell, aura::client::ActivationChangeObserver implementation: | 959 // Shell, aura::client::ActivationChangeObserver implementation: |
936 | 960 |
937 void Shell::OnWindowActivated(aura::Window* gained_active, | 961 void Shell::OnWindowActivated(aura::Window* gained_active, |
938 aura::Window* lost_active) { | 962 aura::Window* lost_active) { |
939 if (gained_active) | 963 if (gained_active) |
940 target_root_window_ = gained_active->GetRootWindow(); | 964 target_root_window_ = gained_active->GetRootWindow(); |
941 } | 965 } |
942 | 966 |
943 } // namespace ash | 967 } // namespace ash |
OLD | NEW |