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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager2.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
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_layout_manager2.h" 5 #include "ash/wm/workspace/workspace_layout_manager2.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/always_on_top_controller.h" 10 #include "ash/wm/always_on_top_controller.h"
11 #include "ash/wm/base_layout_manager.h"
11 #include "ash/wm/window_animations.h" 12 #include "ash/wm/window_animations.h"
12 #include "ash/wm/window_properties.h" 13 #include "ash/wm/window_properties.h"
13 #include "ash/wm/window_util.h" 14 #include "ash/wm/window_util.h"
14 #include "ash/wm/workspace/workspace2.h" 15 #include "ash/wm/workspace/workspace2.h"
15 #include "ash/wm/workspace/workspace_manager2.h" 16 #include "ash/wm/workspace/workspace_manager2.h"
17 #include "ash/wm/workspace/workspace_window_resizer.h"
16 #include "base/auto_reset.h" 18 #include "base/auto_reset.h"
17 #include "base/command_line.h" 19 #include "base/command_line.h"
18 #include "ui/aura/client/aura_constants.h" 20 #include "ui/aura/client/aura_constants.h"
19 #include "ui/aura/root_window.h" 21 #include "ui/aura/root_window.h"
20 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
21 #include "ui/aura/window_observer.h" 23 #include "ui/aura/window_observer.h"
22 #include "ui/base/events/event.h" 24 #include "ui/base/events/event.h"
23 #include "ui/base/ui_base_types.h" 25 #include "ui/base/ui_base_types.h"
24 26
25 using aura::Window; 27 using aura::Window;
26 28
27 namespace ash { 29 namespace ash {
28 namespace internal { 30 namespace internal {
29 31
30 namespace {
31
32 gfx::Rect BoundsWithScreenEdgeVisible(
33 aura::Window* window,
34 const gfx::Rect& restore_bounds) {
35 // If the restore_bounds are more than 1 grid step away from the size the
36 // window would be when maximized, inset it.
37 int grid_size = ash::Shell::GetInstance()->GetGridSize();
38 gfx::Rect max_bounds = ash::ScreenAsh::GetMaximizedWindowBoundsInParent(
39 window->parent()->parent());
40 max_bounds.Inset(grid_size, grid_size);
41 // TODO(sky): this looks totally wrong!
42 if (restore_bounds.Contains(max_bounds))
43 return max_bounds;
44 return restore_bounds;
45 }
46
47 } // namespace
48
49 WorkspaceLayoutManager2::WorkspaceLayoutManager2(Workspace2* workspace) 32 WorkspaceLayoutManager2::WorkspaceLayoutManager2(Workspace2* workspace)
50 : root_window_(workspace->window()->GetRootWindow()), 33 : root_window_(workspace->window()->GetRootWindow()),
51 workspace_(workspace), 34 workspace_(workspace),
52 work_area_(ScreenAsh::GetDisplayWorkAreaBoundsInParent( 35 work_area_(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
53 workspace->window()->parent())) { 36 workspace->window()->parent())) {
54 Shell::GetInstance()->AddShellObserver(this); 37 Shell::GetInstance()->AddShellObserver(this);
55 root_window_->AddRootWindowObserver(this); 38 root_window_->AddRootWindowObserver(this);
56 root_window_->AddObserver(this); 39 root_window_->AddObserver(this);
57 } 40 }
58 41
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // See comment in SetMaximizedOrFullscreenBounds() as to why we use parent in 209 // See comment in SetMaximizedOrFullscreenBounds() as to why we use parent in
227 // these calculation. 210 // these calculation.
228 switch (window->GetProperty(aura::client::kShowStateKey)) { 211 switch (window->GetProperty(aura::client::kShowStateKey)) {
229 case ui::SHOW_STATE_DEFAULT: 212 case ui::SHOW_STATE_DEFAULT:
230 case ui::SHOW_STATE_NORMAL: { 213 case ui::SHOW_STATE_NORMAL: {
231 const gfx::Rect* restore = GetRestoreBoundsInScreen(window); 214 const gfx::Rect* restore = GetRestoreBoundsInScreen(window);
232 if (restore) { 215 if (restore) {
233 gfx::Rect bounds_in_parent = 216 gfx::Rect bounds_in_parent =
234 ScreenAsh::ConvertRectFromScreen(window->parent()->parent(), 217 ScreenAsh::ConvertRectFromScreen(window->parent()->parent(),
235 *restore); 218 *restore);
236 SetChildBoundsDirect(window, 219 SetChildBoundsDirect(
237 BoundsWithScreenEdgeVisible(window, 220 window,
238 bounds_in_parent)); 221 BaseLayoutManager::BoundsWithScreenEdgeVisible(
222 window->parent()->parent(),
223 bounds_in_parent));
239 } 224 }
240 window->ClearProperty(aura::client::kRestoreBoundsKey); 225 window->ClearProperty(aura::client::kRestoreBoundsKey);
241 break; 226 break;
242 } 227 }
243 228
244 case ui::SHOW_STATE_MAXIMIZED: 229 case ui::SHOW_STATE_MAXIMIZED:
245 case ui::SHOW_STATE_FULLSCREEN: 230 case ui::SHOW_STATE_FULLSCREEN:
246 SetMaximizedOrFullscreenBounds(window); 231 SetMaximizedOrFullscreenBounds(window);
247 break; 232 break;
248 233
(...skipping 21 matching lines...) Expand all
270 } 255 }
271 return false; 256 return false;
272 } 257 }
273 258
274 WorkspaceManager2* WorkspaceLayoutManager2::workspace_manager() { 259 WorkspaceManager2* WorkspaceLayoutManager2::workspace_manager() {
275 return workspace_->workspace_manager(); 260 return workspace_->workspace_manager();
276 } 261 }
277 262
278 } // namespace internal 263 } // namespace internal
279 } // namespace ash 264 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_event_filter_unittest.cc ('k') | ash/wm/workspace/workspace_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698