Commit 0e450495 authored by kevers's avatar kevers Committed by Commit bot

Fix size and position of the virtual keyboard after a screen rotation.

This regression was introduced by commit #295268, which fixed the z-order of the virtual keyboards with respect to context menus.  That change pushed the virtual keyboard container deeper in the window hierarchy such that it no longer receives size change notifications after a screen rotation.

This patch introduces a custom layout manager on the virtual keyboard parent container to propagate the size change.  The virtual keyboard container is created or destroyed as the feature is enabled or disabled.  The parent container serves as a placeholder in the proper z-order.  The window hierarchy is: root -> lock screen related container -> VK parent container -> VK container -> VK.

BUG=417612
TEST=VirtualKeyboardRootWindowControllerTest.DisplayRotation

Review URL: https://codereview.chromium.org/617553002

Cr-Commit-Position: refs/heads/master@{#297430}
parent a70360f3
......@@ -616,6 +616,8 @@
'wm/toplevel_window_event_handler.h',
'wm/video_detector.cc',
'wm/video_detector.h',
"wm/virtual_keyboard_container_layout_manager.cc",
"wm/virtual_keyboard_container_layout_manager.h",
'wm/window_animations.cc',
'wm/window_animations.h',
'wm/window_positioner.cc',
......
......@@ -44,6 +44,7 @@
#include "ash/wm/status_area_layout_manager.h"
#include "ash/wm/system_background_controller.h"
#include "ash/wm/system_modal_container_layout_manager.h"
#include "ash/wm/virtual_keyboard_container_layout_manager.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
......@@ -1005,6 +1006,9 @@ void RootWindowController::CreateContainersInRootWindow(
lock_screen_related_containers);
wm::SetSnapsChildrenToPhysicalPixelBoundary(
virtual_keyboard_parent_container);
virtual_keyboard_parent_container->SetLayoutManager(
new VirtualKeyboardContainerLayoutManager(
virtual_keyboard_parent_container));
SetUsesScreenCoordinates(virtual_keyboard_parent_container);
aura::Window* menu_container = CreateContainer(
......
......@@ -944,5 +944,27 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) {
menu.reset();
}
// Resolution in UpdateDisplay is not being respected on Windows 8.
#if defined(OS_WIN)
#define MAYBE_DisplayRotation DISABLED_DisplayRotation
#else
#define MAYBE_DisplayRotation DisplayRotation
#endif
// Tests that the virtual keyboard correctly resizes with a change to display
// orientation. See crbug/417612.
TEST_F(VirtualKeyboardRootWindowControllerTest, MAYBE_DisplayRotation) {
UpdateDisplay("800x600");
aura::Window* root_window = Shell::GetPrimaryRootWindow();
aura::Window* keyboard_container =
Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer);
ASSERT_TRUE(keyboard_container);
keyboard_container->Show();
EXPECT_EQ("0,0 800x600", keyboard_container->bounds().ToString());
UpdateDisplay("600x800");
EXPECT_EQ("0,0 600x800", keyboard_container->bounds().ToString());
}
} // namespace test
} // namespace ash
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/virtual_keyboard_container_layout_manager.h"
#include "ash/shell_window_ids.h"
#include "ui/aura/window.h"
#include "ui/keyboard/keyboard_controller.h"
namespace ash {
////////////////////////////////////////////////////////////////////////////////
// VirtualKeyboardContainerLayoutManager, public:
VirtualKeyboardContainerLayoutManager::VirtualKeyboardContainerLayoutManager(
aura::Window* container)
: SnapToPixelLayoutManager(container),
parent_container_(container) {}
VirtualKeyboardContainerLayoutManager::~VirtualKeyboardContainerLayoutManager()
{
}
////////////////////////////////////////////////////////////////////////////////
// VirtualKeyboardContainerLayoutManager, aura::LayoutManager implementation:
void VirtualKeyboardContainerLayoutManager::OnWindowResized() {
keyboard::KeyboardController* keyboard_controller =
keyboard::KeyboardController::GetInstance();
if (!keyboard_controller)
return;
// The layout manager for the root window propagates a resize to its
// immediate children and grandchildren, but stops there. The keyboard
// container is three levels deep, and therefore needs to be explicitly
// updated when its parent is resized.
aura::Window* keyboard_container =
keyboard_controller->GetContainerWindow();
if (keyboard_container)
keyboard_container->SetBounds(parent_container_->bounds());
}
} // namespace ash
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_VIRTUAL_KEYBOARD_CONTAINER_LAYOUT_MANAGER_H_
#define ASH_WM_VIRTUAL_KEYBOARD_CONTAINER_LAYOUT_MANAGER_H_
#include "ash/snap_to_pixel_layout_manager.h"
#include "base/macros.h"
namespace aura {
class Window;
}
namespace ash {
class VirtualKeyboardContainerLayoutManager : public SnapToPixelLayoutManager {
public:
explicit VirtualKeyboardContainerLayoutManager(aura::Window* container);
virtual ~VirtualKeyboardContainerLayoutManager();
// Overridden from SnapToPixelLayoutManager:
virtual void OnWindowResized() OVERRIDE;
private:
aura::Window* parent_container_;
DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardContainerLayoutManager);
};
} // namespace ash
#endif // ASH_WM_VIRTUAL_KEYBOARD_CONTAINER_LAYOUT_MANAGER_H_
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment