Home | History | Annotate | Download | only in wm
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "ash/wm/virtual_keyboard_container_layout_manager.h"
      6 
      7 #include "ash/shell_window_ids.h"
      8 #include "ui/aura/window.h"
      9 #include "ui/keyboard/keyboard_controller.h"
     10 
     11 namespace ash {
     12 
     13 ////////////////////////////////////////////////////////////////////////////////
     14 // VirtualKeyboardContainerLayoutManager, public:
     15 
     16 VirtualKeyboardContainerLayoutManager::VirtualKeyboardContainerLayoutManager(
     17     aura::Window* container)
     18     : SnapToPixelLayoutManager(container),
     19       parent_container_(container) {}
     20 
     21 VirtualKeyboardContainerLayoutManager::~VirtualKeyboardContainerLayoutManager()
     22 {
     23 }
     24 
     25 ////////////////////////////////////////////////////////////////////////////////
     26 // VirtualKeyboardContainerLayoutManager, aura::LayoutManager implementation:
     27 
     28 void VirtualKeyboardContainerLayoutManager::OnWindowResized() {
     29   keyboard::KeyboardController* keyboard_controller =
     30       keyboard::KeyboardController::GetInstance();
     31   if (!keyboard_controller)
     32     return;
     33 
     34   // The layout manager for the root window propagates a resize to its
     35   // immediate children and grandchildren, but stops there. The keyboard
     36   // container is three levels deep, and therefore needs to be explicitly
     37   // updated when its parent is resized.
     38   aura::Window* keyboard_container =
     39       keyboard_controller->GetContainerWindow();
     40   if (keyboard_container)
     41     keyboard_container->SetBounds(parent_container_->bounds());
     42 }
     43 
     44 }  // namespace ash
     45