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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #include "ash/wm/window_properties.h" | 64 #include "ash/wm/window_properties.h" |
65 #include "ash/wm/workspace/workspace_event_filter.h" | 65 #include "ash/wm/workspace/workspace_event_filter.h" |
66 #include "ash/wm/workspace/workspace_layout_manager.h" | 66 #include "ash/wm/workspace/workspace_layout_manager.h" |
67 #include "ash/wm/workspace/workspace_manager.h" | 67 #include "ash/wm/workspace/workspace_manager.h" |
68 #include "ash/wm/workspace_controller.h" | 68 #include "ash/wm/workspace_controller.h" |
69 #include "base/bind.h" | 69 #include "base/bind.h" |
70 #include "base/command_line.h" | 70 #include "base/command_line.h" |
71 #include "grit/ui_resources.h" | 71 #include "grit/ui_resources.h" |
72 #include "ui/aura/client/aura_constants.h" | 72 #include "ui/aura/client/aura_constants.h" |
73 #include "ui/aura/client/user_action_client.h" | 73 #include "ui/aura/client/user_action_client.h" |
74 #include "ui/aura/cursor_manager.h" | |
75 #include "ui/aura/env.h" | 74 #include "ui/aura/env.h" |
76 #include "ui/aura/focus_manager.h" | 75 #include "ui/aura/focus_manager.h" |
77 #include "ui/aura/layout_manager.h" | 76 #include "ui/aura/layout_manager.h" |
78 #include "ui/aura/display_manager.h" | 77 #include "ui/aura/display_manager.h" |
79 #include "ui/aura/root_window.h" | 78 #include "ui/aura/root_window.h" |
80 #include "ui/aura/shared/compound_event_filter.h" | 79 #include "ui/aura/shared/compound_event_filter.h" |
81 #include "ui/aura/shared/input_method_event_filter.h" | 80 #include "ui/aura/shared/input_method_event_filter.h" |
82 #include "ui/aura/ui_controls_aura.h" | 81 #include "ui/aura/ui_controls_aura.h" |
83 #include "ui/aura/window.h" | 82 #include "ui/aura/window.h" |
84 #include "ui/compositor/layer.h" | 83 #include "ui/compositor/layer.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 197 |
199 Shell::~Shell() { | 198 Shell::~Shell() { |
200 views::FocusManagerFactory::Install(NULL); | 199 views::FocusManagerFactory::Install(NULL); |
201 | 200 |
202 // Remove the focus from any window. This will prevent overhead and side | 201 // Remove the focus from any window. This will prevent overhead and side |
203 // effects (e.g. crashes) from changing focus during shutdown. | 202 // effects (e.g. crashes) from changing focus during shutdown. |
204 // See bug crbug.com/134502. | 203 // See bug crbug.com/134502. |
205 if (active_root_window_) | 204 if (active_root_window_) |
206 active_root_window_->GetFocusManager()->SetFocusedWindow(NULL, NULL); | 205 active_root_window_->GetFocusManager()->SetFocusedWindow(NULL, NULL); |
207 | 206 |
208 aura::Env::GetInstance()->cursor_manager()->set_delegate(NULL); | 207 cursor_manager_.set_delegate(NULL); |
209 | 208 |
210 // Please keep in same order as in Init() because it's easy to miss one. | 209 // Please keep in same order as in Init() because it's easy to miss one. |
211 RemoveEnvEventFilter(user_activity_detector_.get()); | 210 RemoveEnvEventFilter(user_activity_detector_.get()); |
212 RemoveEnvEventFilter(event_rewriter_filter_.get()); | 211 RemoveEnvEventFilter(event_rewriter_filter_.get()); |
213 RemoveEnvEventFilter(partial_screenshot_filter_.get()); | 212 RemoveEnvEventFilter(partial_screenshot_filter_.get()); |
214 RemoveEnvEventFilter(input_method_filter_.get()); | 213 RemoveEnvEventFilter(input_method_filter_.get()); |
215 RemoveEnvEventFilter(window_modality_controller_.get()); | 214 RemoveEnvEventFilter(window_modality_controller_.get()); |
216 if (mouse_cursor_filter_.get()) | 215 if (mouse_cursor_filter_.get()) |
217 RemoveEnvEventFilter(mouse_cursor_filter_.get()); | 216 RemoveEnvEventFilter(mouse_cursor_filter_.get()); |
218 RemoveEnvEventFilter(system_gesture_filter_.get()); | 217 RemoveEnvEventFilter(system_gesture_filter_.get()); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 363 |
365 void Shell::Init() { | 364 void Shell::Init() { |
366 // Install the custom factory first so that views::FocusManagers for Tray, | 365 // Install the custom factory first so that views::FocusManagers for Tray, |
367 // Launcher, and WallPaper could be created by the factory. | 366 // Launcher, and WallPaper could be created by the factory. |
368 views::FocusManagerFactory::Install(new AshFocusManagerFactory); | 367 views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
369 | 368 |
370 env_filter_ = new aura::shared::CompoundEventFilter; | 369 env_filter_ = new aura::shared::CompoundEventFilter; |
371 // Pass ownership of the filter to the Env. | 370 // Pass ownership of the filter to the Env. |
372 aura::Env::GetInstance()->SetEventFilter(env_filter_); | 371 aura::Env::GetInstance()->SetEventFilter(env_filter_); |
373 | 372 |
374 aura::Env::GetInstance()->cursor_manager()->set_delegate(this); | 373 cursor_manager_.set_delegate(this); |
375 | |
376 | 374 |
377 focus_manager_.reset(new aura::FocusManager); | 375 focus_manager_.reset(new aura::FocusManager); |
378 activation_controller_.reset( | 376 activation_controller_.reset( |
379 new internal::ActivationController(focus_manager_.get())); | 377 new internal::ActivationController(focus_manager_.get())); |
380 | 378 |
381 screen_position_controller_.reset(new internal::ScreenPositionController); | 379 screen_position_controller_.reset(new internal::ScreenPositionController); |
382 display_controller_.reset(new internal::DisplayController); | 380 display_controller_.reset(new internal::DisplayController); |
383 display_controller_->InitPrimaryDisplay(); | 381 display_controller_->InitPrimaryDisplay(); |
384 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); | 382 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); |
385 active_root_window_ = root_window; | 383 active_root_window_ = root_window; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 // It needs to be created after OnWindowResized has been called, otherwise the | 491 // It needs to be created after OnWindowResized has been called, otherwise the |
494 // widget will not paint when restoring after a browser crash. | 492 // widget will not paint when restoring after a browser crash. |
495 user_wallpaper_delegate_->InitializeWallpaper(); | 493 user_wallpaper_delegate_->InitializeWallpaper(); |
496 | 494 |
497 power_button_controller_.reset(new PowerButtonController); | 495 power_button_controller_.reset(new PowerButtonController); |
498 AddShellObserver(power_button_controller_.get()); | 496 AddShellObserver(power_button_controller_.get()); |
499 | 497 |
500 display_controller_->InitSecondaryDisplays(); | 498 display_controller_->InitSecondaryDisplays(); |
501 | 499 |
502 if (initially_hide_cursor_) | 500 if (initially_hide_cursor_) |
503 aura::Env::GetInstance()->cursor_manager()->ShowCursor(false); | 501 cursor_manager_.ShowCursor(false); |
504 } | 502 } |
505 | 503 |
506 void Shell::AddEnvEventFilter(aura::EventFilter* filter) { | 504 void Shell::AddEnvEventFilter(aura::EventFilter* filter) { |
507 env_filter_->AddFilter(filter); | 505 env_filter_->AddFilter(filter); |
508 } | 506 } |
509 | 507 |
510 void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { | 508 void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { |
511 env_filter_->RemoveFilter(filter); | 509 env_filter_->RemoveFilter(filter); |
512 } | 510 } |
513 | 511 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 DCHECK(capture_controller_.get()); | 701 DCHECK(capture_controller_.get()); |
704 | 702 |
705 root_window->set_focus_manager(focus_manager_.get()); | 703 root_window->set_focus_manager(focus_manager_.get()); |
706 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); | 704 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); |
707 aura::client::SetActivationClient(root_window, activation_controller_.get()); | 705 aura::client::SetActivationClient(root_window, activation_controller_.get()); |
708 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); | 706 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
709 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); | 707 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
710 aura::client::SetCaptureClient(root_window, capture_controller_.get()); | 708 aura::client::SetCaptureClient(root_window, capture_controller_.get()); |
711 aura::client::SetScreenPositionClient(root_window, | 709 aura::client::SetScreenPositionClient(root_window, |
712 screen_position_controller_.get()); | 710 screen_position_controller_.get()); |
| 711 aura::client::SetCursorClient(root_window, &cursor_manager_); |
713 | 712 |
714 if (nested_dispatcher_controller_.get()) { | 713 if (nested_dispatcher_controller_.get()) { |
715 aura::client::SetDispatcherClient(root_window, | 714 aura::client::SetDispatcherClient(root_window, |
716 nested_dispatcher_controller_.get()); | 715 nested_dispatcher_controller_.get()); |
717 } | 716 } |
718 if (user_action_client_.get()) | 717 if (user_action_client_.get()) |
719 aura::client::SetUserActionClient(root_window, user_action_client_.get()); | 718 aura::client::SetUserActionClient(root_window, user_action_client_.get()); |
720 | 719 |
721 root_window->SetCursor(ui::kCursorPointer); | 720 root_window->SetCursor(ui::kCursorPointer); |
722 controller->InitLayoutManagers(); | 721 controller->InitLayoutManagers(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 } | 783 } |
785 | 784 |
786 void Shell::ShowCursor(bool visible) { | 785 void Shell::ShowCursor(bool visible) { |
787 RootWindowList root_windows = GetAllRootWindows(); | 786 RootWindowList root_windows = GetAllRootWindows(); |
788 for (RootWindowList::iterator iter = root_windows.begin(); | 787 for (RootWindowList::iterator iter = root_windows.begin(); |
789 iter != root_windows.end(); ++iter) | 788 iter != root_windows.end(); ++iter) |
790 (*iter)->ShowCursor(visible); | 789 (*iter)->ShowCursor(visible); |
791 } | 790 } |
792 | 791 |
793 } // namespace ash | 792 } // namespace ash |
OLD | NEW |