Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2576)

Unified Diff: ash/wm/workspace/workspace_manager.cc

Issue 9969164: Ignoring alignment when it pushes a window out of the screen (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698