Chromium Code Reviews| Index: ash/wm/workspace/workspace_manager.cc |
| diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc |
| index e4cec4b645ec7be0d89da3cf02323882d6d6e708..cc339e2fc20be0996badcb8b763b2f264d1f50b2 100644 |
| --- a/ash/wm/workspace/workspace_manager.cc |
| +++ b/ash/wm/workspace/workspace_manager.cc |
| @@ -53,10 +53,30 @@ void BuildWindowList(const std::vector<aura::Window*>& windows, |
| gfx::Rect AlignRectToGrid(const gfx::Rect& rect, int grid_size) { |
|
sky
2012/04/11 21:10:00
I believe this is called from a handful of places,
|
| if (grid_size <= 1) |
| return rect; |
| - return gfx::Rect(ash::WindowResizer::AlignToGrid(rect.x(), grid_size), |
| - ash::WindowResizer::AlignToGrid(rect.y(), grid_size), |
| - ash::WindowResizer::AlignToGrid(rect.width(), grid_size), |
| - ash::WindowResizer::AlignToGrid(rect.height(), grid_size)); |
| + int x = ash::WindowResizer::AlignToGrid(rect.x(), grid_size); |
| + int y = ash::WindowResizer::AlignToGrid(rect.y(), grid_size); |
| + int w = ash::WindowResizer::AlignToGrid(rect.width(), grid_size); |
| + int h = ash::WindowResizer::AlignToGrid(rect.height(), grid_size); |
| + |
| + // If the alignment was pushing the window out of the screen, we ignore the |
| + // alignment for that call. |
| + const gfx::Rect work_area = |
| + gfx::Screen::GetMonitorWorkAreaNearestPoint( |
| + gfx::Point((rect.x() + rect.width()) / 2, |
| + (rect.y() + rect.height()) / 2)); |
| + |
| + if (rect.x() + rect.width() <= work_area.width() && |
| + x + w > work_area.width()) { |
| + x = rect.x(); |
|
sky
2012/04/11 21:10:00
Why ignore the grid in this case?
|
| + w = rect.width(); |
| + } |
| + if (rect.y() + rect.height() <= work_area.height() && |
| + y + h > work_area.height()) { |
| + y = rect.y(); |
| + h = rect.height(); |
| + } |
| + |
| + return gfx::Rect(x, y, w, h); |
| } |
| } |