Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: ash/shell.cc

Issue 25111002: Only show virtual keyboard on primary root window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reviews Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } // namespace 152 } // namespace
152 153
153 // static 154 // static
154 Shell* Shell::instance_ = NULL; 155 Shell* Shell::instance_ = NULL;
155 // static 156 // static
156 bool Shell::initially_hide_cursor_ = false; 157 bool Shell::initially_hide_cursor_ = false;
157 158
158 //////////////////////////////////////////////////////////////////////////////// 159 ////////////////////////////////////////////////////////////////////////////////
159 // Shell, public: 160 // Shell, public:
160 161
161 Shell::Shell(ShellDelegate* delegate) 162 Shell::Shell(ShellDelegate* delegate)
varkha 2013/10/04 01:54:07 Ctor is private. Also verify that the methods are
bshe 2013/10/04 03:04:39 Done.
162 : screen_(new ScreenAsh), 163 : screen_(new ScreenAsh),
163 target_root_window_(NULL), 164 target_root_window_(NULL),
164 scoped_target_root_window_(NULL), 165 scoped_target_root_window_(NULL),
165 delegate_(delegate), 166 delegate_(delegate),
166 activation_client_(NULL), 167 activation_client_(NULL),
167 #if defined(OS_CHROMEOS) && defined(USE_X11) 168 #if defined(OS_CHROMEOS) && defined(USE_X11)
168 output_configurator_(new chromeos::OutputConfigurator()), 169 output_configurator_(new chromeos::OutputConfigurator()),
169 #endif // defined(OS_CHROMEOS) 170 #endif // defined(OS_CHROMEOS)
170 native_cursor_manager_(new AshNativeCursorManager), 171 native_cursor_manager_(new AshNativeCursorManager),
171 cursor_manager_(scoped_ptr<views::corewm::NativeCursorManager>( 172 cursor_manager_(scoped_ptr<views::corewm::NativeCursorManager>(
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 392 }
392 return containers; 393 return containers;
393 } 394 }
394 395
395 // static 396 // static
396 bool Shell::IsForcedMaximizeMode() { 397 bool Shell::IsForcedMaximizeMode() {
397 CommandLine* command_line = CommandLine::ForCurrentProcess(); 398 CommandLine* command_line = CommandLine::ForCurrentProcess();
398 return command_line->HasSwitch(switches::kForcedMaximizeMode); 399 return command_line->HasSwitch(switches::kForcedMaximizeMode);
399 } 400 }
400 401
401 void Shell::Init() { 402 void Shell::Init() {
varkha 2013/10/04 01:54:07 Should go down in private: section.
bshe 2013/10/04 03:04:39 Done.
402 CommandLine* command_line = CommandLine::ForCurrentProcess(); 403 CommandLine* command_line = CommandLine::ForCurrentProcess();
403 404
404 delegate_->PreInit(); 405 delegate_->PreInit();
405 bool display_initialized = false; 406 bool display_initialized = false;
406 #if defined(OS_CHROMEOS) && defined(USE_X11) 407 #if defined(OS_CHROMEOS) && defined(USE_X11)
407 output_configurator_animation_.reset( 408 output_configurator_animation_.reset(
408 new internal::OutputConfiguratorAnimation()); 409 new internal::OutputConfiguratorAnimation());
409 output_configurator_->AddObserver(output_configurator_animation_.get()); 410 output_configurator_->AddObserver(output_configurator_animation_.get());
410 if (base::SysInfo::IsRunningOnChromeOS()) { 411 if (base::SysInfo::IsRunningOnChromeOS()) {
411 display_change_observer_.reset(new internal::DisplayChangeObserver); 412 display_change_observer_.reset(new internal::DisplayChangeObserver);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 if (keyboard_controller_.get()) {
884 RootWindowControllerList controllers = GetAllRootWindowControllers();
885 for (RootWindowControllerList::iterator iter = controllers.begin();
886 iter != controllers.end(); ++iter) {
varkha 2013/10/04 01:54:07 nit: align with RootWindowControllerList above.
bshe 2013/10/04 03:04:39 Done.
887 (*iter)->DisableKeyboard(keyboard_controller_.get());
varkha 2013/10/04 01:54:07 Can there be a situation when you are disabling ke
bshe 2013/10/04 03:04:39 We reset the keyboard controller before we enable
888 }
889 }
890 keyboard::KeyboardControllerProxy* proxy =
891 delegate_->CreateKeyboardControllerProxy();
892 keyboard_controller_.reset(
893 new keyboard::KeyboardController(proxy));
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698