| Index: ash/wm/window_util.cc
|
| diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
|
| index 3adb2968049eadccb5da5e65493634e3691b9d19..460b9c35f16acf15bb8015915f2e8fa6f4e3813e 100644
|
| --- a/ash/wm/window_util.cc
|
| +++ b/ash/wm/window_util.cc
|
| @@ -86,7 +86,8 @@ bool CanResizeWindow(const aura::Window* window) {
|
|
|
| bool CanSnapWindow(aura::Window* window) {
|
| // If a window has a maximum size defined, snapping may make it too big.
|
| - return window->delegate()->GetMaximumSize().IsEmpty();
|
| + return window->delegate() ? window->delegate()->GetMaximumSize().IsEmpty() :
|
| + true;
|
| }
|
|
|
| bool IsWindowNormal(const aura::Window* window) {
|
| @@ -139,6 +140,27 @@ void CenterWindow(aura::Window* window) {
|
| window->SetBounds(center);
|
| }
|
|
|
| +void SnapWindow(aura::Window* window, internal::SnapSizer::Edge edge) {
|
| + if (!CanSnapWindow(window))
|
| + return;
|
| + internal::SnapSizer sizer(window, gfx::Point(), edge,
|
| + internal::SnapSizer::OTHER_INPUT);
|
| + if (wm::IsWindowFullscreen(window) || wm::IsWindowMaximized(window)) {
|
| + // Before we can set the bounds we need to restore the window.
|
| + // Restoring the window will set the window to its restored bounds.
|
| + // To avoid an unnecessary bounds changes (which may have side effects)
|
| + // we set the restore bounds to the bounds we want, restore the window,
|
| + // then reset the restore bounds. This way no unnecessary bounds
|
| + // changes occurs and the original restore bounds is remembered.
|
| + gfx::Rect restore = *GetRestoreBoundsInScreen(window);
|
| + SetRestoreBoundsInParent(window, sizer.GetSnapBounds(window->bounds()));
|
| + wm::RestoreWindow(window);
|
| + SetRestoreBoundsInScreen(window, restore);
|
| + } else {
|
| + window->SetBounds(sizer.GetSnapBounds(window->bounds()));
|
| + }
|
| +}
|
| +
|
| ui::Layer* RecreateWindowLayers(aura::Window* window, bool set_bounds) {
|
| const gfx::Rect bounds = window->bounds();
|
| ui::Layer* old_layer = window->RecreateLayer();
|
|
|