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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager.cc

Issue 22394003: Maximize window in the display to be restored. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: check null Created 7 years, 4 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 | « no previous file | ash/wm/workspace/workspace_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/workspace/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include "ash/display/display_controller.h"
7 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
8 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
9 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shell.h" 11 #include "ash/shell.h"
11 #include "ash/wm/always_on_top_controller.h" 12 #include "ash/wm/always_on_top_controller.h"
12 #include "ash/wm/base_layout_manager.h" 13 #include "ash/wm/base_layout_manager.h"
13 #include "ash/wm/frame_painter.h" 14 #include "ash/wm/frame_painter.h"
14 #include "ash/wm/property_util.h" 15 #include "ash/wm/property_util.h"
15 #include "ash/wm/window_animations.h" 16 #include "ash/wm/window_animations.h"
16 #include "ash/wm/window_properties.h" 17 #include "ash/wm/window_properties.h"
(...skipping 17 matching lines...) Expand all
34 35
35 // This specifies how much percent 30% of a window rect (width / height) 36 // This specifies how much percent 30% of a window rect (width / height)
36 // must be visible when the window is added to the workspace. 37 // must be visible when the window is added to the workspace.
37 const float kMinimumPercentOnScreenArea = 0.3f; 38 const float kMinimumPercentOnScreenArea = 0.3f;
38 39
39 bool IsMaximizedState(ui::WindowShowState state) { 40 bool IsMaximizedState(ui::WindowShowState state) {
40 return state == ui::SHOW_STATE_MAXIMIZED || 41 return state == ui::SHOW_STATE_MAXIMIZED ||
41 state == ui::SHOW_STATE_FULLSCREEN; 42 state == ui::SHOW_STATE_FULLSCREEN;
42 } 43 }
43 44
45 void MoveToDisplayForRestore(aura::Window* window) {
46 const gfx::Rect* restore_bounds = GetRestoreBoundsInScreen(window);
47 if (!restore_bounds)
48 return;
49
50 // Move only if the restore bounds is outside of
51 // the root window. There is no information about in which
52 // display it should be restored, so this is best guess.
53 // TODO(oshima): Restore information should contain the
54 // work area information like WindowResizer does for the
55 // last window location.
56 if (!window->GetRootWindow()->GetBoundsInScreen().Intersects(
57 *restore_bounds)) {
58 DisplayController* display_controller =
59 Shell::GetInstance()->display_controller();
60 const gfx::Display& display =
61 display_controller->GetDisplayMatching(*restore_bounds);
62 aura::RootWindow* new_root =
63 display_controller->GetRootWindowForDisplayId(display.id());
64 if (new_root != window->GetRootWindow()) {
65 aura::Window* new_container =
66 Shell::GetContainer(new_root, window->parent()->id());
67 new_container->AddChild(window);
68 }
69 }
70 }
71
44 } // namespace 72 } // namespace
45 73
46 WorkspaceLayoutManager::WorkspaceLayoutManager(aura::Window* window) 74 WorkspaceLayoutManager::WorkspaceLayoutManager(aura::Window* window)
47 : BaseLayoutManager(window->GetRootWindow()), 75 : BaseLayoutManager(window->GetRootWindow()),
48 shelf_(NULL), 76 shelf_(NULL),
49 window_(window), 77 window_(window),
50 work_area_(ScreenAsh::GetDisplayWorkAreaBoundsInParent( 78 work_area_(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
51 window->parent())) { 79 window->parent())) {
52 } 80 }
53 81
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 window, 306 window,
279 BaseLayoutManager::BoundsWithScreenEdgeVisible( 307 BaseLayoutManager::BoundsWithScreenEdgeVisible(
280 window->parent()->parent(), 308 window->parent()->parent(),
281 bounds_in_parent)); 309 bounds_in_parent));
282 } 310 }
283 ClearRestoreBounds(window); 311 ClearRestoreBounds(window);
284 break; 312 break;
285 } 313 }
286 314
287 case ui::SHOW_STATE_MAXIMIZED: 315 case ui::SHOW_STATE_MAXIMIZED:
316 MoveToDisplayForRestore(window);
288 CrossFadeToBounds(window, ScreenAsh::GetMaximizedWindowBoundsInParent( 317 CrossFadeToBounds(window, ScreenAsh::GetMaximizedWindowBoundsInParent(
289 window->parent()->parent())); 318 window->parent()->parent()));
290 break; 319 break;
291 case ui::SHOW_STATE_FULLSCREEN: 320 case ui::SHOW_STATE_FULLSCREEN:
321 MoveToDisplayForRestore(window);
292 CrossFadeToBounds(window, ScreenAsh::GetDisplayBoundsInParent( 322 CrossFadeToBounds(window, ScreenAsh::GetDisplayBoundsInParent(
293 window->parent()->parent())); 323 window->parent()->parent()));
294 break; 324 break;
295
296 default: 325 default:
297 break; 326 break;
298 } 327 }
299 } 328 }
300 329
301 bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( 330 bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds(
302 aura::Window* window) { 331 aura::Window* window) {
303 if (!GetTrackedByWorkspace(window)) 332 if (!GetTrackedByWorkspace(window))
304 return false; 333 return false;
305 334
(...skipping 10 matching lines...) Expand all
316 SetChildBoundsDirect( 345 SetChildBoundsDirect(
317 window, 346 window,
318 ScreenAsh::GetDisplayBoundsInParent(window->parent()->parent())); 347 ScreenAsh::GetDisplayBoundsInParent(window->parent()->parent()));
319 return true; 348 return true;
320 } 349 }
321 return false; 350 return false;
322 } 351 }
323 352
324 } // namespace internal 353 } // namespace internal
325 } // namespace ash 354 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/workspace/workspace_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698