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.
5 #include "ash/wm/virtual_keyboard_container_layout_manager.h"
7 #include "ash/shell_window_ids.h"
8 #include "ui/aura/window.h"
9 #include "ui/keyboard/keyboard_controller.h"
13 ////////////////////////////////////////////////////////////////////////////////
14 // VirtualKeyboardContainerLayoutManager, public:
16 VirtualKeyboardContainerLayoutManager::VirtualKeyboardContainerLayoutManager(
17 aura::Window
* container
)
18 : SnapToPixelLayoutManager(container
),
19 parent_container_(container
) {}
21 VirtualKeyboardContainerLayoutManager::~VirtualKeyboardContainerLayoutManager()
25 ////////////////////////////////////////////////////////////////////////////////
26 // VirtualKeyboardContainerLayoutManager, aura::LayoutManager implementation:
28 void VirtualKeyboardContainerLayoutManager::OnWindowResized() {
29 keyboard::KeyboardController
* keyboard_controller
=
30 keyboard::KeyboardController::GetInstance();
31 if (!keyboard_controller
)
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());