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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/wm/workspace/workspace_layout_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/workspace_layout_manager.cc
diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc
index 2fd56af26cbc9c4ba608936d3c21b34485ecf17f..c748d9a9e465c075bf94a8bbfcab8bc16b95b935 100644
--- a/ash/wm/workspace/workspace_layout_manager.cc
+++ b/ash/wm/workspace/workspace_layout_manager.cc
@@ -4,6 +4,7 @@
#include "ash/wm/workspace/workspace_layout_manager.h"
+#include "ash/display/display_controller.h"
#include "ash/root_window_controller.h"
#include "ash/screen_ash.h"
#include "ash/shelf/shelf_layout_manager.h"
@@ -41,6 +42,33 @@ bool IsMaximizedState(ui::WindowShowState state) {
state == ui::SHOW_STATE_FULLSCREEN;
}
+void MoveToDisplayForRestore(aura::Window* window) {
+ const gfx::Rect* restore_bounds = GetRestoreBoundsInScreen(window);
+ if (!restore_bounds)
+ return;
+
+ // Move only if the restore bounds is outside of
+ // the root window. There is no information about in which
+ // display it should be restored, so this is best guess.
+ // TODO(oshima): Restore information should contain the
+ // work area information like WindowResizer does for the
+ // last window location.
+ if (!window->GetRootWindow()->GetBoundsInScreen().Intersects(
+ *restore_bounds)) {
+ DisplayController* display_controller =
+ Shell::GetInstance()->display_controller();
+ const gfx::Display& display =
+ display_controller->GetDisplayMatching(*restore_bounds);
+ aura::RootWindow* new_root =
+ display_controller->GetRootWindowForDisplayId(display.id());
+ if (new_root != window->GetRootWindow()) {
+ aura::Window* new_container =
+ Shell::GetContainer(new_root, window->parent()->id());
+ new_container->AddChild(window);
+ }
+ }
+}
+
} // namespace
WorkspaceLayoutManager::WorkspaceLayoutManager(aura::Window* window)
@@ -285,14 +313,15 @@ void WorkspaceLayoutManager::UpdateBoundsFromShowState(Window* window) {
}
case ui::SHOW_STATE_MAXIMIZED:
+ MoveToDisplayForRestore(window);
CrossFadeToBounds(window, ScreenAsh::GetMaximizedWindowBoundsInParent(
window->parent()->parent()));
break;
case ui::SHOW_STATE_FULLSCREEN:
+ MoveToDisplayForRestore(window);
CrossFadeToBounds(window, ScreenAsh::GetDisplayBoundsInParent(
window->parent()->parent()));
break;
-
default:
break;
}
« 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