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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/workspace/workspace_manager.h" 5 #include "ash/wm/workspace/workspace_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Returns a list of all the windows with layers in |result|. 43 // Returns a list of all the windows with layers in |result|.
44 void BuildWindowList(const std::vector<aura::Window*>& windows, 44 void BuildWindowList(const std::vector<aura::Window*>& windows,
45 std::vector<aura::Window*>* result) { 45 std::vector<aura::Window*>* result) {
46 for (size_t i = 0; i < windows.size(); ++i) { 46 for (size_t i = 0; i < windows.size(); ++i) {
47 if (windows[i]->layer()) 47 if (windows[i]->layer())
48 result->push_back(windows[i]); 48 result->push_back(windows[i]);
49 BuildWindowList(windows[i]->transient_children(), result); 49 BuildWindowList(windows[i]->transient_children(), result);
50 } 50 }
51 } 51 }
52 52
53 gfx::Rect AlignRectToGrid(const gfx::Rect& rect, int grid_size) { 53 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,
54 if (grid_size <= 1) 54 if (grid_size <= 1)
55 return rect; 55 return rect;
56 return gfx::Rect(ash::WindowResizer::AlignToGrid(rect.x(), grid_size), 56 int x = ash::WindowResizer::AlignToGrid(rect.x(), grid_size);
57 ash::WindowResizer::AlignToGrid(rect.y(), grid_size), 57 int y = ash::WindowResizer::AlignToGrid(rect.y(), grid_size);
58 ash::WindowResizer::AlignToGrid(rect.width(), grid_size), 58 int w = ash::WindowResizer::AlignToGrid(rect.width(), grid_size);
59 ash::WindowResizer::AlignToGrid(rect.height(), grid_size)); 59 int h = ash::WindowResizer::AlignToGrid(rect.height(), grid_size);
60
61 // If the alignment was pushing the window out of the screen, we ignore the
62 // alignment for that call.
63 const gfx::Rect work_area =
64 gfx::Screen::GetMonitorWorkAreaNearestPoint(
65 gfx::Point((rect.x() + rect.width()) / 2,
66 (rect.y() + rect.height()) / 2));
67
68 if (rect.x() + rect.width() <= work_area.width() &&
69 x + w > work_area.width()) {
70 x = rect.x();
sky 2012/04/11 21:10:00 Why ignore the grid in this case?
71 w = rect.width();
72 }
73 if (rect.y() + rect.height() <= work_area.height() &&
74 y + h > work_area.height()) {
75 y = rect.y();
76 h = rect.height();
77 }
78
79 return gfx::Rect(x, y, w, h);
60 } 80 }
61 81
62 } 82 }
63 83
64 namespace ash { 84 namespace ash {
65 namespace internal { 85 namespace internal {
66 86
67 //////////////////////////////////////////////////////////////////////////////// 87 ////////////////////////////////////////////////////////////////////////////////
68 // WindowManager, public: 88 // WindowManager, public:
69 89
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 return workspace; 380 return workspace;
361 } 381 }
362 382
363 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) { 383 void WorkspaceManager::CleanupWorkspace(Workspace* workspace) {
364 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty()) 384 if (workspace->type() != Workspace::TYPE_MANAGED && workspace->is_empty())
365 delete workspace; 385 delete workspace;
366 } 386 }
367 387
368 } // namespace internal 388 } // namespace internal
369 } // namespace ash 389 } // namespace ash
OLDNEW
« 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