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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 // It needs to be created after OnWindowResized has been called, otherwise the | 488 // It needs to be created after OnWindowResized has been called, otherwise the |
491 // widget will not paint when restoring after a browser crash. | 489 // widget will not paint when restoring after a browser crash. |
492 user_wallpaper_delegate_->InitializeWallpaper(); | 490 user_wallpaper_delegate_->InitializeWallpaper(); |
493 | 491 |
494 power_button_controller_.reset(new PowerButtonController); | 492 power_button_controller_.reset(new PowerButtonController); |
495 AddShellObserver(power_button_controller_.get()); | 493 AddShellObserver(power_button_controller_.get()); |
496 | 494 |
497 display_controller_->InitSecondaryDisplays(); | 495 display_controller_->InitSecondaryDisplays(); |
498 | 496 |
499 if (initially_hide_cursor_) | 497 if (initially_hide_cursor_) |
500 aura::Env::GetInstance()->cursor_manager()->ShowCursor(false); | 498 cursor_manager_.ShowCursor(false); |
501 } | 499 } |
502 | 500 |
503 void Shell::AddEnvEventFilter(aura::EventFilter* filter) { | 501 void Shell::AddEnvEventFilter(aura::EventFilter* filter) { |
504 env_filter_->AddFilter(filter); | 502 env_filter_->AddFilter(filter); |
505 } | 503 } |
506 | 504 |
507 void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { | 505 void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { |
508 env_filter_->RemoveFilter(filter); | 506 env_filter_->RemoveFilter(filter); |
509 } | 507 } |
510 | 508 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 DCHECK(capture_controller_.get()); | 698 DCHECK(capture_controller_.get()); |
701 | 699 |
702 root_window->set_focus_manager(focus_manager_.get()); | 700 root_window->set_focus_manager(focus_manager_.get()); |
703 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); | 701 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); |
704 aura::client::SetActivationClient(root_window, activation_controller_.get()); | 702 aura::client::SetActivationClient(root_window, activation_controller_.get()); |
705 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); | 703 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
706 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); | 704 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
707 aura::client::SetCaptureClient(root_window, capture_controller_.get()); | 705 aura::client::SetCaptureClient(root_window, capture_controller_.get()); |
708 aura::client::SetScreenPositionClient(root_window, | 706 aura::client::SetScreenPositionClient(root_window, |
709 screen_position_controller_.get()); | 707 screen_position_controller_.get()); |
| 708 aura::client::SetCursorClient(root_window, &cursor_manager_); |
710 aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); | 709 aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); |
711 | 710 |
712 if (nested_dispatcher_controller_.get()) { | 711 if (nested_dispatcher_controller_.get()) { |
713 aura::client::SetDispatcherClient(root_window, | 712 aura::client::SetDispatcherClient(root_window, |
714 nested_dispatcher_controller_.get()); | 713 nested_dispatcher_controller_.get()); |
715 } | 714 } |
716 if (user_action_client_.get()) | 715 if (user_action_client_.get()) |
717 aura::client::SetUserActionClient(root_window, user_action_client_.get()); | 716 aura::client::SetUserActionClient(root_window, user_action_client_.get()); |
718 | 717 |
719 root_window->SetCursor(ui::kCursorPointer); | 718 root_window->SetCursor(ui::kCursorPointer); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 } | 781 } |
783 | 782 |
784 void Shell::ShowCursor(bool visible) { | 783 void Shell::ShowCursor(bool visible) { |
785 RootWindowList root_windows = GetAllRootWindows(); | 784 RootWindowList root_windows = GetAllRootWindows(); |
786 for (RootWindowList::iterator iter = root_windows.begin(); | 785 for (RootWindowList::iterator iter = root_windows.begin(); |
787 iter != root_windows.end(); ++iter) | 786 iter != root_windows.end(); ++iter) |
788 (*iter)->ShowCursor(visible); | 787 (*iter)->ShowCursor(visible); |
789 } | 788 } |
790 | 789 |
791 } // namespace ash | 790 } // namespace ash |
OLD | NEW |