Commit d750f589 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Allow bounds change for normal window from VK request in tablet mode.

Bug: 1071236
Change-Id: If37eb5af5c976ad7d713cb7519ade25fa2f32984
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2249393
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779408}
parent bca9130d
......@@ -55,6 +55,7 @@
#include "ui/base/hit_test.h"
#include "ui/events/test/event_generator.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/ime_util_chromeos.h"
#include "ui/wm/core/transient_window_manager.h"
#include "ui/wm/core/window_util.h"
......@@ -1598,6 +1599,27 @@ TEST_P(TabletModeWindowManagerTest, DontMaximizeTransientChild) {
EXPECT_EQ(rect.size(), child->bounds().size());
}
TEST_P(TabletModeWindowManagerTest, AllowNormalWindowBoundsChangeByVK) {
UpdateDisplay("1200x800");
gfx::Rect rect(0, 0, 1200, 600);
std::unique_ptr<aura::Window> window(CreateFixedSizeNonMaximizableWindow(
aura::client::WINDOW_TYPE_NORMAL, rect));
ASSERT_TRUE(CreateTabletModeWindowManager());
WindowState* window_state = WindowState::Get(window.get());
EXPECT_FALSE(window_state->IsMaximized());
EXPECT_EQ(WindowStateType::kNormal, window_state->GetStateType());
gfx::Rect window_bounds = window->bounds();
// Simulate VK up.
wm::EnsureWindowNotInRect(window.get(), gfx::Rect(0, 600, 1200, 200));
EXPECT_NE(window->bounds(), window_bounds);
// Simulate VK dismissal.
wm::RestoreWindowBoundsOnClientFocusLost(window.get());
EXPECT_EQ(window->bounds(), window_bounds);
}
class TabletModeWindowManagerWithoutClamshellSplitViewTest
: public TabletModeWindowManagerTest {
public:
......
......@@ -28,6 +28,7 @@
#include "ui/aura/window_delegate.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/wm/core/ime_util_chromeos.h"
#include "ui/wm/core/window_util.h"
namespace ash {
......@@ -163,6 +164,16 @@ bool IsSnapped(WindowStateType state) {
state == WindowStateType::kRightSnapped;
}
// Returns true if the bounds change of |window| is from VK request and can be
// allowed by the current window's state.
bool BoundsChangeIsFromVKAndAllowed(aura::Window* window) {
if (!window->GetProperty(wm::kVirtualKeyboardRestoreBoundsKey))
return false;
WindowStateType state_type = WindowState::Get(window)->GetStateType();
return state_type == WindowStateType::kNormal ||
state_type == WindowStateType::kDefault;
}
} // namespace
// static
......@@ -329,7 +340,8 @@ void TabletModeWindowState::OnWMEvent(WindowState* window_state,
if (window_util::IsDraggingTabs(window_state->window()) ||
IsTabDraggingSourceWindow(window_state->window()) ||
TabDragDropDelegate::IsSourceWindowForDrag(window_state->window())) {
TabDragDropDelegate::IsSourceWindowForDrag(window_state->window()) ||
BoundsChangeIsFromVKAndAllowed(window_state->window())) {
// If the window is the current tab-dragged window or the current tab-
// dragged window's source window, we may need to update its bounds
// during dragging.
......
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