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

Unified Diff: ash/wm/maximize_mode/maximize_mode_window_state.cc

Issue 2095793002: Convert determining restore bounds to use ash/common type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak Created 4 years, 6 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 | « ash/aura/wm_window_aura.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e0b0a9f69509fe8b81b15222317365e8c97d3600..b96fc2e3ea113db8dae66a7ab25efa0d5fad0395 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_state.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_state.cc
@@ -79,6 +79,27 @@ gfx::Rect GetBoundsInMaximizedMode(wm::WindowState* state_object) {
return GetCenteredBounds(bounds_in_parent, state_object);
}
+gfx::Rect GetRestoreBounds(wm::WindowState* window_state) {
+ if (window_state->IsMinimized() || window_state->IsMaximized() ||
+ window_state->IsFullscreen()) {
+ gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen();
+ if (!restore_bounds.IsEmpty())
+ return restore_bounds;
+ }
+ gfx::Rect bounds = window_state->window()->GetBoundsInScreen();
+ if (window_state->IsDocked()) {
+ gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen();
+ // Use current window horizontal offset origin in order to preserve docked
+ // alignment but preserve restored size and vertical offset for the time
+ // when the window gets undocked.
+ if (!restore_bounds.IsEmpty()) {
+ bounds.set_size(restore_bounds.size());
+ bounds.set_y(restore_bounds.y());
+ }
+ }
+ return bounds;
+}
+
} // namespace
// static
@@ -211,17 +232,14 @@ void MaximizeModeWindowState::AttachState(
aura::Window* window =
ash::WmWindowAura::GetAuraWindow(window_state->window());
- views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
- if (widget) {
- gfx::Rect bounds = widget->GetRestoredBounds();
- if (!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->SetProperty(ash::kRestoreShowStateOverrideKey,
- window_state->GetShowState());
- window->SetProperty(ash::kRestoreBoundsOverrideKey,
- new gfx::Rect(widget->GetRestoredBounds()));
- }
+ gfx::Rect restore_bounds = GetRestoreBounds(window_state);
+ 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->SetProperty(ash::kRestoreShowStateOverrideKey,
+ window_state->GetShowState());
+ window->SetProperty(ash::kRestoreBoundsOverrideKey,
+ new gfx::Rect(restore_bounds));
}
// Initialize the state to a good preset.
« no previous file with comments | « ash/aura/wm_window_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698