Ignores programmatic bounds changes for docked windows. This prevents a window that is using resizeTo or similar API from changing window bounds while it is managed by DockedLayoutManager.
BUG=496852 TEST=DockedWindowLayoutManagerTest.DockedWindowBoundsDontChange Review URL: https://codereview.chromium.org/1149153007 Cr-Commit-Position: refs/heads/master@{#333226}
This commit is contained in:
@@ -210,8 +210,9 @@ bool IsPopupOrTransient(const aura::Window* window) {
|
|||||||
::wm::GetTransientParent(window));
|
::wm::GetTransientParent(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Certain windows (minimized, hidden or popups) do not matter to docking.
|
// Certain windows (minimized, hidden or popups) are not docked and are ignored
|
||||||
bool IsUsedByLayout(const aura::Window* window) {
|
// by layout logic even when they are children of a docked container.
|
||||||
|
bool IsWindowDocked(const aura::Window* window) {
|
||||||
return (window->IsVisible() &&
|
return (window->IsVisible() &&
|
||||||
!wm::GetWindowState(window)->IsMinimized() &&
|
!wm::GetWindowState(window)->IsMinimized() &&
|
||||||
!IsPopupOrTransient(window));
|
!IsPopupOrTransient(window));
|
||||||
@@ -479,8 +480,7 @@ void DockedWindowLayoutManager::StartDragging(aura::Window* window) {
|
|||||||
WindowResizer::kBoundsChangeDirection_Horizontal)) {
|
WindowResizer::kBoundsChangeDirection_Horizontal)) {
|
||||||
for (size_t i = 0; i < dock_container_->children().size(); ++i) {
|
for (size_t i = 0; i < dock_container_->children().size(); ++i) {
|
||||||
aura::Window* window1(dock_container_->children()[i]);
|
aura::Window* window1(dock_container_->children()[i]);
|
||||||
if (IsUsedByLayout(window1) &&
|
if (IsWindowDocked(window1) && window1 != dragged_window_ &&
|
||||||
window1 != dragged_window_ &&
|
|
||||||
window1->bounds().width() == docked_width_) {
|
window1->bounds().width() == docked_width_) {
|
||||||
wm::GetWindowState(window1)->set_bounds_changed_by_user(false);
|
wm::GetWindowState(window1)->set_bounds_changed_by_user(false);
|
||||||
}
|
}
|
||||||
@@ -745,6 +745,8 @@ void DockedWindowLayoutManager::SetChildBounds(
|
|||||||
actual_new_bounds.set_height(
|
actual_new_bounds.set_height(
|
||||||
std::max(min_size.height(), actual_new_bounds.height()));
|
std::max(min_size.height(), actual_new_bounds.height()));
|
||||||
}
|
}
|
||||||
|
if (IsWindowDocked(child) && child != dragged_window_)
|
||||||
|
return;
|
||||||
SnapToPixelLayoutManager::SetChildBounds(child, actual_new_bounds);
|
SnapToPixelLayoutManager::SetChildBounds(child, actual_new_bounds);
|
||||||
if (IsPopupOrTransient(child))
|
if (IsPopupOrTransient(child))
|
||||||
return;
|
return;
|
||||||
@@ -938,7 +940,7 @@ void DockedWindowLayoutManager::MaybeMinimizeChildrenExcept(
|
|||||||
aura::Window::Windows::const_reverse_iterator iter = children.rbegin();
|
aura::Window::Windows::const_reverse_iterator iter = children.rbegin();
|
||||||
while (iter != children.rend()) {
|
while (iter != children.rend()) {
|
||||||
aura::Window* window(*iter++);
|
aura::Window* window(*iter++);
|
||||||
if (window == child || !IsUsedByLayout(window))
|
if (window == child || !IsWindowDocked(window))
|
||||||
continue;
|
continue;
|
||||||
int room_needed = GetWindowHeightCloseTo(window, 0) +
|
int room_needed = GetWindowHeightCloseTo(window, 0) +
|
||||||
(gap_needed ? kMinDockGap : 0);
|
(gap_needed ? kMinDockGap : 0);
|
||||||
@@ -1015,7 +1017,7 @@ void DockedWindowLayoutManager::RecordUmaAction(DockedAction action,
|
|||||||
if (IsPopupOrTransient(window))
|
if (IsPopupOrTransient(window))
|
||||||
continue;
|
continue;
|
||||||
docked_all_count++;
|
docked_all_count++;
|
||||||
if (!IsUsedByLayout(window))
|
if (!IsWindowDocked(window))
|
||||||
continue;
|
continue;
|
||||||
docked_visible_count++;
|
docked_visible_count++;
|
||||||
if (window->type() == ui::wm::WINDOW_TYPE_PANEL)
|
if (window->type() == ui::wm::WINDOW_TYPE_PANEL)
|
||||||
@@ -1076,7 +1078,7 @@ void DockedWindowLayoutManager::Relayout() {
|
|||||||
for (size_t i = 0; i < dock_container_->children().size(); ++i) {
|
for (size_t i = 0; i < dock_container_->children().size(); ++i) {
|
||||||
aura::Window* window(dock_container_->children()[i]);
|
aura::Window* window(dock_container_->children()[i]);
|
||||||
|
|
||||||
if (!IsUsedByLayout(window) || window == dragged_window_)
|
if (!IsWindowDocked(window) || window == dragged_window_)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If the shelf is currently hidden (full-screen mode), hide window until
|
// If the shelf is currently hidden (full-screen mode), hide window until
|
||||||
@@ -1316,7 +1318,7 @@ void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) {
|
|||||||
for (aura::Window::Windows::const_iterator it =
|
for (aura::Window::Windows::const_iterator it =
|
||||||
dock_container_->children().begin();
|
dock_container_->children().begin();
|
||||||
it != dock_container_->children().end(); ++it) {
|
it != dock_container_->children().end(); ++it) {
|
||||||
if (!IsUsedByLayout(*it) ||
|
if (!IsWindowDocked(*it) ||
|
||||||
((*it) == dragged_window_ && !is_dragged_window_docked_)) {
|
((*it) == dragged_window_ && !is_dragged_window_docked_)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -237,6 +237,23 @@ TEST_P(DockedWindowLayoutManagerTest, AddOneWindow) {
|
|||||||
EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
|
EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests that a docked window's bounds cannot be changed programmatically.
|
||||||
|
TEST_P(DockedWindowLayoutManagerTest, DockedWindowBoundsDontChange) {
|
||||||
|
if (!SupportsHostWindowResize())
|
||||||
|
return;
|
||||||
|
|
||||||
|
gfx::Rect bounds(0, 0, 201, 201);
|
||||||
|
scoped_ptr<aura::Window> window(CreateTestWindow(bounds));
|
||||||
|
DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
|
||||||
|
|
||||||
|
// The window should be attached and docked at the right edge.
|
||||||
|
EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
|
||||||
|
|
||||||
|
bounds = window->GetBoundsInScreen();
|
||||||
|
window->SetBounds(gfx::Rect(210, 210, 210, 210));
|
||||||
|
EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString());
|
||||||
|
}
|
||||||
|
|
||||||
// Tests that with a window docked on the left the auto-placing logic in
|
// Tests that with a window docked on the left the auto-placing logic in
|
||||||
// RearrangeVisibleWindowOnShow places windows flush with work area edges.
|
// RearrangeVisibleWindowOnShow places windows flush with work area edges.
|
||||||
TEST_P(DockedWindowLayoutManagerTest, AutoPlacingLeft) {
|
TEST_P(DockedWindowLayoutManagerTest, AutoPlacingLeft) {
|
||||||
|
Reference in New Issue
Block a user