| 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 const aura::Window* RootWindowController::GetContainer(int container_id) const { | 324 const aura::Window* RootWindowController::GetContainer(int container_id) const { |
| 325 return root_window_->GetChildById(container_id); | 325 return root_window_->GetChildById(container_id); |
| 326 } | 326 } |
| 327 | 327 |
| 328 void RootWindowController::Init(bool first_run_after_boot) { | 328 void RootWindowController::Init(bool first_run_after_boot) { |
| 329 root_window_->SetCursor(ui::kCursorPointer); | 329 root_window_->SetCursor(ui::kCursorPointer); |
| 330 CreateContainersInRootWindow(root_window_.get()); | 330 CreateContainersInRootWindow(root_window_.get()); |
| 331 CreateSystemBackground(first_run_after_boot); | 331 CreateSystemBackground(first_run_after_boot); |
| 332 | 332 |
| 333 InitLayoutManagers(); | 333 InitLayoutManagers(); |
| 334 InitKeyboard(); | |
| 335 InitTouchHuds(); | 334 InitTouchHuds(); |
| 336 | 335 |
| 337 if (Shell::GetPrimaryRootWindowController()-> | 336 if (Shell::GetPrimaryRootWindowController()-> |
| 338 GetSystemModalLayoutManager(NULL)->has_modal_background()) { | 337 GetSystemModalLayoutManager(NULL)->has_modal_background()) { |
| 339 GetSystemModalLayoutManager(NULL)->CreateModalBackground(); | 338 GetSystemModalLayoutManager(NULL)->CreateModalBackground(); |
| 340 } | 339 } |
| 341 | 340 |
| 342 Shell::GetInstance()->AddShellObserver(this); | 341 Shell::GetInstance()->AddShellObserver(this); |
| 343 } | 342 } |
| 344 | 343 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 // before move it to |kDesktopController|. | 399 // before move it to |kDesktopController|. |
| 401 DCHECK_EQ(controller->widget(), widget); | 400 DCHECK_EQ(controller->widget(), widget); |
| 402 // Release the old controller and close its background widget. | 401 // Release the old controller and close its background widget. |
| 403 SetWallpaperController(controller); | 402 SetWallpaperController(controller); |
| 404 } | 403 } |
| 405 } | 404 } |
| 406 | 405 |
| 407 void RootWindowController::CloseChildWindows() { | 406 void RootWindowController::CloseChildWindows() { |
| 408 mouse_event_target_.reset(); | 407 mouse_event_target_.reset(); |
| 409 | 408 |
| 409 // Deactivate keyboard container before closing child windows and shutting |
| 410 // down associated layout managers. |
| 411 DeactivateKeyboard(Shell::GetInstance()->keyboard_controller()); |
| 412 |
| 410 if (!shelf_.get()) | 413 if (!shelf_.get()) |
| 411 return; | 414 return; |
| 412 // panel_layout_manager_ needs to be shut down before windows are destroyed. | 415 // panel_layout_manager_ needs to be shut down before windows are destroyed. |
| 413 if (panel_layout_manager_) { | 416 if (panel_layout_manager_) { |
| 414 panel_layout_manager_->Shutdown(); | 417 panel_layout_manager_->Shutdown(); |
| 415 panel_layout_manager_ = NULL; | 418 panel_layout_manager_ = NULL; |
| 416 } | 419 } |
| 417 // docked_layout_manager_ needs to be shut down before windows are destroyed. | 420 // docked_layout_manager_ needs to be shut down before windows are destroyed. |
| 418 if (docked_layout_manager_) { | 421 if (docked_layout_manager_) { |
| 419 if (shelf_->shelf_layout_manager()) | 422 if (shelf_->shelf_layout_manager()) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 const aura::Window::Windows& windows = | 524 const aura::Window::Windows& windows = |
| 522 GetContainer(kShellWindowId_DefaultContainer)->children(); | 525 GetContainer(kShellWindowId_DefaultContainer)->children(); |
| 523 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); | 526 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); |
| 524 iter != windows.rend(); ++iter) { | 527 iter != windows.rend(); ++iter) { |
| 525 if (wm::GetWindowState(*iter)->IsFullscreen()) | 528 if (wm::GetWindowState(*iter)->IsFullscreen()) |
| 526 return *iter; | 529 return *iter; |
| 527 } | 530 } |
| 528 return NULL; | 531 return NULL; |
| 529 } | 532 } |
| 530 | 533 |
| 531 void RootWindowController::InitKeyboard() { | 534 void RootWindowController::ActivateKeyboard( |
| 532 if (keyboard::IsKeyboardEnabled()) { | 535 keyboard::KeyboardController* keyboard_controller) { |
| 533 aura::Window* parent = root_window(); | 536 if (!keyboard::IsKeyboardEnabled() || |
| 537 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { |
| 538 return; |
| 539 } |
| 540 DCHECK(keyboard_controller); |
| 541 keyboard_controller->AddObserver(shelf()->shelf_layout_manager()); |
| 542 keyboard_controller->AddObserver(panel_layout_manager_); |
| 543 keyboard_controller->AddObserver(docked_layout_manager_); |
| 544 aura::Window* parent = root_window(); |
| 545 aura::Window* keyboard_container = |
| 546 keyboard_controller->GetContainerWindow(); |
| 547 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); |
| 548 parent->AddChild(keyboard_container); |
| 549 // TODO(oshima): Bounds of keyboard container should be handled by |
| 550 // RootWindowLayoutManager. Remove this after fixed RootWindowLayoutManager. |
| 551 keyboard_container->SetBounds(parent->bounds()); |
| 552 } |
| 534 | 553 |
| 535 keyboard::KeyboardControllerProxy* proxy = | 554 void RootWindowController::DeactivateKeyboard( |
| 536 Shell::GetInstance()->delegate()->CreateKeyboardControllerProxy(); | 555 keyboard::KeyboardController* keyboard_controller) { |
| 537 keyboard_controller_.reset( | 556 if (!keyboard::IsKeyboardEnabled()) |
| 538 new keyboard::KeyboardController(proxy)); | 557 return; |
| 539 | 558 |
| 540 keyboard_controller_->AddObserver(shelf()->shelf_layout_manager()); | 559 DCHECK(keyboard_controller); |
| 541 keyboard_controller_->AddObserver(panel_layout_manager_); | 560 aura::Window* keyboard_container = |
| 542 keyboard_controller_->AddObserver(docked_layout_manager_); | 561 keyboard_controller->GetContainerWindow(); |
| 543 | 562 if (keyboard_container->GetRootWindow() == root_window()) { |
| 544 // Deletes the old container since |keyboard_controller_| creates a | 563 root_window()->RemoveChild(keyboard_container); |
| 545 // new container window in GetContainerWindow(). | 564 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); |
| 546 delete GetContainer(kShellWindowId_VirtualKeyboardContainer); | 565 keyboard_controller->RemoveObserver(panel_layout_manager_); |
| 547 | 566 keyboard_controller->RemoveObserver(docked_layout_manager_); |
| 548 aura::Window* keyboard_container = | |
| 549 keyboard_controller_->GetContainerWindow(); | |
| 550 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); | |
| 551 parent->AddChild(keyboard_container); | |
| 552 keyboard_container->SetBounds(parent->bounds()); | |
| 553 } | 567 } |
| 554 } | 568 } |
| 555 | 569 |
| 556 | 570 |
| 557 //////////////////////////////////////////////////////////////////////////////// | 571 //////////////////////////////////////////////////////////////////////////////// |
| 558 // RootWindowController, private: | 572 // RootWindowController, private: |
| 559 | 573 |
| 560 void RootWindowController::InitLayoutManagers() { | 574 void RootWindowController::InitLayoutManagers() { |
| 561 root_window_layout_ = | 575 root_window_layout_ = |
| 562 new RootWindowLayoutManager(root_window_.get()); | 576 new RootWindowLayoutManager(root_window_.get()); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 set_touch_hud_projection(new TouchHudProjection(root_window_.get())); | 834 set_touch_hud_projection(new TouchHudProjection(root_window_.get())); |
| 821 } | 835 } |
| 822 | 836 |
| 823 void RootWindowController::DisableTouchHudProjection() { | 837 void RootWindowController::DisableTouchHudProjection() { |
| 824 if (!touch_hud_projection_) | 838 if (!touch_hud_projection_) |
| 825 return; | 839 return; |
| 826 touch_hud_projection_->Remove(); | 840 touch_hud_projection_->Remove(); |
| 827 } | 841 } |
| 828 | 842 |
| 829 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { | 843 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
| 830 if (status != user::LOGGED_IN_NONE) | |
| 831 InitKeyboard(); | |
| 832 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 844 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| 833 } | 845 } |
| 834 | 846 |
| 835 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { | 847 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
| 836 if (enabled) | 848 if (enabled) |
| 837 EnableTouchHudProjection(); | 849 EnableTouchHudProjection(); |
| 838 else | 850 else |
| 839 DisableTouchHudProjection(); | 851 DisableTouchHudProjection(); |
| 840 } | 852 } |
| 841 | 853 |
| 842 RootWindowController* GetRootWindowController( | 854 RootWindowController* GetRootWindowController( |
| 843 const aura::RootWindow* root_window) { | 855 const aura::RootWindow* root_window) { |
| 844 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 856 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
| 845 } | 857 } |
| 846 | 858 |
| 847 } // namespace internal | 859 } // namespace internal |
| 848 } // namespace ash | 860 } // namespace ash |
| OLD | NEW |