Chromium Code Reviews| 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 "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 11 #include "ash/wm/coordinate_conversion.h" | 11 #include "ash/wm/coordinate_conversion.h" |
| 12 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" | 12 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
| 13 #include "ash/wm/window_animations.h" | 13 #include "ash/wm/window_animations.h" |
| 14 #include "ash/wm/window_properties.h" | 14 #include "ash/wm/window_properties.h" |
| 15 #include "ash/wm/window_state_delegate.h" | 15 #include "ash/wm/window_state_delegate.h" |
| 16 #include "ash/wm/window_state_util.h" | 16 #include "ash/wm/window_state_util.h" |
| 17 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 18 #include "ash/wm/wm_event.h" | 18 #include "ash/wm/wm_event.h" |
| 19 #include "ash/wm/workspace/workspace_window_resizer.h" | 19 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 20 #include "ui/aura/client/aura_constants.h" | 20 #include "ui/aura/client/aura_constants.h" |
| 21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_delegate.h" | 22 #include "ui/aura/window_delegate.h" |
| 23 #include "ui/compositor/layer.h" | |
| 23 #include "ui/gfx/display.h" | 24 #include "ui/gfx/display.h" |
| 24 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 25 #include "ui/views/view_constants_aura.h" | 26 #include "ui/views/view_constants_aura.h" |
| 26 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| 27 | 28 |
| 28 namespace ash { | 29 namespace ash { |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 // Returns the biggest possible size for a window which is about to be | 32 // Returns the biggest possible size for a window which is about to be |
| 32 // maximized. | 33 // maximized. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 if (animated) | 92 if (animated) |
| 92 window_state->SetBoundsDirect(bounds_in_parent); | 93 window_state->SetBoundsDirect(bounds_in_parent); |
| 93 else | 94 else |
| 94 window_state->SetBoundsDirectAnimated(bounds_in_parent); | 95 window_state->SetBoundsDirectAnimated(bounds_in_parent); |
| 95 } | 96 } |
| 96 | 97 |
| 97 MaximizeModeWindowState::MaximizeModeWindowState( | 98 MaximizeModeWindowState::MaximizeModeWindowState( |
| 98 aura::Window* window, MaximizeModeWindowManager* creator) | 99 aura::Window* window, MaximizeModeWindowManager* creator) |
| 99 : window_(window), | 100 : window_(window), |
| 100 creator_(creator), | 101 creator_(creator), |
| 101 current_state_type_(wm::GetWindowState(window)->GetStateType()) { | 102 current_state_type_(wm::GetWindowState(window)->GetStateType()), |
| 103 defer_bounds_updates_(false) { | |
| 102 old_state_.reset( | 104 old_state_.reset( |
| 103 wm::GetWindowState(window)->SetStateObject( | 105 wm::GetWindowState(window)->SetStateObject( |
| 104 scoped_ptr<State>(this).Pass()).release()); | 106 scoped_ptr<State>(this).Pass()).release()); |
| 105 } | 107 } |
| 106 | 108 |
| 107 MaximizeModeWindowState::~MaximizeModeWindowState() { | 109 MaximizeModeWindowState::~MaximizeModeWindowState() { |
| 108 creator_->WindowStateDestroyed(window_); | 110 creator_->WindowStateDestroyed(window_); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void MaximizeModeWindowState::LeaveMaximizeMode(wm::WindowState* window_state) { | 113 void MaximizeModeWindowState::LeaveMaximizeMode(wm::WindowState* window_state) { |
| 112 // Note: When we return we will destroy ourselves with the |our_reference|. | 114 // Note: When we return we will destroy ourselves with the |our_reference|. |
| 113 scoped_ptr<wm::WindowState::State> our_reference = | 115 scoped_ptr<wm::WindowState::State> our_reference = |
| 114 window_state->SetStateObject(old_state_.Pass()); | 116 window_state->SetStateObject(old_state_.Pass()); |
| 115 } | 117 } |
| 116 | 118 |
| 119 void MaximizeModeWindowState::SetDeferBoundsUpdates(bool defer_bounds_updates) { | |
| 120 if (defer_bounds_updates_ == defer_bounds_updates) | |
| 121 return; | |
| 122 | |
| 123 defer_bounds_updates_ = defer_bounds_updates; | |
| 124 if (!defer_bounds_updates_) | |
| 125 UpdateBounds(wm::GetWindowState(window_), true); | |
| 126 } | |
| 127 | |
| 117 void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state, | 128 void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state, |
| 118 const wm::WMEvent* event) { | 129 const wm::WMEvent* event) { |
| 119 switch (event->type()) { | 130 switch (event->type()) { |
| 120 case wm::WM_EVENT_TOGGLE_FULLSCREEN: | 131 case wm::WM_EVENT_TOGGLE_FULLSCREEN: |
| 121 ToggleFullScreen(window_state, window_state->delegate()); | 132 ToggleFullScreen(window_state, window_state->delegate()); |
| 122 break; | 133 break; |
| 123 case wm::WM_EVENT_FULLSCREEN: | 134 case wm::WM_EVENT_FULLSCREEN: |
| 124 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_FULLSCREEN, true); | 135 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_FULLSCREEN, true); |
| 125 break; | 136 break; |
| 126 case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: | 137 case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 } | 284 } |
| 274 | 285 |
| 275 wm::WindowStateType MaximizeModeWindowState::GetMaximizedOrCenteredWindowType( | 286 wm::WindowStateType MaximizeModeWindowState::GetMaximizedOrCenteredWindowType( |
| 276 wm::WindowState* window_state) { | 287 wm::WindowState* window_state) { |
| 277 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED : | 288 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED : |
| 278 wm::WINDOW_STATE_TYPE_NORMAL; | 289 wm::WINDOW_STATE_TYPE_NORMAL; |
| 279 } | 290 } |
| 280 | 291 |
| 281 void MaximizeModeWindowState::UpdateBounds(wm::WindowState* window_state, | 292 void MaximizeModeWindowState::UpdateBounds(wm::WindowState* window_state, |
| 282 bool animated) { | 293 bool animated) { |
| 294 if (defer_bounds_updates_) | |
|
Mr4D (OOO till 08-26)
2014/09/23 22:27:14
Just checking - you don't want the window to chang
flackr
2014/09/30 16:42:29
As long as the window is in overview, it should be
| |
| 295 return; | |
| 283 gfx::Rect bounds_in_parent = GetBoundsInMaximizedMode(window_state); | 296 gfx::Rect bounds_in_parent = GetBoundsInMaximizedMode(window_state); |
| 284 // If we have a target bounds rectangle, we center it and set it | 297 // If we have a target bounds rectangle, we center it and set it |
| 285 // accordingly. | 298 // accordingly. |
| 286 if (!bounds_in_parent.IsEmpty() && | 299 if (!bounds_in_parent.IsEmpty() && |
| 287 bounds_in_parent != window_state->window()->bounds()) { | 300 bounds_in_parent != window_state->window()->bounds()) { |
| 288 if (current_state_type_ == wm::WINDOW_STATE_TYPE_MINIMIZED || | 301 if (current_state_type_ == wm::WINDOW_STATE_TYPE_MINIMIZED || |
| 289 !window_state->window()->IsVisible() || | 302 !window_state->window()->IsVisible() || |
| 290 !animated) { | 303 !animated) { |
| 291 window_state->SetBoundsDirect(bounds_in_parent); | 304 window_state->SetBoundsDirect(bounds_in_parent); |
| 292 } else { | 305 } else { |
| 293 // If we animate (to) maximized mode, we want to use the cross fade to | 306 // If we animate (to) maximized mode, we want to use the cross fade to |
| 294 // avoid flashing. | 307 // avoid flashing. |
| 295 if (window_state->IsMaximized()) | 308 if (window_state->IsMaximized()) |
| 296 window_state->SetBoundsDirectCrossFade(bounds_in_parent); | 309 window_state->SetBoundsDirectCrossFade(bounds_in_parent); |
| 297 else | 310 else |
| 298 window_state->SetBoundsDirectAnimated(bounds_in_parent); | 311 window_state->SetBoundsDirectAnimated(bounds_in_parent); |
| 299 } | 312 } |
| 300 } | 313 } |
| 301 } | 314 } |
| 302 | 315 |
| 303 } // namespace ash | 316 } // namespace ash |
| OLD | NEW |