OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/window_state.h" | 5 #include "ash/wm/window_state.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // WindowState is registered as an owned property of |window_|, and window | 88 // WindowState is registered as an owned property of |window_|, and window |
89 // unregisters all of its observers in its d'tor before destroying its | 89 // unregisters all of its observers in its d'tor before destroying its |
90 // properties. As a result, window_->RemoveObserver() doesn't need to (and | 90 // properties. As a result, window_->RemoveObserver() doesn't need to (and |
91 // shouldn't) be called here. | 91 // shouldn't) be called here. |
92 } | 92 } |
93 | 93 |
94 bool WindowState::HasDelegate() const { | 94 bool WindowState::HasDelegate() const { |
95 return !!delegate_; | 95 return !!delegate_; |
96 } | 96 } |
97 | 97 |
98 void WindowState::SetDelegate(scoped_ptr<WindowStateDelegate> delegate) { | 98 void WindowState::SetDelegate(std::unique_ptr<WindowStateDelegate> delegate) { |
99 DCHECK(!delegate_.get()); | 99 DCHECK(!delegate_.get()); |
100 delegate_ = std::move(delegate); | 100 delegate_ = std::move(delegate); |
101 } | 101 } |
102 | 102 |
103 WindowStateType WindowState::GetStateType() const { | 103 WindowStateType WindowState::GetStateType() const { |
104 return current_state_->GetType(); | 104 return current_state_->GetType(); |
105 } | 105 } |
106 | 106 |
107 bool WindowState::IsMinimized() const { | 107 bool WindowState::IsMinimized() const { |
108 return GetStateType() == WINDOW_STATE_TYPE_MINIMIZED || | 108 return GetStateType() == WINDOW_STATE_TYPE_MINIMIZED || |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 276 |
277 void WindowState::SetRestoreBoundsInParent(const gfx::Rect& bounds) { | 277 void WindowState::SetRestoreBoundsInParent(const gfx::Rect& bounds) { |
278 SetRestoreBoundsInScreen( | 278 SetRestoreBoundsInScreen( |
279 ScreenUtil::ConvertRectToScreen(window_->parent(), bounds)); | 279 ScreenUtil::ConvertRectToScreen(window_->parent(), bounds)); |
280 } | 280 } |
281 | 281 |
282 void WindowState::ClearRestoreBounds() { | 282 void WindowState::ClearRestoreBounds() { |
283 window_->ClearProperty(aura::client::kRestoreBoundsKey); | 283 window_->ClearProperty(aura::client::kRestoreBoundsKey); |
284 } | 284 } |
285 | 285 |
286 scoped_ptr<WindowState::State> WindowState::SetStateObject( | 286 std::unique_ptr<WindowState::State> WindowState::SetStateObject( |
287 scoped_ptr<WindowState::State> new_state) { | 287 std::unique_ptr<WindowState::State> new_state) { |
288 current_state_->DetachState(this); | 288 current_state_->DetachState(this); |
289 scoped_ptr<WindowState::State> old_object = std::move(current_state_); | 289 std::unique_ptr<WindowState::State> old_object = std::move(current_state_); |
290 current_state_ = std::move(new_state); | 290 current_state_ = std::move(new_state); |
291 current_state_->AttachState(this, old_object.get()); | 291 current_state_->AttachState(this, old_object.get()); |
292 return old_object; | 292 return old_object; |
293 } | 293 } |
294 | 294 |
295 void WindowState::SetPreAutoManageWindowBounds( | 295 void WindowState::SetPreAutoManageWindowBounds( |
296 const gfx::Rect& bounds) { | 296 const gfx::Rect& bounds) { |
297 pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds)); | 297 pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds)); |
298 } | 298 } |
299 | 299 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 return; | 458 return; |
459 } | 459 } |
460 | 460 |
461 const gfx::Rect old_bounds = window_->bounds(); | 461 const gfx::Rect old_bounds = window_->bounds(); |
462 | 462 |
463 // Create fresh layers for the window and all its children to paint into. | 463 // Create fresh layers for the window and all its children to paint into. |
464 // Takes ownership of the old layer and all its children, which will be | 464 // Takes ownership of the old layer and all its children, which will be |
465 // cleaned up after the animation completes. | 465 // cleaned up after the animation completes. |
466 // Specify |set_bounds| to true here to keep the old bounds in the child | 466 // Specify |set_bounds| to true here to keep the old bounds in the child |
467 // windows of |window|. | 467 // windows of |window|. |
468 scoped_ptr<ui::LayerTreeOwner> old_layer_owner = | 468 std::unique_ptr<ui::LayerTreeOwner> old_layer_owner = |
469 ::wm::RecreateLayers(window_); | 469 ::wm::RecreateLayers(window_); |
470 ui::Layer* old_layer = old_layer_owner->root(); | 470 ui::Layer* old_layer = old_layer_owner->root(); |
471 DCHECK(old_layer); | 471 DCHECK(old_layer); |
472 ui::Layer* new_layer = window_->layer(); | 472 ui::Layer* new_layer = window_->layer(); |
473 | 473 |
474 // Resize the window to the new size, which will force a layout and paint. | 474 // Resize the window to the new size, which will force a layout and paint. |
475 SetBoundsDirect(new_bounds); | 475 SetBoundsDirect(new_bounds); |
476 | 476 |
477 // Ensure the higher-resolution layer is on top. | 477 // Ensure the higher-resolution layer is on top. |
478 bool old_on_top = (old_bounds.width() > new_bounds.width()); | 478 bool old_on_top = (old_bounds.width() > new_bounds.width()); |
(...skipping 20 matching lines...) Expand all Loading... |
499 } | 499 } |
500 return settings; | 500 return settings; |
501 } | 501 } |
502 | 502 |
503 const WindowState* GetWindowState(const aura::Window* window) { | 503 const WindowState* GetWindowState(const aura::Window* window) { |
504 return GetWindowState(const_cast<aura::Window*>(window)); | 504 return GetWindowState(const_cast<aura::Window*>(window)); |
505 } | 505 } |
506 | 506 |
507 } // namespace wm | 507 } // namespace wm |
508 } // namespace ash | 508 } // namespace ash |
OLD | NEW |