Index: ash/wm/maximize_mode/maximize_mode_window_state.cc |
diff --git a/ash/wm/maximize_mode/maximize_mode_window_state.cc b/ash/wm/maximize_mode/maximize_mode_window_state.cc |
index 904c245a346990157170945bd1e2a860675285fb..cefbf0620a25ae455abebe7a9b204e377e4789ae 100644 |
--- a/ash/wm/maximize_mode/maximize_mode_window_state.cc |
+++ b/ash/wm/maximize_mode/maximize_mode_window_state.cc |
@@ -12,25 +12,46 @@ |
#include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
#include "ash/wm/screen_pinning_controller.h" |
#include "ash/wm/window_animation_types.h" |
+#include "ash/wm/window_properties.h" |
#include "ash/wm/window_state_util.h" |
#include "ash/wm/wm_event.h" |
#include "ash/wm_window.h" |
+#include "ui/aura/window.h" |
+#include "ui/aura/window_delegate.h" |
#include "ui/compositor/layer.h" |
#include "ui/gfx/geometry/rect.h" |
namespace ash { |
namespace { |
+// Sets the restore bounds and show state overrides. These values take |
+// precedence over the restore bounds and restore show state (if set). |
+// If |bounds_override| is empty the values are cleared. |
+void SetWindowRestoreOverrides(aura::Window* window, |
+ const gfx::Rect& bounds_override, |
+ ui::WindowShowState window_state_override) { |
+ if (bounds_override.IsEmpty()) { |
+ window->ClearProperty(kRestoreShowStateOverrideKey); |
+ window->ClearProperty(kRestoreBoundsOverrideKey); |
+ return; |
+ } |
+ window->SetProperty(kRestoreShowStateOverrideKey, window_state_override); |
+ window->SetProperty(kRestoreBoundsOverrideKey, |
+ new gfx::Rect(bounds_override)); |
+} |
+ |
// Returns the biggest possible size for a window which is about to be |
// maximized. |
gfx::Size GetMaximumSizeOfWindow(wm::WindowState* window_state) { |
DCHECK(window_state->CanMaximize() || window_state->CanResize()); |
- gfx::Size workspace_size = ScreenUtil::GetMaximizedWindowBoundsInParent( |
- window_state->window()->aura_window()) |
- .size(); |
+ gfx::Size workspace_size = |
+ ScreenUtil::GetMaximizedWindowBoundsInParent(window_state->window()) |
+ .size(); |
- gfx::Size size = window_state->window()->GetMaximumSize(); |
+ gfx::Size size = window_state->window()->delegate() |
+ ? window_state->window()->delegate()->GetMaximumSize() |
+ : gfx::Size(); |
if (size.IsEmpty()) |
return workspace_size; |
@@ -41,8 +62,8 @@ gfx::Size GetMaximumSizeOfWindow(wm::WindowState* window_state) { |
// Returns the centered bounds of the given bounds in the work area. |
gfx::Rect GetCenteredBounds(const gfx::Rect& bounds_in_parent, |
wm::WindowState* state_object) { |
- gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
- state_object->window()->aura_window()); |
+ gfx::Rect work_area_in_parent = |
+ ScreenUtil::GetDisplayWorkAreaBoundsInParent(state_object->window()); |
work_area_in_parent.ClampToCenteredSize(bounds_in_parent.size()); |
return work_area_in_parent; |
} |
@@ -50,8 +71,7 @@ gfx::Rect GetCenteredBounds(const gfx::Rect& bounds_in_parent, |
// Returns the maximized/full screen and/or centered bounds of a window. |
gfx::Rect GetBoundsInMaximizedMode(wm::WindowState* state_object) { |
if (state_object->IsFullscreen() || state_object->IsPinned()) |
- return ScreenUtil::GetDisplayBoundsInParent( |
- state_object->window()->aura_window()); |
+ return ScreenUtil::GetDisplayBoundsInParent(state_object->window()); |
gfx::Rect bounds_in_parent; |
// Make the window as big as possible. |
@@ -64,7 +84,7 @@ gfx::Rect GetBoundsInMaximizedMode(wm::WindowState* state_object) { |
if (state_object->HasRestoreBounds()) |
bounds_in_parent = state_object->GetRestoreBoundsInParent(); |
else |
- bounds_in_parent = state_object->window()->GetBounds(); |
+ bounds_in_parent = state_object->window()->bounds(); |
} |
return GetCenteredBounds(bounds_in_parent, state_object); |
} |
@@ -85,7 +105,7 @@ gfx::Rect GetRestoreBounds(wm::WindowState* window_state) { |
void MaximizeModeWindowState::UpdateWindowPosition( |
wm::WindowState* window_state) { |
gfx::Rect bounds_in_parent = GetBoundsInMaximizedMode(window_state); |
- if (bounds_in_parent == window_state->window()->GetBounds()) |
+ if (bounds_in_parent == window_state->window()->bounds()) |
return; |
window_state->SetBoundsDirect(bounds_in_parent); |
} |
@@ -180,7 +200,7 @@ void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state, |
gfx::Rect bounds_in_parent = |
(static_cast<const wm::SetBoundsEvent*>(event))->requested_bounds(); |
bounds_in_parent = GetCenteredBounds(bounds_in_parent, window_state); |
- if (bounds_in_parent != window_state->window()->GetBounds()) { |
+ if (bounds_in_parent != window_state->window()->bounds()) { |
if (window_state->window()->IsVisible()) |
window_state->SetBoundsDirectAnimated(bounds_in_parent); |
else |
@@ -222,8 +242,8 @@ void MaximizeModeWindowState::AttachState( |
if (!restore_bounds.IsEmpty()) { |
// We do not want to do a session restore to our window states. Therefore |
// we tell the window to use the current default states instead. |
- window_state->window()->SetRestoreOverrides(restore_bounds, |
- window_state->GetShowState()); |
+ SetWindowRestoreOverrides(window_state->window(), restore_bounds, |
+ window_state->GetShowState()); |
} |
// Initialize the state to a good preset. |
@@ -241,8 +261,8 @@ void MaximizeModeWindowState::AttachState( |
void MaximizeModeWindowState::DetachState(wm::WindowState* window_state) { |
// From now on, we can use the default session restore mechanism again. |
- window_state->window()->SetRestoreOverrides(gfx::Rect(), |
- ui::SHOW_STATE_NORMAL); |
+ SetWindowRestoreOverrides(window_state->window(), gfx::Rect(), |
+ ui::SHOW_STATE_NORMAL); |
window_state->set_can_be_dragged(true); |
} |
@@ -271,8 +291,8 @@ void MaximizeModeWindowState::UpdateWindow(wm::WindowState* window_state, |
window_state->NotifyPreStateTypeChange(old_state_type); |
if (target_state == wm::WINDOW_STATE_TYPE_MINIMIZED) { |
- window_state->window()->SetVisibilityAnimationType( |
- wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); |
+ ::wm::SetWindowVisibilityAnimationType( |
+ window_state->window(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); |
window_state->window()->Hide(); |
if (window_state->IsActive()) |
window_state->Deactivate(); |
@@ -287,12 +307,12 @@ void MaximizeModeWindowState::UpdateWindow(wm::WindowState* window_state, |
old_state_type == wm::WINDOW_STATE_TYPE_TRUSTED_PINNED || |
target_state == wm::WINDOW_STATE_TYPE_TRUSTED_PINNED) { |
Shell::Get()->screen_pinning_controller()->SetPinnedWindow( |
- window_state->window()); |
+ WmWindow::Get(window_state->window())); |
} |
- if ((window_state->window()->GetTargetVisibility() || |
+ if ((window_state->window()->layer()->GetTargetVisibility() || |
old_state_type == wm::WINDOW_STATE_TYPE_MINIMIZED) && |
- !window_state->window()->GetLayer()->visible()) { |
+ !window_state->window()->layer()->visible()) { |
// The layer may be hidden if the window was previously minimized. Make |
// sure it's visible. |
window_state->window()->Show(); |
@@ -313,7 +333,7 @@ void MaximizeModeWindowState::UpdateBounds(wm::WindowState* window_state, |
// If we have a target bounds rectangle, we center it and set it |
// accordingly. |
if (!bounds_in_parent.IsEmpty() && |
- bounds_in_parent != window_state->window()->GetBounds()) { |
+ bounds_in_parent != window_state->window()->bounds()) { |
if (current_state_type_ == wm::WINDOW_STATE_TYPE_MINIMIZED || |
!window_state->window()->IsVisible() || !animated) { |
window_state->SetBoundsDirect(bounds_in_parent); |