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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « ash/aura/wm_window_aura.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/maximize_mode/maximize_mode_window_state.h" 5 #include "ash/wm/maximize_mode/maximize_mode_window_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/aura/wm_window_aura.h" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // dimensions since they are likely to be the result from some other state 72 // dimensions since they are likely to be the result from some other state
73 // object logic. 73 // object logic.
74 if (state_object->HasRestoreBounds()) 74 if (state_object->HasRestoreBounds())
75 bounds_in_parent = state_object->GetRestoreBoundsInParent(); 75 bounds_in_parent = state_object->GetRestoreBoundsInParent();
76 else 76 else
77 bounds_in_parent = state_object->window()->GetBounds(); 77 bounds_in_parent = state_object->window()->GetBounds();
78 } 78 }
79 return GetCenteredBounds(bounds_in_parent, state_object); 79 return GetCenteredBounds(bounds_in_parent, state_object);
80 } 80 }
81 81
82 gfx::Rect GetRestoreBounds(wm::WindowState* window_state) {
83 if (window_state->IsMinimized() || window_state->IsMaximized() ||
84 window_state->IsFullscreen()) {
85 gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen();
86 if (!restore_bounds.IsEmpty())
87 return restore_bounds;
88 }
89 gfx::Rect bounds = window_state->window()->GetBoundsInScreen();
90 if (window_state->IsDocked()) {
91 gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen();
92 // Use current window horizontal offset origin in order to preserve docked
93 // alignment but preserve restored size and vertical offset for the time
94 // when the window gets undocked.
95 if (!restore_bounds.IsEmpty()) {
96 bounds.set_size(restore_bounds.size());
97 bounds.set_y(restore_bounds.y());
98 }
99 }
100 return bounds;
101 }
102
82 } // namespace 103 } // namespace
83 104
84 // static 105 // static
85 void MaximizeModeWindowState::UpdateWindowPosition( 106 void MaximizeModeWindowState::UpdateWindowPosition(
86 wm::WindowState* window_state) { 107 wm::WindowState* window_state) {
87 gfx::Rect bounds_in_parent = GetBoundsInMaximizedMode(window_state); 108 gfx::Rect bounds_in_parent = GetBoundsInMaximizedMode(window_state);
88 if (bounds_in_parent == window_state->window()->GetBounds()) 109 if (bounds_in_parent == window_state->window()->GetBounds())
89 return; 110 return;
90 window_state->SetBoundsDirect(bounds_in_parent); 111 window_state->SetBoundsDirect(bounds_in_parent);
91 } 112 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return current_state_type_; 225 return current_state_type_;
205 } 226 }
206 227
207 void MaximizeModeWindowState::AttachState( 228 void MaximizeModeWindowState::AttachState(
208 wm::WindowState* window_state, 229 wm::WindowState* window_state,
209 wm::WindowState::State* previous_state) { 230 wm::WindowState::State* previous_state) {
210 current_state_type_ = previous_state->GetType(); 231 current_state_type_ = previous_state->GetType();
211 232
212 aura::Window* window = 233 aura::Window* window =
213 ash::WmWindowAura::GetAuraWindow(window_state->window()); 234 ash::WmWindowAura::GetAuraWindow(window_state->window());
214 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); 235 gfx::Rect restore_bounds = GetRestoreBounds(window_state);
215 if (widget) { 236 if (!restore_bounds.IsEmpty()) {
216 gfx::Rect bounds = widget->GetRestoredBounds(); 237 // We do not want to do a session restore to our window states. Therefore
217 if (!bounds.IsEmpty()) { 238 // we tell the window to use the current default states instead.
218 // We do not want to do a session restore to our window states. Therefore 239 window->SetProperty(ash::kRestoreShowStateOverrideKey,
219 // we tell the window to use the current default states instead. 240 window_state->GetShowState());
220 window->SetProperty(ash::kRestoreShowStateOverrideKey, 241 window->SetProperty(ash::kRestoreBoundsOverrideKey,
221 window_state->GetShowState()); 242 new gfx::Rect(restore_bounds));
222 window->SetProperty(ash::kRestoreBoundsOverrideKey,
223 new gfx::Rect(widget->GetRestoredBounds()));
224 }
225 } 243 }
226 244
227 // Initialize the state to a good preset. 245 // Initialize the state to a good preset.
228 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED && 246 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED &&
229 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED && 247 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED &&
230 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN && 248 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN &&
231 current_state_type_ != wm::WINDOW_STATE_TYPE_PINNED) { 249 current_state_type_ != wm::WINDOW_STATE_TYPE_PINNED) {
232 UpdateWindow(window_state, 250 UpdateWindow(window_state,
233 GetMaximizedOrCenteredWindowType(window_state), 251 GetMaximizedOrCenteredWindowType(window_state),
234 true); 252 true);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // avoid flashing. 336 // avoid flashing.
319 if (window_state->IsMaximized()) 337 if (window_state->IsMaximized())
320 window_state->SetBoundsDirectCrossFade(bounds_in_parent); 338 window_state->SetBoundsDirectCrossFade(bounds_in_parent);
321 else 339 else
322 window_state->SetBoundsDirectAnimated(bounds_in_parent); 340 window_state->SetBoundsDirectAnimated(bounds_in_parent);
323 } 341 }
324 } 342 }
325 } 343 }
326 344
327 } // namespace ash 345 } // namespace ash
OLDNEW
« 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