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

Side by Side Diff: ash/wm/base_layout_manager.cc

Issue 10910164: Removes the grid from ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ShelfBrowserTest Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/base_layout_manager.h ('k') | ash/wm/base_layout_manager_unittest.cc » ('j') | 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/base_layout_manager.h" 5 #include "ash/wm/base_layout_manager.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/shelf_layout_manager.h" 10 #include "ash/wm/shelf_layout_manager.h"
11 #include "ash/wm/window_animations.h" 11 #include "ash/wm/window_animations.h"
12 #include "ash/wm/window_properties.h" 12 #include "ash/wm/window_properties.h"
13 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
14 #include "ash/wm/workspace_controller.h" 14 #include "ash/wm/workspace_controller.h"
15 #include "ash/wm/workspace/workspace_window_resizer.h"
15 #include "base/command_line.h" 16 #include "base/command_line.h"
16 #include "ui/aura/client/aura_constants.h" 17 #include "ui/aura/client/aura_constants.h"
17 #include "ui/aura/root_window.h" 18 #include "ui/aura/root_window.h"
18 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
19 #include "ui/base/ui_base_types.h" 20 #include "ui/base/ui_base_types.h"
20 #include "ui/compositor/layer.h" 21 #include "ui/compositor/layer.h"
21 #include "ui/gfx/screen.h" 22 #include "ui/gfx/screen.h"
22 23
23 namespace {
24
25 // Given a |window| and tentative |restore_bounds|, returns new bounds that
26 // ensure that at least a few pixels of the screen background are visible
27 // outside the edges of the window. Use this to ensure that restoring a
28 // maximized window creates enough space that the resize handles are easily
29 // clickable. We get into this state when updating Chrome OS R18 to R19, as
30 // Chrome OS R18 and earlier used only maximized windows and set their restore
31 // bounds to the size of the screen. See crbug.com/108073
32 gfx::Rect BoundsWithScreenEdgeVisible(aura::Window* window,
33 const gfx::Rect& restore_bounds) {
34 // If the restore_bounds are more than 1 grid step away from the size the
35 // window would be when maximized, inset it.
36 int grid_size = ash::Shell::GetInstance()->GetGridSize();
37 gfx::Rect max_bounds =
38 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window);
39 max_bounds.Inset(grid_size, grid_size);
40 if (restore_bounds.Contains(max_bounds))
41 return max_bounds;
42 return restore_bounds;
43 }
44
45 } // namespace
46
47 namespace ash { 24 namespace ash {
48 namespace internal { 25 namespace internal {
49 26
50 ///////////////////////////////////////////////////////////////////////////// 27 /////////////////////////////////////////////////////////////////////////////
51 // BaseLayoutManager, public: 28 // BaseLayoutManager, public:
52 29
53 BaseLayoutManager::BaseLayoutManager(aura::RootWindow* root_window) 30 BaseLayoutManager::BaseLayoutManager(aura::RootWindow* root_window)
54 : root_window_(root_window) { 31 : root_window_(root_window) {
55 Shell::GetInstance()->AddShellObserver(this); 32 Shell::GetInstance()->AddShellObserver(this);
56 root_window_->AddRootWindowObserver(this); 33 root_window_->AddRootWindowObserver(this);
57 root_window_->AddObserver(this); 34 root_window_->AddObserver(this);
58 } 35 }
59 36
60 BaseLayoutManager::~BaseLayoutManager() { 37 BaseLayoutManager::~BaseLayoutManager() {
61 if (root_window_) { 38 if (root_window_) {
62 root_window_->RemoveObserver(this); 39 root_window_->RemoveObserver(this);
63 root_window_->RemoveRootWindowObserver(this); 40 root_window_->RemoveRootWindowObserver(this);
64 } 41 }
65 for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i) 42 for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i)
66 (*i)->RemoveObserver(this); 43 (*i)->RemoveObserver(this);
67 Shell::GetInstance()->RemoveShellObserver(this); 44 Shell::GetInstance()->RemoveShellObserver(this);
68 } 45 }
69 46
47 // static
48 gfx::Rect BaseLayoutManager::BoundsWithScreenEdgeVisible(
49 aura::Window* window,
50 const gfx::Rect& restore_bounds) {
51 gfx::Rect max_bounds =
52 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window);
53 // If the restore_bounds are more than 1 grid step away from the size the
54 // window would be when maximized, inset it.
55 max_bounds.Inset(ash::internal::WorkspaceWindowResizer::kScreenEdgeInset,
56 ash::internal::WorkspaceWindowResizer::kScreenEdgeInset);
57 if (restore_bounds.Contains(max_bounds))
58 return max_bounds;
59 return restore_bounds;
60 }
61
70 ///////////////////////////////////////////////////////////////////////////// 62 /////////////////////////////////////////////////////////////////////////////
71 // BaseLayoutManager, LayoutManager overrides: 63 // BaseLayoutManager, LayoutManager overrides:
72 64
73 void BaseLayoutManager::OnWindowResized() { 65 void BaseLayoutManager::OnWindowResized() {
74 } 66 }
75 67
76 void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) { 68 void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
77 windows_.insert(child); 69 windows_.insert(child);
78 child->AddObserver(this); 70 child->AddObserver(this);
79 // Only update the bounds if the window has a show state that depends on the 71 // Only update the bounds if the window has a show state that depends on the
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 gfx::Rect display_rect = 249 gfx::Rect display_rect =
258 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window); 250 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window);
259 // Put as much of the window as possible within the display area. 251 // Put as much of the window as possible within the display area.
260 window->SetBounds(window->bounds().AdjustToFit(display_rect)); 252 window->SetBounds(window->bounds().AdjustToFit(display_rect));
261 } 253 }
262 } 254 }
263 } 255 }
264 256
265 } // namespace internal 257 } // namespace internal
266 } // namespace ash 258 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/base_layout_manager.h ('k') | ash/wm/base_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698