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 // Disable keyboard container before close child windows and shutdown | |
|
varkha
2013/10/04 01:54:07
nit: s/close/closing, s/shutdown/shutting down.
bshe
2013/10/04 03:04:39
Done.
| |
| 410 // associated layout managers. | |
| 411 DisableKeyboard(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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 const aura::Window::Windows& windows = | 515 const aura::Window::Windows& windows = |
| 513 GetContainer(kShellWindowId_DefaultContainer)->children(); | 516 GetContainer(kShellWindowId_DefaultContainer)->children(); |
| 514 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); | 517 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); |
| 515 iter != windows.rend(); ++iter) { | 518 iter != windows.rend(); ++iter) { |
| 516 if (wm::GetWindowState(*iter)->IsFullscreen()) | 519 if (wm::GetWindowState(*iter)->IsFullscreen()) |
| 517 return *iter; | 520 return *iter; |
| 518 } | 521 } |
| 519 return NULL; | 522 return NULL; |
| 520 } | 523 } |
| 521 | 524 |
| 522 void RootWindowController::InitKeyboard() { | 525 void RootWindowController::EnableKeyboard( |
|
varkha
2013/10/04 01:54:07
If I understand it right, "enabled" in keyboard::I
bshe
2013/10/04 03:04:39
Done.
| |
| 523 if (keyboard::IsKeyboardEnabled()) { | 526 keyboard::KeyboardController* keyboard_controller) { |
| 527 if (keyboard::IsKeyboardEnabled() && | |
| 528 !GetContainer(kShellWindowId_VirtualKeyboardContainer)) { | |
|
varkha
2013/10/04 01:54:07
Could reverse the condition and return early.
bshe
2013/10/04 03:04:39
Done.
| |
| 529 DCHECK(keyboard_controller); | |
| 530 keyboard_controller->AddObserver(shelf()->shelf_layout_manager()); | |
| 531 keyboard_controller->AddObserver(panel_layout_manager_); | |
|
varkha
2013/10/04 01:54:07
AddObserver(docked_layout_manager_)
bshe
2013/10/04 03:04:39
Added in patchset 7 after rebase.
On 2013/10/04 0
| |
| 524 aura::Window* parent = root_window(); | 532 aura::Window* parent = root_window(); |
| 525 | |
| 526 keyboard::KeyboardControllerProxy* proxy = | |
| 527 Shell::GetInstance()->delegate()->CreateKeyboardControllerProxy(); | |
| 528 keyboard_controller_.reset( | |
| 529 new keyboard::KeyboardController(proxy)); | |
| 530 | |
| 531 keyboard_controller_->AddObserver(shelf()->shelf_layout_manager()); | |
| 532 keyboard_controller_->AddObserver(panel_layout_manager_); | |
| 533 | |
| 534 aura::Window* keyboard_container = | 533 aura::Window* keyboard_container = |
| 535 keyboard_controller_->GetContainerWindow(); | 534 keyboard_controller->GetContainerWindow(); |
| 536 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); | 535 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); |
| 537 parent->AddChild(keyboard_container); | 536 parent->AddChild(keyboard_container); |
| 538 keyboard_container->SetBounds(parent->bounds()); | 537 keyboard_container->SetBounds(parent->bounds()); |
| 539 } | 538 } |
| 540 } | 539 } |
| 541 | 540 |
| 541 void RootWindowController::DisableKeyboard( | |
| 542 keyboard::KeyboardController* keyboard_controller) { | |
| 543 if (keyboard::IsKeyboardEnabled()) { | |
|
varkha
2013/10/04 01:54:07
Favor early return.
bshe
2013/10/04 03:04:39
Done.
| |
| 544 DCHECK(keyboard_controller); | |
| 545 aura::Window* keyboard_container = | |
| 546 keyboard_controller->GetContainerWindow(); | |
| 547 if (keyboard_container->GetRootWindow() == root_window()) { | |
| 548 root_window()->RemoveChild(keyboard_container); | |
| 549 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); | |
| 550 keyboard_controller->RemoveObserver(panel_layout_manager_); | |
|
varkha
2013/10/04 01:54:07
RemoveObserver(docked_layout_manager_)
bshe
2013/10/04 03:04:39
Removed in patchset 7 after rebase
On 2013/10/04 0
| |
| 551 } | |
| 552 } | |
| 553 } | |
| 554 | |
| 542 | 555 |
| 543 //////////////////////////////////////////////////////////////////////////////// | 556 //////////////////////////////////////////////////////////////////////////////// |
| 544 // RootWindowController, private: | 557 // RootWindowController, private: |
| 545 | 558 |
| 546 void RootWindowController::InitLayoutManagers() { | 559 void RootWindowController::InitLayoutManagers() { |
| 547 root_window_layout_ = | 560 root_window_layout_ = |
| 548 new RootWindowLayoutManager(root_window_.get()); | 561 new RootWindowLayoutManager(root_window_.get()); |
| 549 root_window_->SetLayoutManager(root_window_layout_); | 562 root_window_->SetLayoutManager(root_window_layout_); |
| 550 | 563 |
| 551 aura::Window* default_container = | 564 aura::Window* default_container = |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 805 set_touch_hud_projection(new TouchHudProjection(root_window_.get())); | 818 set_touch_hud_projection(new TouchHudProjection(root_window_.get())); |
| 806 } | 819 } |
| 807 | 820 |
| 808 void RootWindowController::DisableTouchHudProjection() { | 821 void RootWindowController::DisableTouchHudProjection() { |
| 809 if (!touch_hud_projection_) | 822 if (!touch_hud_projection_) |
| 810 return; | 823 return; |
| 811 touch_hud_projection_->Remove(); | 824 touch_hud_projection_->Remove(); |
| 812 } | 825 } |
| 813 | 826 |
| 814 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { | 827 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
| 815 if (status != user::LOGGED_IN_NONE) | |
| 816 InitKeyboard(); | |
| 817 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 828 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| 818 } | 829 } |
| 819 | 830 |
| 820 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { | 831 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
| 821 if (enabled) | 832 if (enabled) |
| 822 EnableTouchHudProjection(); | 833 EnableTouchHudProjection(); |
| 823 else | 834 else |
| 824 DisableTouchHudProjection(); | 835 DisableTouchHudProjection(); |
| 825 } | 836 } |
| 826 | 837 |
| 827 RootWindowController* GetRootWindowController( | 838 RootWindowController* GetRootWindowController( |
| 828 const aura::RootWindow* root_window) { | 839 const aura::RootWindow* root_window) { |
| 829 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 840 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
| 830 } | 841 } |
| 831 | 842 |
| 832 } // namespace internal | 843 } // namespace internal |
| 833 } // namespace ash | 844 } // namespace ash |
| OLD | NEW |