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

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_window_state.cc

Issue 2091263004: Moves a couple of the maximize mode classes to ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 5 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
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"
10 #include "ash/common/shell_window_ids.h" 9 #include "ash/common/shell_window_ids.h"
11 #include "ash/common/wm/window_animation_types.h" 10 #include "ash/common/wm/window_animation_types.h"
12 #include "ash/common/wm/window_state_delegate.h"
13 #include "ash/common/wm/window_state_util.h" 11 #include "ash/common/wm/window_state_util.h"
14 #include "ash/common/wm/wm_event.h" 12 #include "ash/common/wm/wm_event.h"
15 #include "ash/common/wm/wm_screen_util.h" 13 #include "ash/common/wm/wm_screen_util.h"
16 #include "ash/common/wm/workspace/workspace_window_resizer.h"
17 #include "ash/common/wm_shell.h" 14 #include "ash/common/wm_shell.h"
18 #include "ash/screen_util.h" 15 #include "ash/common/wm_window.h"
19 #include "ash/shell.h"
20 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" 16 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h"
21 #include "ash/wm/window_animations.h"
22 #include "ash/wm/window_properties.h"
23 #include "ash/wm/window_state_aura.h"
24 #include "ash/wm/window_util.h"
25 #include "ui/aura/client/aura_constants.h"
26 #include "ui/aura/window.h"
27 #include "ui/aura/window_delegate.h"
28 #include "ui/compositor/layer.h" 17 #include "ui/compositor/layer.h"
29 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
30 #include "ui/views/view_constants_aura.h"
31 #include "ui/views/widget/widget.h"
32 19
33 namespace ash { 20 namespace ash {
34 namespace { 21 namespace {
35 22
36 // Returns the biggest possible size for a window which is about to be 23 // Returns the biggest possible size for a window which is about to be
37 // maximized. 24 // maximized.
38 gfx::Size GetMaximumSizeOfWindow(wm::WindowState* window_state) { 25 gfx::Size GetMaximumSizeOfWindow(wm::WindowState* window_state) {
39 DCHECK(window_state->CanMaximize() || window_state->CanResize()); 26 DCHECK(window_state->CanMaximize() || window_state->CanResize());
40 27
41 gfx::Size workspace_size = 28 gfx::Size workspace_size =
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // static 92 // static
106 void MaximizeModeWindowState::UpdateWindowPosition( 93 void MaximizeModeWindowState::UpdateWindowPosition(
107 wm::WindowState* window_state) { 94 wm::WindowState* window_state) {
108 gfx::Rect bounds_in_parent = GetBoundsInMaximizedMode(window_state); 95 gfx::Rect bounds_in_parent = GetBoundsInMaximizedMode(window_state);
109 if (bounds_in_parent == window_state->window()->GetBounds()) 96 if (bounds_in_parent == window_state->window()->GetBounds())
110 return; 97 return;
111 window_state->SetBoundsDirect(bounds_in_parent); 98 window_state->SetBoundsDirect(bounds_in_parent);
112 } 99 }
113 100
114 MaximizeModeWindowState::MaximizeModeWindowState( 101 MaximizeModeWindowState::MaximizeModeWindowState(
115 aura::Window* window, 102 WmWindow* window,
116 MaximizeModeWindowManager* creator) 103 MaximizeModeWindowManager* creator)
117 : window_(window), 104 : window_(window),
118 creator_(creator), 105 creator_(creator),
119 current_state_type_(wm::GetWindowState(window)->GetStateType()), 106 current_state_type_(window->GetWindowState()->GetStateType()),
120 defer_bounds_updates_(false) { 107 defer_bounds_updates_(false) {
121 old_state_.reset(wm::GetWindowState(window) 108 old_state_.reset(window_->GetWindowState()
122 ->SetStateObject(std::unique_ptr<State>(this)) 109 ->SetStateObject(std::unique_ptr<State>(this))
123 .release()); 110 .release());
124 } 111 }
125 112
126 MaximizeModeWindowState::~MaximizeModeWindowState() { 113 MaximizeModeWindowState::~MaximizeModeWindowState() {
127 creator_->WindowStateDestroyed(window_); 114 creator_->WindowStateDestroyed(window_);
128 } 115 }
129 116
130 void MaximizeModeWindowState::LeaveMaximizeMode(wm::WindowState* window_state) { 117 void MaximizeModeWindowState::LeaveMaximizeMode(wm::WindowState* window_state) {
131 // Note: When we return we will destroy ourselves with the |our_reference|. 118 // Note: When we return we will destroy ourselves with the |our_reference|.
132 std::unique_ptr<wm::WindowState::State> our_reference = 119 std::unique_ptr<wm::WindowState::State> our_reference =
133 window_state->SetStateObject(std::move(old_state_)); 120 window_state->SetStateObject(std::move(old_state_));
134 } 121 }
135 122
136 void MaximizeModeWindowState::SetDeferBoundsUpdates(bool defer_bounds_updates) { 123 void MaximizeModeWindowState::SetDeferBoundsUpdates(bool defer_bounds_updates) {
137 if (defer_bounds_updates_ == defer_bounds_updates) 124 if (defer_bounds_updates_ == defer_bounds_updates)
138 return; 125 return;
139 126
140 defer_bounds_updates_ = defer_bounds_updates; 127 defer_bounds_updates_ = defer_bounds_updates;
141 if (!defer_bounds_updates_) 128 if (!defer_bounds_updates_)
142 UpdateBounds(wm::GetWindowState(window_), true); 129 UpdateBounds(window_->GetWindowState(), true);
143 } 130 }
144 131
145 void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state, 132 void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state,
146 const wm::WMEvent* event) { 133 const wm::WMEvent* event) {
147 switch (event->type()) { 134 switch (event->type()) {
148 case wm::WM_EVENT_TOGGLE_FULLSCREEN: 135 case wm::WM_EVENT_TOGGLE_FULLSCREEN:
149 ToggleFullScreen(window_state, window_state->delegate()); 136 ToggleFullScreen(window_state, window_state->delegate());
150 break; 137 break;
151 case wm::WM_EVENT_FULLSCREEN: 138 case wm::WM_EVENT_FULLSCREEN:
152 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_FULLSCREEN, true); 139 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_FULLSCREEN, true);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 210
224 wm::WindowStateType MaximizeModeWindowState::GetType() const { 211 wm::WindowStateType MaximizeModeWindowState::GetType() const {
225 return current_state_type_; 212 return current_state_type_;
226 } 213 }
227 214
228 void MaximizeModeWindowState::AttachState( 215 void MaximizeModeWindowState::AttachState(
229 wm::WindowState* window_state, 216 wm::WindowState* window_state,
230 wm::WindowState::State* previous_state) { 217 wm::WindowState::State* previous_state) {
231 current_state_type_ = previous_state->GetType(); 218 current_state_type_ = previous_state->GetType();
232 219
233 aura::Window* window =
234 ash::WmWindowAura::GetAuraWindow(window_state->window());
235 gfx::Rect restore_bounds = GetRestoreBounds(window_state); 220 gfx::Rect restore_bounds = GetRestoreBounds(window_state);
236 if (!restore_bounds.IsEmpty()) { 221 if (!restore_bounds.IsEmpty()) {
237 // We do not want to do a session restore to our window states. Therefore 222 // We do not want to do a session restore to our window states. Therefore
238 // we tell the window to use the current default states instead. 223 // we tell the window to use the current default states instead.
239 window->SetProperty(ash::kRestoreShowStateOverrideKey, 224 window_state->window()->SetRestoreOverrides(restore_bounds,
240 window_state->GetShowState()); 225 window_state->GetShowState());
241 window->SetProperty(ash::kRestoreBoundsOverrideKey,
242 new gfx::Rect(restore_bounds));
243 } 226 }
244 227
245 // Initialize the state to a good preset. 228 // Initialize the state to a good preset.
246 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED && 229 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED &&
247 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED && 230 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED &&
248 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN && 231 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN &&
249 current_state_type_ != wm::WINDOW_STATE_TYPE_PINNED) { 232 current_state_type_ != wm::WINDOW_STATE_TYPE_PINNED) {
250 UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state), 233 UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state),
251 true); 234 true);
252 } 235 }
253 236
254 window_state->set_can_be_dragged(false); 237 window_state->set_can_be_dragged(false);
255 } 238 }
256 239
257 void MaximizeModeWindowState::DetachState(wm::WindowState* window_state) { 240 void MaximizeModeWindowState::DetachState(wm::WindowState* window_state) {
258 // From now on, we can use the default session restore mechanism again. 241 // From now on, we can use the default session restore mechanism again.
259 ash::WmWindowAura::GetAuraWindow(window_state->window()) 242 window_state->window()->SetRestoreOverrides(gfx::Rect(),
260 ->ClearProperty(ash::kRestoreBoundsOverrideKey); 243 ui::SHOW_STATE_NORMAL);
261 window_state->set_can_be_dragged(true); 244 window_state->set_can_be_dragged(true);
262 } 245 }
263 246
264 void MaximizeModeWindowState::UpdateWindow(wm::WindowState* window_state, 247 void MaximizeModeWindowState::UpdateWindow(wm::WindowState* window_state,
265 wm::WindowStateType target_state, 248 wm::WindowStateType target_state,
266 bool animated) { 249 bool animated) {
267 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED || 250 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED ||
268 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED || 251 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED ||
269 target_state == wm::WINDOW_STATE_TYPE_PINNED || 252 target_state == wm::WINDOW_STATE_TYPE_PINNED ||
270 (target_state == wm::WINDOW_STATE_TYPE_NORMAL && 253 (target_state == wm::WINDOW_STATE_TYPE_NORMAL &&
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // avoid flashing. 317 // avoid flashing.
335 if (window_state->IsMaximized()) 318 if (window_state->IsMaximized())
336 window_state->SetBoundsDirectCrossFade(bounds_in_parent); 319 window_state->SetBoundsDirectCrossFade(bounds_in_parent);
337 else 320 else
338 window_state->SetBoundsDirectAnimated(bounds_in_parent); 321 window_state->SetBoundsDirectAnimated(bounds_in_parent);
339 } 322 }
340 } 323 }
341 } 324 }
342 325
343 } // namespace ash 326 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_window_state.h ('k') | ash/wm/maximize_mode/workspace_backdrop_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698