| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #include "ash/wm/window_util.h" | 62 #include "ash/wm/window_util.h" |
| 63 #include "ash/wm/workspace/workspace_event_filter.h" | 63 #include "ash/wm/workspace/workspace_event_filter.h" |
| 64 #include "ash/wm/workspace/workspace_layout_manager.h" | 64 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 65 #include "ash/wm/workspace/workspace_manager.h" | 65 #include "ash/wm/workspace/workspace_manager.h" |
| 66 #include "ash/wm/workspace_controller.h" | 66 #include "ash/wm/workspace_controller.h" |
| 67 #include "base/bind.h" | 67 #include "base/bind.h" |
| 68 #include "base/command_line.h" | 68 #include "base/command_line.h" |
| 69 #include "grit/ui_resources.h" | 69 #include "grit/ui_resources.h" |
| 70 #include "ui/aura/client/aura_constants.h" | 70 #include "ui/aura/client/aura_constants.h" |
| 71 #include "ui/aura/client/user_action_client.h" | 71 #include "ui/aura/client/user_action_client.h" |
| 72 #include "ui/aura/cursor_manager.h" | |
| 73 #include "ui/aura/env.h" | 72 #include "ui/aura/env.h" |
| 74 #include "ui/aura/focus_manager.h" | 73 #include "ui/aura/focus_manager.h" |
| 75 #include "ui/aura/layout_manager.h" | 74 #include "ui/aura/layout_manager.h" |
| 76 #include "ui/aura/display_manager.h" | 75 #include "ui/aura/display_manager.h" |
| 77 #include "ui/aura/root_window.h" | 76 #include "ui/aura/root_window.h" |
| 78 #include "ui/aura/shared/compound_event_filter.h" | 77 #include "ui/aura/shared/compound_event_filter.h" |
| 79 #include "ui/aura/shared/input_method_event_filter.h" | 78 #include "ui/aura/shared/input_method_event_filter.h" |
| 80 #include "ui/aura/ui_controls_aura.h" | 79 #include "ui/aura/ui_controls_aura.h" |
| 81 #include "ui/aura/window.h" | 80 #include "ui/aura/window.h" |
| 82 #include "ui/compositor/layer.h" | 81 #include "ui/compositor/layer.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 191 |
| 193 Shell::~Shell() { | 192 Shell::~Shell() { |
| 194 views::FocusManagerFactory::Install(NULL); | 193 views::FocusManagerFactory::Install(NULL); |
| 195 | 194 |
| 196 // Remove the focus from any window. This will prevent overhead and side | 195 // Remove the focus from any window. This will prevent overhead and side |
| 197 // effects (e.g. crashes) from changing focus during shutdown. | 196 // effects (e.g. crashes) from changing focus during shutdown. |
| 198 // See bug crbug.com/134502. | 197 // See bug crbug.com/134502. |
| 199 if (active_root_window_) | 198 if (active_root_window_) |
| 200 active_root_window_->GetFocusManager()->SetFocusedWindow(NULL, NULL); | 199 active_root_window_->GetFocusManager()->SetFocusedWindow(NULL, NULL); |
| 201 | 200 |
| 202 aura::Env::GetInstance()->cursor_manager()->set_delegate(NULL); | 201 cursor_manager_.set_delegate(NULL); |
| 203 | 202 |
| 204 // Please keep in same order as in Init() because it's easy to miss one. | 203 // Please keep in same order as in Init() because it's easy to miss one. |
| 205 RemoveEnvEventFilter(user_activity_detector_.get()); | 204 RemoveEnvEventFilter(user_activity_detector_.get()); |
| 206 RemoveEnvEventFilter(key_rewriter_filter_.get()); | 205 RemoveEnvEventFilter(key_rewriter_filter_.get()); |
| 207 RemoveEnvEventFilter(partial_screenshot_filter_.get()); | 206 RemoveEnvEventFilter(partial_screenshot_filter_.get()); |
| 208 RemoveEnvEventFilter(input_method_filter_.get()); | 207 RemoveEnvEventFilter(input_method_filter_.get()); |
| 209 RemoveEnvEventFilter(window_modality_controller_.get()); | 208 RemoveEnvEventFilter(window_modality_controller_.get()); |
| 210 if (mouse_cursor_filter_.get()) | 209 if (mouse_cursor_filter_.get()) |
| 211 RemoveEnvEventFilter(mouse_cursor_filter_.get()); | 210 RemoveEnvEventFilter(mouse_cursor_filter_.get()); |
| 212 RemoveEnvEventFilter(system_gesture_filter_.get()); | 211 RemoveEnvEventFilter(system_gesture_filter_.get()); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 357 |
| 359 void Shell::Init() { | 358 void Shell::Init() { |
| 360 // Install the custom factory first so that views::FocusManagers for Tray, | 359 // Install the custom factory first so that views::FocusManagers for Tray, |
| 361 // Launcher, and WallPaper could be created by the factory. | 360 // Launcher, and WallPaper could be created by the factory. |
| 362 views::FocusManagerFactory::Install(new AshFocusManagerFactory); | 361 views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
| 363 | 362 |
| 364 env_filter_ = new aura::shared::CompoundEventFilter; | 363 env_filter_ = new aura::shared::CompoundEventFilter; |
| 365 // Pass ownership of the filter to the Env. | 364 // Pass ownership of the filter to the Env. |
| 366 aura::Env::GetInstance()->SetEventFilter(env_filter_); | 365 aura::Env::GetInstance()->SetEventFilter(env_filter_); |
| 367 | 366 |
| 368 aura::Env::GetInstance()->cursor_manager()->set_delegate(this); | 367 cursor_manager_.set_delegate(this); |
| 369 | |
| 370 | 368 |
| 371 focus_manager_.reset(new aura::FocusManager); | 369 focus_manager_.reset(new aura::FocusManager); |
| 372 activation_controller_.reset( | 370 activation_controller_.reset( |
| 373 new internal::ActivationController(focus_manager_.get())); | 371 new internal::ActivationController(focus_manager_.get())); |
| 374 | 372 |
| 375 display_controller_.reset(new internal::DisplayController); | 373 display_controller_.reset(new internal::DisplayController); |
| 376 display_controller_->InitPrimaryDisplay(); | 374 display_controller_->InitPrimaryDisplay(); |
| 377 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); | 375 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); |
| 378 active_root_window_ = root_window; | 376 active_root_window_ = root_window; |
| 379 | 377 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 // It needs to be created after OnWindowResized has been called, otherwise the | 487 // It needs to be created after OnWindowResized has been called, otherwise the |
| 490 // widget will not paint when restoring after a browser crash. | 488 // widget will not paint when restoring after a browser crash. |
| 491 user_wallpaper_delegate_->InitializeWallpaper(); | 489 user_wallpaper_delegate_->InitializeWallpaper(); |
| 492 | 490 |
| 493 power_button_controller_.reset(new PowerButtonController); | 491 power_button_controller_.reset(new PowerButtonController); |
| 494 AddShellObserver(power_button_controller_.get()); | 492 AddShellObserver(power_button_controller_.get()); |
| 495 | 493 |
| 496 display_controller_->InitSecondaryDisplays(); | 494 display_controller_->InitSecondaryDisplays(); |
| 497 | 495 |
| 498 if (initially_hide_cursor_) | 496 if (initially_hide_cursor_) |
| 499 aura::Env::GetInstance()->cursor_manager()->ShowCursor(false); | 497 cursor_manager_.ShowCursor(false); |
| 500 } | 498 } |
| 501 | 499 |
| 502 void Shell::AddEnvEventFilter(aura::EventFilter* filter) { | 500 void Shell::AddEnvEventFilter(aura::EventFilter* filter) { |
| 503 env_filter_->AddFilter(filter); | 501 env_filter_->AddFilter(filter); |
| 504 } | 502 } |
| 505 | 503 |
| 506 void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { | 504 void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { |
| 507 env_filter_->RemoveFilter(filter); | 505 env_filter_->RemoveFilter(filter); |
| 508 } | 506 } |
| 509 | 507 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 DCHECK(visibility_controller_.get()); | 686 DCHECK(visibility_controller_.get()); |
| 689 DCHECK(drag_drop_controller_.get()); | 687 DCHECK(drag_drop_controller_.get()); |
| 690 DCHECK(capture_controller_.get()); | 688 DCHECK(capture_controller_.get()); |
| 691 | 689 |
| 692 root_window->set_focus_manager(focus_manager_.get()); | 690 root_window->set_focus_manager(focus_manager_.get()); |
| 693 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); | 691 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); |
| 694 aura::client::SetActivationClient(root_window, activation_controller_.get()); | 692 aura::client::SetActivationClient(root_window, activation_controller_.get()); |
| 695 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); | 693 aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
| 696 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); | 694 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
| 697 aura::client::SetCaptureClient(root_window, capture_controller_.get()); | 695 aura::client::SetCaptureClient(root_window, capture_controller_.get()); |
| 696 aura::client::SetCursorClient(root_window, &cursor_manager_); |
| 698 | 697 |
| 699 if (nested_dispatcher_controller_.get()) { | 698 if (nested_dispatcher_controller_.get()) { |
| 700 aura::client::SetDispatcherClient(root_window, | 699 aura::client::SetDispatcherClient(root_window, |
| 701 nested_dispatcher_controller_.get()); | 700 nested_dispatcher_controller_.get()); |
| 702 } | 701 } |
| 703 if (user_action_client_.get()) | 702 if (user_action_client_.get()) |
| 704 aura::client::SetUserActionClient(root_window, user_action_client_.get()); | 703 aura::client::SetUserActionClient(root_window, user_action_client_.get()); |
| 705 | 704 |
| 706 root_window->SetCursor(ui::kCursorPointer); | 705 root_window->SetCursor(ui::kCursorPointer); |
| 707 controller->InitLayoutManagers(); | 706 controller->InitLayoutManagers(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 } | 761 } |
| 763 | 762 |
| 764 void Shell::ShowCursor(bool visible) { | 763 void Shell::ShowCursor(bool visible) { |
| 765 RootWindowList root_windows = GetAllRootWindows(); | 764 RootWindowList root_windows = GetAllRootWindows(); |
| 766 for (RootWindowList::iterator iter = root_windows.begin(); | 765 for (RootWindowList::iterator iter = root_windows.begin(); |
| 767 iter != root_windows.end(); ++iter) | 766 iter != root_windows.end(); ++iter) |
| 768 (*iter)->ShowCursor(visible); | 767 (*iter)->ShowCursor(visible); |
| 769 } | 768 } |
| 770 | 769 |
| 771 } // namespace ash | 770 } // namespace ash |
| OLD | NEW |