Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: ash/root_window_controller.cc

Issue 2747543002: ash: Start/stop observing KeyboardController via ShellObserver (Closed)
Patch Set: update keyboard container before notifying keyboard state observers Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <queue> 8 #include <queue>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 wm::GetWindowForFullscreenMode(WmWindow::Get(GetRootWindow()))); 666 wm::GetWindowForFullscreenMode(WmWindow::Get(GetRootWindow())));
667 } 667 }
668 668
669 void RootWindowController::ActivateKeyboard( 669 void RootWindowController::ActivateKeyboard(
670 keyboard::KeyboardController* keyboard_controller) { 670 keyboard::KeyboardController* keyboard_controller) {
671 if (!keyboard::IsKeyboardEnabled() || 671 if (!keyboard::IsKeyboardEnabled() ||
672 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { 672 GetContainer(kShellWindowId_VirtualKeyboardContainer)) {
673 return; 673 return;
674 } 674 }
675 DCHECK(keyboard_controller); 675 DCHECK(keyboard_controller);
676 keyboard_controller->AddObserver(wm_shelf_->shelf_layout_manager());
677 keyboard_controller->AddObserver(panel_layout_manager());
678 keyboard_controller->AddObserver(docked_window_layout_manager());
679 keyboard_controller->AddObserver(workspace_controller()->layout_manager());
680 keyboard_controller->AddObserver(
681 always_on_top_controller_->GetLayoutManager());
682 Shell::GetInstance()->NotifyVirtualKeyboardActivated(true);
683 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); 676 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
684 DCHECK(parent); 677 DCHECK(parent);
685 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); 678 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow();
686 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); 679 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer);
687 parent->AddChild(keyboard_container); 680 parent->AddChild(keyboard_container);
681 // Notify observers after adding keyboard container because various layout
682 // managers are using the root window of the container window to decide
683 // whether the keyboard is relevant to them.
684 Shell::GetInstance()->NotifyVirtualKeyboardActivated(true);
688 } 685 }
689 686
690 void RootWindowController::DeactivateKeyboard( 687 void RootWindowController::DeactivateKeyboard(
691 keyboard::KeyboardController* keyboard_controller) { 688 keyboard::KeyboardController* keyboard_controller) {
692 if (!keyboard_controller || 689 if (!keyboard_controller ||
693 !keyboard_controller->keyboard_container_initialized()) { 690 !keyboard_controller->keyboard_container_initialized()) {
694 return; 691 return;
695 } 692 }
696 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); 693 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow();
697 if (keyboard_container->GetRootWindow() == GetRootWindow()) { 694 if (keyboard_container->GetRootWindow() == GetRootWindow()) {
698 aura::Window* parent = 695 aura::Window* parent =
699 GetContainer(kShellWindowId_ImeWindowParentContainer); 696 GetContainer(kShellWindowId_ImeWindowParentContainer);
700 DCHECK(parent); 697 DCHECK(parent);
701 // Virtual keyboard may be deactivated while still showing, hide the 698 // Virtual keyboard may be deactivated while still showing, hide the
702 // keyboard before removing it from view hierarchy. 699 // keyboard before removing it from view hierarchy.
703 keyboard_controller->HideKeyboard( 700 keyboard_controller->HideKeyboard(
704 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 701 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
702 // Notify observers before removing keyboard container because various
703 // layout managers are using the root window of the container window to
704 // decide whether the keyboard is relevant to them.
705 Shell::GetInstance()->NotifyVirtualKeyboardActivated(false);
705 parent->RemoveChild(keyboard_container); 706 parent->RemoveChild(keyboard_container);
706 keyboard_controller->RemoveObserver(wm_shelf_->shelf_layout_manager());
707 keyboard_controller->RemoveObserver(panel_layout_manager());
708 keyboard_controller->RemoveObserver(docked_window_layout_manager());
709 keyboard_controller->RemoveObserver(
710 workspace_controller()->layout_manager());
711 keyboard_controller->RemoveObserver(
712 always_on_top_controller_->GetLayoutManager());
713 Shell::GetInstance()->NotifyVirtualKeyboardActivated(false);
714 } 707 }
715 } 708 }
716 709
717 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { 710 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) {
718 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); 711 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
719 return parent ? parent->Contains(window) : false; 712 return parent ? parent->Contains(window) : false;
720 } 713 }
721 714
722 void RootWindowController::SetTouchAccessibilityAnchorPoint( 715 void RootWindowController::SetTouchAccessibilityAnchorPoint(
723 const gfx::Point& anchor_point) { 716 const gfx::Point& anchor_point) {
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 EnableTouchHudProjection(); 1146 EnableTouchHudProjection();
1154 else 1147 else
1155 DisableTouchHudProjection(); 1148 DisableTouchHudProjection();
1156 } 1149 }
1157 1150
1158 RootWindowController* GetRootWindowController(const aura::Window* root_window) { 1151 RootWindowController* GetRootWindowController(const aura::Window* root_window) {
1159 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; 1152 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr;
1160 } 1153 }
1161 1154
1162 } // namespace ash 1155 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698