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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 void RootWindowController::CloseChildWindows() { | 396 void RootWindowController::CloseChildWindows() { |
397 mouse_event_target_.reset(); | 397 mouse_event_target_.reset(); |
398 | 398 |
399 // Deactivate keyboard container before closing child windows and shutting | 399 // Deactivate keyboard container before closing child windows and shutting |
400 // down associated layout managers. | 400 // down associated layout managers. |
401 DeactivateKeyboard(Shell::GetInstance()->keyboard_controller()); | 401 DeactivateKeyboard(Shell::GetInstance()->keyboard_controller()); |
402 | 402 |
403 if (!shelf_.get()) | |
404 return; | |
405 // panel_layout_manager_ needs to be shut down before windows are destroyed. | 403 // panel_layout_manager_ needs to be shut down before windows are destroyed. |
406 if (panel_layout_manager_) { | 404 if (panel_layout_manager_) { |
407 panel_layout_manager_->Shutdown(); | 405 panel_layout_manager_->Shutdown(); |
408 panel_layout_manager_ = NULL; | 406 panel_layout_manager_ = NULL; |
409 } | 407 } |
410 // docked_layout_manager_ needs to be shut down before windows are destroyed. | 408 // docked_layout_manager_ needs to be shut down before windows are destroyed. |
411 if (docked_layout_manager_) { | 409 if (shelf_ && docked_layout_manager_) { |
412 if (shelf_->shelf_layout_manager()) | 410 if (shelf_->shelf_layout_manager()) |
413 docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager()); | 411 docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager()); |
414 docked_layout_manager_->Shutdown(); | 412 docked_layout_manager_->Shutdown(); |
415 docked_layout_manager_ = NULL; | 413 docked_layout_manager_ = NULL; |
416 } | 414 } |
417 | 415 |
418 aura::client::SetDragDropClient(root_window_.get(), NULL); | 416 aura::client::SetDragDropClient(root_window_.get(), NULL); |
419 | 417 |
420 // TODO(harrym): Remove when Status Area Widget is a child view. | 418 // TODO(harrym): Remove when Status Area Widget is a child view. |
421 shelf_->ShutdownStatusAreaWidget(); | 419 if (shelf_) { |
420 shelf_->ShutdownStatusAreaWidget(); | |
422 | 421 |
423 if (shelf_->shelf_layout_manager()) | 422 if (shelf_->shelf_layout_manager()) |
424 shelf_->shelf_layout_manager()->PrepareForShutdown(); | 423 shelf_->shelf_layout_manager()->PrepareForShutdown(); |
424 } | |
oshima
2013/11/01 00:09:02
can you rebase?
bshe
2013/11/12 15:28:33
Done.
| |
425 | 425 |
426 // Close background widget first as it depends on tooltip. | 426 // Close background widget first as it depends on tooltip. |
427 wallpaper_controller_.reset(); | 427 wallpaper_controller_.reset(); |
428 animating_wallpaper_controller_.reset(); | 428 animating_wallpaper_controller_.reset(); |
429 | 429 |
430 workspace_controller_.reset(); | 430 workspace_controller_.reset(); |
431 aura::client::SetTooltipClient(root_window_.get(), NULL); | 431 aura::client::SetTooltipClient(root_window_.get(), NULL); |
432 | 432 |
433 // Explicitly destroy top level windows. We do this as during part of | 433 // Explicitly destroy top level windows. We do this as during part of |
434 // destruction such windows may query the RootWindow for state. | 434 // destruction such windows may query the RootWindow for state. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 return NULL; | 521 return NULL; |
522 } | 522 } |
523 | 523 |
524 void RootWindowController::ActivateKeyboard( | 524 void RootWindowController::ActivateKeyboard( |
525 keyboard::KeyboardController* keyboard_controller) { | 525 keyboard::KeyboardController* keyboard_controller) { |
526 if (!keyboard::IsKeyboardEnabled() || | 526 if (!keyboard::IsKeyboardEnabled() || |
527 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { | 527 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { |
528 return; | 528 return; |
529 } | 529 } |
530 DCHECK(keyboard_controller); | 530 DCHECK(keyboard_controller); |
531 keyboard_controller->AddObserver(shelf()->shelf_layout_manager()); | 531 if (!keyboard::IsKeyboardUsabilityTestEnabled()) { |
532 keyboard_controller->AddObserver(panel_layout_manager_); | 532 keyboard_controller->AddObserver(shelf()->shelf_layout_manager()); |
533 keyboard_controller->AddObserver(docked_layout_manager_); | 533 keyboard_controller->AddObserver(panel_layout_manager_); |
534 keyboard_controller->AddObserver(docked_layout_manager_); | |
535 } | |
534 aura::Window* parent = root_window(); | 536 aura::Window* parent = root_window(); |
535 aura::Window* keyboard_container = | 537 aura::Window* keyboard_container = |
536 keyboard_controller->GetContainerWindow(); | 538 keyboard_controller->GetContainerWindow(); |
537 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); | 539 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); |
538 parent->AddChild(keyboard_container); | 540 parent->AddChild(keyboard_container); |
539 // TODO(oshima): Bounds of keyboard container should be handled by | 541 // TODO(oshima): Bounds of keyboard container should be handled by |
540 // RootWindowLayoutManager. Remove this after fixed RootWindowLayoutManager. | 542 // RootWindowLayoutManager. Remove this after fixed RootWindowLayoutManager. |
541 keyboard_container->SetBounds(parent->bounds()); | 543 keyboard_container->SetBounds(parent->bounds()); |
542 } | 544 } |
543 | 545 |
544 void RootWindowController::DeactivateKeyboard( | 546 void RootWindowController::DeactivateKeyboard( |
545 keyboard::KeyboardController* keyboard_controller) { | 547 keyboard::KeyboardController* keyboard_controller) { |
546 if (!keyboard::IsKeyboardEnabled()) | 548 if (!keyboard::IsKeyboardEnabled()) |
547 return; | 549 return; |
548 | 550 |
549 DCHECK(keyboard_controller); | 551 DCHECK(keyboard_controller); |
550 aura::Window* keyboard_container = | 552 aura::Window* keyboard_container = |
551 keyboard_controller->GetContainerWindow(); | 553 keyboard_controller->GetContainerWindow(); |
552 if (keyboard_container->GetRootWindow() == root_window()) { | 554 if (keyboard_container->GetRootWindow() == root_window()) { |
553 root_window()->RemoveChild(keyboard_container); | 555 root_window()->RemoveChild(keyboard_container); |
554 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); | 556 if (!keyboard::IsKeyboardUsabilityTestEnabled()) { |
555 keyboard_controller->RemoveObserver(panel_layout_manager_); | 557 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); |
556 keyboard_controller->RemoveObserver(docked_layout_manager_); | 558 keyboard_controller->RemoveObserver(panel_layout_manager_); |
559 keyboard_controller->RemoveObserver(docked_layout_manager_); | |
560 } | |
557 } | 561 } |
558 } | 562 } |
559 | 563 |
560 | 564 |
561 //////////////////////////////////////////////////////////////////////////////// | 565 //////////////////////////////////////////////////////////////////////////////// |
562 // RootWindowController, private: | 566 // RootWindowController, private: |
563 | 567 |
564 RootWindowController::RootWindowController(aura::RootWindow* root_window) | 568 RootWindowController::RootWindowController(aura::RootWindow* root_window) |
565 : root_window_(root_window), | 569 : root_window_(root_window), |
566 root_window_layout_(NULL), | 570 root_window_layout_(NULL), |
567 docked_layout_manager_(NULL), | 571 docked_layout_manager_(NULL), |
568 panel_layout_manager_(NULL), | 572 panel_layout_manager_(NULL), |
569 touch_hud_debug_(NULL), | 573 touch_hud_debug_(NULL), |
570 touch_hud_projection_(NULL) { | 574 touch_hud_projection_(NULL) { |
571 GetRootWindowSettings(root_window)->controller = this; | 575 GetRootWindowSettings(root_window)->controller = this; |
572 screen_dimmer_.reset(new ScreenDimmer(root_window)); | 576 screen_dimmer_.reset(new ScreenDimmer(root_window)); |
573 | 577 |
574 stacking_controller_.reset(new StackingController); | 578 stacking_controller_.reset(new StackingController); |
575 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); | 579 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); |
576 capture_client_.reset(new views::corewm::ScopedCaptureClient(root_window)); | 580 capture_client_.reset(new views::corewm::ScopedCaptureClient(root_window)); |
577 } | 581 } |
578 | 582 |
579 void RootWindowController::Init(RootWindowType root_window_type, | 583 void RootWindowController::Init(RootWindowType root_window_type, |
580 bool first_run_after_boot) { | 584 bool first_run_after_boot) { |
581 Shell::GetInstance()->InitRootWindow(root_window_.get()); | 585 Shell* shell = Shell::GetInstance(); |
586 shell->InitRootWindow(root_window_.get()); | |
582 | 587 |
583 root_window_->SetCursor(ui::kCursorPointer); | 588 root_window_->SetCursor(ui::kCursorPointer); |
584 CreateContainersInRootWindow(root_window_.get()); | 589 CreateContainersInRootWindow(root_window_.get()); |
585 | 590 |
586 if (root_window_type == VIRTUAL_KEYBOARD) | 591 if (root_window_type == VIRTUAL_KEYBOARD) { |
592 shell->InitKeyboard(this); | |
587 return; | 593 return; |
594 } | |
588 | 595 |
589 CreateSystemBackground(first_run_after_boot); | 596 CreateSystemBackground(first_run_after_boot); |
590 | 597 |
591 InitLayoutManagers(); | 598 InitLayoutManagers(); |
592 InitTouchHuds(); | 599 InitTouchHuds(); |
593 | 600 |
594 if (Shell::GetPrimaryRootWindowController()-> | 601 if (Shell::GetPrimaryRootWindowController()-> |
595 GetSystemModalLayoutManager(NULL)->has_modal_background()) { | 602 GetSystemModalLayoutManager(NULL)->has_modal_background()) { |
596 GetSystemModalLayoutManager(NULL)->CreateModalBackground(); | 603 GetSystemModalLayoutManager(NULL)->CreateModalBackground(); |
597 } | 604 } |
598 | 605 |
599 Shell* shell = Shell::GetInstance(); | |
600 shell->AddShellObserver(this); | 606 shell->AddShellObserver(this); |
601 | 607 |
602 if (root_window_type == PRIMARY) { | 608 if (root_window_type == PRIMARY) { |
603 root_window_layout()->OnWindowResized(); | 609 root_window_layout()->OnWindowResized(); |
604 shell->InitKeyboard(this); | 610 if (!keyboard::IsKeyboardUsabilityTestEnabled()) |
oshima
2013/11/01 00:09:02
The name of this flag is confusing. Can we rename
bshe
2013/11/12 15:28:33
Do you mean change --keyboard-usability-test to --
| |
611 shell->InitKeyboard(this); | |
605 } else { | 612 } else { |
606 root_window_layout()->OnWindowResized(); | 613 root_window_layout()->OnWindowResized(); |
607 shell->desktop_background_controller()->OnRootWindowAdded( | 614 shell->desktop_background_controller()->OnRootWindowAdded( |
608 root_window_.get()); | 615 root_window_.get()); |
609 shell->high_contrast_controller()->OnRootWindowAdded(root_window_.get()); | 616 shell->high_contrast_controller()->OnRootWindowAdded(root_window_.get()); |
610 root_window_->ShowRootWindow(); | 617 root_window_->ShowRootWindow(); |
611 // Activate new root for testing. | 618 // Activate new root for testing. |
612 // TODO(oshima): remove this. | 619 // TODO(oshima): remove this. |
613 shell->set_target_root_window(root_window_.get()); | 620 shell->set_target_root_window(root_window_.get()); |
614 | 621 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 DisableTouchHudProjection(); | 914 DisableTouchHudProjection(); |
908 } | 915 } |
909 | 916 |
910 RootWindowController* GetRootWindowController( | 917 RootWindowController* GetRootWindowController( |
911 const aura::Window* root_window) { | 918 const aura::Window* root_window) { |
912 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 919 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
913 } | 920 } |
914 | 921 |
915 } // namespace internal | 922 } // namespace internal |
916 } // namespace ash | 923 } // namespace ash |
OLD | NEW |