| OLD | NEW |
| 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/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| 10 #include "ash/common/wm/window_animation_types.h" | 11 #include "ash/common/wm/window_animation_types.h" |
| 11 #include "ash/common/wm/window_state_delegate.h" | 12 #include "ash/common/wm/window_state_delegate.h" |
| 12 #include "ash/common/wm/window_state_util.h" | 13 #include "ash/common/wm/window_state_util.h" |
| 13 #include "ash/common/wm/wm_event.h" | 14 #include "ash/common/wm/wm_event.h" |
| 14 #include "ash/common/wm/wm_screen_util.h" | 15 #include "ash/common/wm/wm_screen_util.h" |
| 15 #include "ash/common/wm/workspace/workspace_window_resizer.h" | 16 #include "ash/common/wm/workspace/workspace_window_resizer.h" |
| 16 #include "ash/screen_util.h" | 17 #include "ash/screen_util.h" |
| 17 #include "ash/shell.h" | 18 #include "ash/shell.h" |
| 18 #include "ash/wm/aura/wm_window_aura.h" | |
| 19 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" | 19 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
| 20 #include "ash/wm/window_animations.h" | 20 #include "ash/wm/window_animations.h" |
| 21 #include "ash/wm/window_properties.h" | 21 #include "ash/wm/window_properties.h" |
| 22 #include "ash/wm/window_state_aura.h" | 22 #include "ash/wm/window_state_aura.h" |
| 23 #include "ash/wm/window_util.h" | 23 #include "ash/wm/window_util.h" |
| 24 #include "ui/aura/client/aura_constants.h" | 24 #include "ui/aura/client/aura_constants.h" |
| 25 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 26 #include "ui/aura/window_delegate.h" | 26 #include "ui/aura/window_delegate.h" |
| 27 #include "ui/compositor/layer.h" | 27 #include "ui/compositor/layer.h" |
| 28 #include "ui/gfx/geometry/rect.h" | 28 #include "ui/gfx/geometry/rect.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 wm::WindowStateType MaximizeModeWindowState::GetType() const { | 198 wm::WindowStateType MaximizeModeWindowState::GetType() const { |
| 199 return current_state_type_; | 199 return current_state_type_; |
| 200 } | 200 } |
| 201 | 201 |
| 202 void MaximizeModeWindowState::AttachState( | 202 void MaximizeModeWindowState::AttachState( |
| 203 wm::WindowState* window_state, | 203 wm::WindowState* window_state, |
| 204 wm::WindowState::State* previous_state) { | 204 wm::WindowState::State* previous_state) { |
| 205 current_state_type_ = previous_state->GetType(); | 205 current_state_type_ = previous_state->GetType(); |
| 206 | 206 |
| 207 aura::Window* window = | 207 aura::Window* window = |
| 208 ash::wm::WmWindowAura::GetAuraWindow(window_state->window()); | 208 ash::WmWindowAura::GetAuraWindow(window_state->window()); |
| 209 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); | 209 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| 210 if (widget) { | 210 if (widget) { |
| 211 gfx::Rect bounds = widget->GetRestoredBounds(); | 211 gfx::Rect bounds = widget->GetRestoredBounds(); |
| 212 if (!bounds.IsEmpty()) { | 212 if (!bounds.IsEmpty()) { |
| 213 // We do not want to do a session restore to our window states. Therefore | 213 // We do not want to do a session restore to our window states. Therefore |
| 214 // we tell the window to use the current default states instead. | 214 // we tell the window to use the current default states instead. |
| 215 window->SetProperty(ash::kRestoreShowStateOverrideKey, | 215 window->SetProperty(ash::kRestoreShowStateOverrideKey, |
| 216 window_state->GetShowState()); | 216 window_state->GetShowState()); |
| 217 window->SetProperty(ash::kRestoreBoundsOverrideKey, | 217 window->SetProperty(ash::kRestoreBoundsOverrideKey, |
| 218 new gfx::Rect(widget->GetRestoredBounds())); | 218 new gfx::Rect(widget->GetRestoredBounds())); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 // Initialize the state to a good preset. | 222 // Initialize the state to a good preset. |
| 223 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED && | 223 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED && |
| 224 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED && | 224 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED && |
| 225 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) { | 225 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) { |
| 226 UpdateWindow(window_state, | 226 UpdateWindow(window_state, |
| 227 GetMaximizedOrCenteredWindowType(window_state), | 227 GetMaximizedOrCenteredWindowType(window_state), |
| 228 true); | 228 true); |
| 229 } | 229 } |
| 230 | 230 |
| 231 window_state->set_can_be_dragged(false); | 231 window_state->set_can_be_dragged(false); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void MaximizeModeWindowState::DetachState(wm::WindowState* window_state) { | 234 void MaximizeModeWindowState::DetachState(wm::WindowState* window_state) { |
| 235 // From now on, we can use the default session restore mechanism again. | 235 // From now on, we can use the default session restore mechanism again. |
| 236 ash::wm::WmWindowAura::GetAuraWindow(window_state->window()) | 236 ash::WmWindowAura::GetAuraWindow(window_state->window()) |
| 237 ->ClearProperty(ash::kRestoreBoundsOverrideKey); | 237 ->ClearProperty(ash::kRestoreBoundsOverrideKey); |
| 238 window_state->set_can_be_dragged(true); | 238 window_state->set_can_be_dragged(true); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void MaximizeModeWindowState::UpdateWindow(wm::WindowState* window_state, | 241 void MaximizeModeWindowState::UpdateWindow(wm::WindowState* window_state, |
| 242 wm::WindowStateType target_state, | 242 wm::WindowStateType target_state, |
| 243 bool animated) { | 243 bool animated) { |
| 244 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED || | 244 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED || |
| 245 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED || | 245 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED || |
| 246 (target_state == wm::WINDOW_STATE_TYPE_NORMAL && | 246 (target_state == wm::WINDOW_STATE_TYPE_NORMAL && |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // avoid flashing. | 306 // avoid flashing. |
| 307 if (window_state->IsMaximized()) | 307 if (window_state->IsMaximized()) |
| 308 window_state->SetBoundsDirectCrossFade(bounds_in_parent); | 308 window_state->SetBoundsDirectCrossFade(bounds_in_parent); |
| 309 else | 309 else |
| 310 window_state->SetBoundsDirectAnimated(bounds_in_parent); | 310 window_state->SetBoundsDirectAnimated(bounds_in_parent); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 } // namespace ash | 315 } // namespace ash |
| OLD | NEW |