Chromium Code Reviews| Index: ash/wm/workspace/workspace_layout_manager.cc |
| diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc |
| index 65ed116b24261cf04babe85e815197cb5f5eaba8..544f07026b4b3a7c73ed0dda113d53083c1a4e20 100644 |
| --- a/ash/wm/workspace/workspace_layout_manager.cc |
| +++ b/ash/wm/workspace/workspace_layout_manager.cc |
| @@ -151,6 +151,15 @@ void WorkspaceLayoutManager::SetChildBounds( |
| SetChildBoundsDirect(child, child_bounds); |
| } |
| workspace_manager()->OnWorkspaceWindowChildBoundsChanged(workspace_, child); |
| + |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshEnableGutter)) { |
| + if (child->type() == aura::client::WINDOW_TYPE_NORMAL && |
| + wm::CanResizeWindow(child)) { |
| + int stuck_edges_mask = CalculateStuckEdges(child); |
| + if (GetStuckToEdge(child) != stuck_edges_mask) |
| + SetStuckToEdge(child, stuck_edges_mask); |
| + } |
| + } |
| } |
| void WorkspaceLayoutManager::OnRootWindowResized(const aura::RootWindow* root, |
| @@ -315,10 +324,12 @@ void WorkspaceLayoutManager::AdjustWindowSizeForScreenChange( |
| // window as possible within the display area. |
| gfx::Rect bounds = window->bounds(); |
| bounds.AdjustToFit(work_area_); |
| + bounds = AdjustWindowBoundsForStuckEdges(window, bounds); |
| window->SetBounds(bounds); |
| } else if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) { |
| gfx::Rect bounds = window->bounds(); |
| ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_, &bounds); |
| + bounds = AdjustWindowBoundsForStuckEdges(window, bounds); |
| if (window->bounds() != bounds) |
| window->SetBounds(bounds); |
| } else if (reason == ADJUST_WINDOW_WINDOW_ADDED) { |
| @@ -336,6 +347,7 @@ void WorkspaceLayoutManager::AdjustWindowSizeForScreenChange( |
| void WorkspaceLayoutManager::UpdateBoundsFromShowState(Window* window) { |
| // See comment in SetMaximizedOrFullscreenBounds() as to why we use parent in |
| // these calculation. |
| + int stuck_edges_mask = EDGE_NONE; |
| switch (window->GetProperty(aura::client::kShowStateKey)) { |
| case ui::SHOW_STATE_DEFAULT: |
| case ui::SHOW_STATE_NORMAL: { |
| @@ -351,17 +363,25 @@ void WorkspaceLayoutManager::UpdateBoundsFromShowState(Window* window) { |
| bounds_in_parent)); |
| } |
| ClearRestoreBounds(window); |
| + stuck_edges_mask = CalculateStuckEdges(window); |
|
flackr
2013/05/01 17:34:04
We probably only want to "stick" windows when they
varkha
2013/05/18 03:06:37
Done.
|
| break; |
| } |
| case ui::SHOW_STATE_MAXIMIZED: |
| case ui::SHOW_STATE_FULLSCREEN: |
| SetMaximizedOrFullscreenBounds(window); |
| + stuck_edges_mask = EDGE_ALL; |
| break; |
| default: |
| break; |
| } |
| + |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshEnableGutter)) |
| + if (window->type() == aura::client::WINDOW_TYPE_NORMAL && |
| + wm::CanResizeWindow(window)) |
| + if (GetStuckToEdge(window) != stuck_edges_mask) |
| + SetStuckToEdge(window, stuck_edges_mask); |
| } |
| bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( |
| @@ -387,6 +407,56 @@ bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( |
| return false; |
| } |
| +int WorkspaceLayoutManager::CalculateStuckEdges(aura::Window* window) { |
| + int stuck_edges_mask = EDGE_NONE; |
| + if (window->bounds().x() == work_area_.x()) |
| + stuck_edges_mask |= EDGE_LEFT; |
| + if (window->bounds().right() == work_area_.right()) |
| + stuck_edges_mask |= EDGE_RIGHT; |
| + if (window->bounds().y() == work_area_.y()) |
| + stuck_edges_mask |= EDGE_TOP; |
| + if (window->bounds().bottom() == work_area_.bottom()) |
| + stuck_edges_mask |= EDGE_BOTTOM; |
| + return stuck_edges_mask; |
| +} |
| + |
| +gfx::Rect WorkspaceLayoutManager::AdjustWindowBoundsForStuckEdges( |
| + aura::Window* window, |
| + const gfx::Rect& bounds) { |
| + gfx::Rect adjusted_bounds(bounds); |
| + if ((0 != (GetStuckToEdge(window) & EDGE_RIGHT) && |
|
flackr
2013/05/01 17:34:04
why the 0 !=? This should be fine as just if ((Get
varkha
2013/05/18 03:06:37
Done.
|
| + bounds.right() != work_area_.right()) || |
|
flackr
2013/05/01 17:34:04
These seem like they should be handled separately
varkha
2013/05/18 03:06:37
Done.
|
| + (0 != (GetStuckToEdge(window) & EDGE_LEFT) && |
| + bounds.x() != work_area_.x())) { |
| + if (0 != (GetStuckToEdge(window) & EDGE_LEFT)) { |
| + adjusted_bounds.set_x(work_area_.x()); |
| + adjusted_bounds.set_width(work_area_.width()); |
| + } else { |
| + adjusted_bounds.set_x(work_area_.width() - bounds.width()); |
| + } |
| + } else { |
|
flackr
2013/05/01 17:34:04
} else if (X) {
..
}
instead of:
} else {
if (
varkha
2013/05/18 03:06:37
The code got broken when I was chasing launcher au
|
| + if (0 != (GetStuckToEdge(window) & EDGE_LEFT) && |
| + bounds.x() != work_area_.x()) |
|
flackr
2013/05/01 17:34:04
This seems the same as the case above.
varkha
2013/05/18 03:06:37
Done.
|
| + adjusted_bounds.set_x(work_area_.x()); |
| + } |
| + if ((0 != (GetStuckToEdge(window) & EDGE_BOTTOM) && |
| + bounds.bottom() != work_area_.bottom()) || |
| + (0 != (GetStuckToEdge(window) & EDGE_TOP) && |
| + bounds.y() != work_area_.y())) { |
| + if (0 != (GetStuckToEdge(window) & EDGE_TOP)) { |
| + adjusted_bounds.set_y(work_area_.y()); |
| + adjusted_bounds.set_height(work_area_.height()); |
| + } else { |
| + adjusted_bounds.set_y(work_area_.height() - bounds.height()); |
| + } |
| + } else { |
| + if (0 != (GetStuckToEdge(window) & EDGE_TOP) && |
| + bounds.y() != work_area_.y()) |
| + adjusted_bounds.set_y(work_area_.y()); |
| + } |
|
flackr
2013/05/01 17:34:04
I don't think we'll support sticking to the bottom
varkha
2013/05/18 03:06:37
The top and bottom are useful when launcher auto-h
|
| + return adjusted_bounds; |
| +} |
| + |
| WorkspaceManager* WorkspaceLayoutManager::workspace_manager() { |
| return workspace_->workspace_manager(); |
| } |