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> |
| 8 |
7 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
9 #include "ash/screen_util.h" | 11 #include "ash/screen_util.h" |
10 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
11 #include "ash/wm/default_state.h" | 13 #include "ash/wm/default_state.h" |
12 #include "ash/wm/window_animations.h" | 14 #include "ash/wm/window_animations.h" |
13 #include "ash/wm/window_properties.h" | 15 #include "ash/wm/window_properties.h" |
14 #include "ash/wm/window_state_delegate.h" | 16 #include "ash/wm/window_state_delegate.h" |
15 #include "ash/wm/window_state_observer.h" | 17 #include "ash/wm/window_state_observer.h" |
16 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // properties. As a result, window_->RemoveObserver() doesn't need to (and | 90 // properties. As a result, window_->RemoveObserver() doesn't need to (and |
89 // shouldn't) be called here. | 91 // shouldn't) be called here. |
90 } | 92 } |
91 | 93 |
92 bool WindowState::HasDelegate() const { | 94 bool WindowState::HasDelegate() const { |
93 return delegate_; | 95 return delegate_; |
94 } | 96 } |
95 | 97 |
96 void WindowState::SetDelegate(scoped_ptr<WindowStateDelegate> delegate) { | 98 void WindowState::SetDelegate(scoped_ptr<WindowStateDelegate> delegate) { |
97 DCHECK(!delegate_.get()); | 99 DCHECK(!delegate_.get()); |
98 delegate_ = delegate.Pass(); | 100 delegate_ = std::move(delegate); |
99 } | 101 } |
100 | 102 |
101 WindowStateType WindowState::GetStateType() const { | 103 WindowStateType WindowState::GetStateType() const { |
102 return current_state_->GetType(); | 104 return current_state_->GetType(); |
103 } | 105 } |
104 | 106 |
105 bool WindowState::IsMinimized() const { | 107 bool WindowState::IsMinimized() const { |
106 return GetStateType() == WINDOW_STATE_TYPE_MINIMIZED || | 108 return GetStateType() == WINDOW_STATE_TYPE_MINIMIZED || |
107 GetStateType() == WINDOW_STATE_TYPE_DOCKED_MINIMIZED; | 109 GetStateType() == WINDOW_STATE_TYPE_DOCKED_MINIMIZED; |
108 } | 110 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 ScreenUtil::ConvertRectToScreen(window_->parent(), bounds)); | 279 ScreenUtil::ConvertRectToScreen(window_->parent(), bounds)); |
278 } | 280 } |
279 | 281 |
280 void WindowState::ClearRestoreBounds() { | 282 void WindowState::ClearRestoreBounds() { |
281 window_->ClearProperty(aura::client::kRestoreBoundsKey); | 283 window_->ClearProperty(aura::client::kRestoreBoundsKey); |
282 } | 284 } |
283 | 285 |
284 scoped_ptr<WindowState::State> WindowState::SetStateObject( | 286 scoped_ptr<WindowState::State> WindowState::SetStateObject( |
285 scoped_ptr<WindowState::State> new_state) { | 287 scoped_ptr<WindowState::State> new_state) { |
286 current_state_->DetachState(this); | 288 current_state_->DetachState(this); |
287 scoped_ptr<WindowState::State> old_object = current_state_.Pass(); | 289 scoped_ptr<WindowState::State> old_object = std::move(current_state_); |
288 current_state_ = new_state.Pass(); | 290 current_state_ = std::move(new_state); |
289 current_state_->AttachState(this, old_object.get()); | 291 current_state_->AttachState(this, old_object.get()); |
290 return old_object.Pass(); | 292 return old_object; |
291 } | 293 } |
292 | 294 |
293 void WindowState::SetPreAutoManageWindowBounds( | 295 void WindowState::SetPreAutoManageWindowBounds( |
294 const gfx::Rect& bounds) { | 296 const gfx::Rect& bounds) { |
295 pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds)); | 297 pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds)); |
296 } | 298 } |
297 | 299 |
298 void WindowState::AddObserver(WindowStateObserver* observer) { | 300 void WindowState::AddObserver(WindowStateObserver* observer) { |
299 observer_list_.AddObserver(observer); | 301 observer_list_.AddObserver(observer); |
300 } | 302 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 // Resize the window to the new size, which will force a layout and paint. | 472 // Resize the window to the new size, which will force a layout and paint. |
471 SetBoundsDirect(new_bounds); | 473 SetBoundsDirect(new_bounds); |
472 | 474 |
473 // Ensure the higher-resolution layer is on top. | 475 // Ensure the higher-resolution layer is on top. |
474 bool old_on_top = (old_bounds.width() > new_bounds.width()); | 476 bool old_on_top = (old_bounds.width() > new_bounds.width()); |
475 if (old_on_top) | 477 if (old_on_top) |
476 old_layer->parent()->StackBelow(new_layer, old_layer); | 478 old_layer->parent()->StackBelow(new_layer, old_layer); |
477 else | 479 else |
478 old_layer->parent()->StackAbove(new_layer, old_layer); | 480 old_layer->parent()->StackAbove(new_layer, old_layer); |
479 | 481 |
480 CrossFadeAnimation(window_, old_layer_owner.Pass(), gfx::Tween::EASE_OUT); | 482 CrossFadeAnimation(window_, std::move(old_layer_owner), gfx::Tween::EASE_OUT); |
481 } | 483 } |
482 | 484 |
483 WindowState* GetActiveWindowState() { | 485 WindowState* GetActiveWindowState() { |
484 aura::Window* active = GetActiveWindow(); | 486 aura::Window* active = GetActiveWindow(); |
485 return active ? GetWindowState(active) : NULL; | 487 return active ? GetWindowState(active) : NULL; |
486 } | 488 } |
487 | 489 |
488 WindowState* GetWindowState(aura::Window* window) { | 490 WindowState* GetWindowState(aura::Window* window) { |
489 if (!window) | 491 if (!window) |
490 return NULL; | 492 return NULL; |
491 WindowState* settings = window->GetProperty(kWindowStateKey); | 493 WindowState* settings = window->GetProperty(kWindowStateKey); |
492 if(!settings) { | 494 if(!settings) { |
493 settings = new WindowState(window); | 495 settings = new WindowState(window); |
494 window->SetProperty(kWindowStateKey, settings); | 496 window->SetProperty(kWindowStateKey, settings); |
495 } | 497 } |
496 return settings; | 498 return settings; |
497 } | 499 } |
498 | 500 |
499 const WindowState* GetWindowState(const aura::Window* window) { | 501 const WindowState* GetWindowState(const aura::Window* window) { |
500 return GetWindowState(const_cast<aura::Window*>(window)); | 502 return GetWindowState(const_cast<aura::Window*>(window)); |
501 } | 503 } |
502 | 504 |
503 } // namespace wm | 505 } // namespace wm |
504 } // namespace ash | 506 } // namespace ash |
OLD | NEW |