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 e4e6c841e0208d8856a54a0cd53a6853d8c3128b..dbd02a561b44720d8ae0fa60c914c8071da53bea 100644 |
| --- a/ash/wm/workspace/workspace_layout_manager.cc |
| +++ b/ash/wm/workspace/workspace_layout_manager.cc |
| @@ -13,6 +13,7 @@ |
| #include "ash/wm/window_animations.h" |
| #include "ash/wm/window_properties.h" |
| #include "ash/wm/window_util.h" |
| +#include "ash/wm/workspace/stuck_edge_types.h" |
| #include "ash/wm/workspace/workspace.h" |
| #include "ash/wm/workspace/workspace_manager.h" |
| #include "ash/wm/workspace/workspace_window_resizer.h" |
| @@ -315,10 +316,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 +339,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 = GetStuckToEdge(window); |
| switch (window->GetProperty(aura::client::kShowStateKey)) { |
| case ui::SHOW_STATE_DEFAULT: |
| case ui::SHOW_STATE_NORMAL: { |
| @@ -349,6 +353,9 @@ void WorkspaceLayoutManager::UpdateBoundsFromShowState(Window* window) { |
| BaseLayoutManager::BoundsWithScreenEdgeVisible( |
| window->parent()->parent(), |
| bounds_in_parent)); |
| + |
| + // getting unstuck |
| + stuck_edges_mask = STUCK_EDGE_NONE; |
| } |
| ClearRestoreBounds(window); |
| break; |
| @@ -357,11 +364,16 @@ void WorkspaceLayoutManager::UpdateBoundsFromShowState(Window* window) { |
| case ui::SHOW_STATE_MAXIMIZED: |
| case ui::SHOW_STATE_FULLSCREEN: |
| SetMaximizedOrFullscreenBounds(window); |
| + stuck_edges_mask = STUCK_EDGE_NONE; |
| break; |
| default: |
| break; |
| } |
| + if (GetStuckToEdge(window) != stuck_edges_mask && |
| + CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kAshEnableDockedWindows)) |
| + SetStuckToEdge(window, stuck_edges_mask); |
| } |
| bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( |
| @@ -387,6 +399,32 @@ bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( |
| return false; |
| } |
| +gfx::Rect WorkspaceLayoutManager::AdjustWindowBoundsForStuckEdges( |
| + aura::Window* window, |
| + const gfx::Rect& bounds) { |
|
flackr
2013/05/22 02:00:56
We should do all docked window specific layout cha
|
| + gfx::Rect new_bounds(bounds); |
| + if ((GetStuckToEdge(window) & STUCK_EDGE_LEFT) && |
| + bounds.x() != work_area_.x()) |
| + new_bounds.set_x(work_area_.x()); |
| + if ((GetStuckToEdge(window) & STUCK_EDGE_RIGHT) && |
| + new_bounds.right() != work_area_.right()) { |
| + if (GetStuckToEdge(window) & STUCK_EDGE_LEFT) |
| + new_bounds.set_width(work_area_.right() - new_bounds.x()); |
| + else |
| + new_bounds.set_x(work_area_.right() - bounds.width()); |
| + } |
| + if ((GetStuckToEdge(window) & STUCK_EDGE_TOP) && bounds.y() != work_area_.y()) |
| + new_bounds.set_y(work_area_.y()); |
| + if ((GetStuckToEdge(window) & STUCK_EDGE_BOTTOM) && |
| + new_bounds.bottom() != work_area_.bottom()) { |
| + if (GetStuckToEdge(window) & STUCK_EDGE_TOP) |
| + new_bounds.set_height(work_area_.bottom() - new_bounds.y()); |
| + else |
| + new_bounds.set_y(work_area_.bottom() - bounds.height()); |
| + } |
| + return new_bounds; |
| +} |
| + |
| WorkspaceManager* WorkspaceLayoutManager::workspace_manager() { |
| return workspace_->workspace_manager(); |
| } |