Commit 46ae571b authored by Qiang Xu's avatar Qiang Xu Committed by Commit Bot

cros: update restore bounds on MoveWindowToDisplay

changes:
We should update restore bounds to respond MoveWindowToDisplay call.

Bug: 825079
Test: manual test and added test coverage
Change-Id: I1c502bcab1f86c40fc513dc9e414ca60e22dc37c
Reviewed-on: https://chromium-review.googlesource.com/977033Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Qiang Xu <warx@google.com>
Cr-Commit-Position: refs/heads/master@{#546999}
parent a0666cac
......@@ -11,6 +11,7 @@
#include "ash/public/cpp/ash_features.h"
#include "ash/root_window_controller.h"
#include "ash/screen_util.h"
#include "ash/shelf/shelf_constants.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/mru_window_tracker.h"
......@@ -449,6 +450,23 @@ TEST_F(DisplayMoveWindowUtilTest, TransientParentNotInCycleWindowList) {
screen->GetDisplayNearestWindow(child->GetNativeWindow()).id());
}
// Tests that restore bounds is updated with window movement to another display.
TEST_F(DisplayMoveWindowUtilTest, RestoreMaximizedWindowAfterMovement) {
UpdateDisplay("400x300,400x300");
aura::Window* w =
CreateTestWindowInShellWithBounds(gfx::Rect(10, 20, 200, 100));
wm::ActivateWindow(w);
wm::WindowState* window_state = wm::GetWindowState(w);
window_state->Maximize();
EXPECT_EQ(gfx::Rect(0, 0, 400, 300 - kShelfSize), w->GetBoundsInScreen());
PerformMoveWindowAccel();
EXPECT_EQ(gfx::Rect(400, 0, 400, 300 - kShelfSize), w->GetBoundsInScreen());
window_state->Restore();
EXPECT_EQ(gfx::Rect(410, 20, 200, 100), w->GetBoundsInScreen());
}
} // namespace display_move_window_util
} // namespace ash
......@@ -37,6 +37,7 @@
#include "ui/gfx/geometry/size.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/core/easy_resize_window_targeter.h"
#include "ui/wm/core/window_util.h"
#include "ui/wm/public/activation_client.h"
......@@ -144,6 +145,12 @@ bool MoveWindowToDisplay(aura::Window* window, int64_t display_id) {
return false;
}
aura::Window* root = Shell::GetRootWindowForDisplayId(display_id);
// Update restore bounds to target root window.
if (window_state->HasRestoreBounds()) {
gfx::Rect restore_bounds = window_state->GetRestoreBoundsInParent();
::wm::ConvertRectToScreen(root, &restore_bounds);
window_state->SetRestoreBoundsInScreen(restore_bounds);
}
return root && MoveWindowToRoot(window, root);
}
......
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