Chromium Code Reviews| 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 keyboard_container->SetBounds(parent->bounds()); | |
|
oshima
2013/10/04 16:50:17
won't RootWindowLayoutManager handle this?
bshe
2013/10/04 17:38:32
Sorry, just to confirm, do you mean the SetBounds
oshima
2013/10/04 17:51:35
I see. Maybe it's doing this way to avoid some iss
bshe
2013/10/04 18:05:52
Thanks! Added a TODO.
On 2013/10/04 17:51:35, osh
| |
| 550 } | |
| 534 | 551 |
| 535 keyboard::KeyboardControllerProxy* proxy = | 552 void RootWindowController::DeactivateKeyboard( |
| 536 Shell::GetInstance()->delegate()->CreateKeyboardControllerProxy(); | 553 keyboard::KeyboardController* keyboard_controller) { |
| 537 keyboard_controller_.reset( | 554 if (!keyboard::IsKeyboardEnabled()) |
| 538 new keyboard::KeyboardController(proxy)); | 555 return; |
| 539 | 556 |
| 540 keyboard_controller_->AddObserver(shelf()->shelf_layout_manager()); | 557 DCHECK(keyboard_controller); |
| 541 keyboard_controller_->AddObserver(panel_layout_manager_); | 558 aura::Window* keyboard_container = |
| 542 keyboard_controller_->AddObserver(docked_layout_manager_); | 559 keyboard_controller->GetContainerWindow(); |
| 543 | 560 if (keyboard_container->GetRootWindow() == root_window()) { |
| 544 // Deletes the old container since |keyboard_controller_| creates a | 561 root_window()->RemoveChild(keyboard_container); |
| 545 // new container window in GetContainerWindow(). | 562 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); |
| 546 delete GetContainer(kShellWindowId_VirtualKeyboardContainer); | 563 keyboard_controller->RemoveObserver(panel_layout_manager_); |
| 547 | 564 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 } | 565 } |
| 554 } | 566 } |
| 555 | 567 |
| 556 | 568 |
| 557 //////////////////////////////////////////////////////////////////////////////// | 569 //////////////////////////////////////////////////////////////////////////////// |
| 558 // RootWindowController, private: | 570 // RootWindowController, private: |
| 559 | 571 |
| 560 void RootWindowController::InitLayoutManagers() { | 572 void RootWindowController::InitLayoutManagers() { |
| 561 root_window_layout_ = | 573 root_window_layout_ = |
| 562 new RootWindowLayoutManager(root_window_.get()); | 574 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())); | 832 set_touch_hud_projection(new TouchHudProjection(root_window_.get())); |
| 821 } | 833 } |
| 822 | 834 |
| 823 void RootWindowController::DisableTouchHudProjection() { | 835 void RootWindowController::DisableTouchHudProjection() { |
| 824 if (!touch_hud_projection_) | 836 if (!touch_hud_projection_) |
| 825 return; | 837 return; |
| 826 touch_hud_projection_->Remove(); | 838 touch_hud_projection_->Remove(); |
| 827 } | 839 } |
| 828 | 840 |
| 829 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { | 841 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
| 830 if (status != user::LOGGED_IN_NONE) | |
| 831 InitKeyboard(); | |
| 832 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 842 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| 833 } | 843 } |
| 834 | 844 |
| 835 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { | 845 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
| 836 if (enabled) | 846 if (enabled) |
| 837 EnableTouchHudProjection(); | 847 EnableTouchHudProjection(); |
| 838 else | 848 else |
| 839 DisableTouchHudProjection(); | 849 DisableTouchHudProjection(); |
| 840 } | 850 } |
| 841 | 851 |
| 842 RootWindowController* GetRootWindowController( | 852 RootWindowController* GetRootWindowController( |
| 843 const aura::RootWindow* root_window) { | 853 const aura::RootWindow* root_window) { |
| 844 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 854 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
| 845 } | 855 } |
| 846 | 856 |
| 847 } // namespace internal | 857 } // namespace internal |
| 848 } // namespace ash | 858 } // namespace ash |
| OLD | NEW |